suyashb95 / WiktionaryParser

A Python Wiktionary Parser
MIT License
357 stars 92 forks source link

Support for Cantonese #9

Open afaiza opened 7 years ago

afaiza commented 7 years ago

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
suyashb95 commented 7 years ago

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?

afaiza commented 7 years ago

Actually, I need more the pronunciations.

Thank you!

kevinsung commented 2 years ago

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.