WiktionaryParser
WiktionaryParser copied to clipboard
Support for Cantonese
Hi,
Thank you for this excellent parser.
I am trying to run this parser on Cantonese entries in Wiktionary, but they are not always found, and when they are found, the data returned is... weird.
I attached an example, where some words that exist in Wiktionary are not returned, and other words actually get different pronunciation (!) than the one written in Wiktionary.
Your help is much appreciated!
Thanks.
This is the code I run:
from wiktionaryparser import WiktionaryParser
import codecs
import sys
parser = WiktionaryParser()
with open('wiktionary_data.txt', "w") as outFile:
with codecs.open("wordcount.log", "r", encoding="UTF-8") as inFile:
for line in inFile:
word = line.split()[0]
wiktionaryWord = parser.fetch(word, "Chinese")
if len(wiktionaryWord) > 0:
outFile.write(word.encode('UTF-8') + "," + str(wiktionaryWord[0]) + "\n")
This is the file wordcount.log
喺 133175
我 84912
個 81040
你 75672
咁 66798
唔 60689
嘅 56333
啊 54957
係 48753
誒 46097
That's weird, probably the structure of the page is different for cantonese. I'm looking into it. I am assuming you only need the definitions?
Actually, I need more the pronunciations.
Thank you!
This issue really applies to the Chinese languages in general, not just Cantonese. It's related to the issue I raise at https://github.com/Suyash458/WiktionaryParser/pull/85#issuecomment-982766291.