tsroten / dragonmapper

Identification and conversion functions for Chinese text processing
MIT License
56 stars 19 forks source link

Pinyin/Zhuyin/IPA syllable `o` is missing. #23

Closed kwebber3 closed 7 years ago

kwebber3 commented 7 years ago
>>> print(transcriptions.pinyin_to_zhuyin(ó))
Traceback (most recent call last):
  File "D:\OneDrive\My Programs\zhuyin converter\Convert2BopomofoPunctuation.py", line 100, in <module>
    print(printBopomofo(eachLine)+"\n"*3)
  File "D:\OneDrive\My Programs\zhuyin converter\Convert2BopomofoPunctuation.py", line 42, in printBopomofo
    bopomofoDictionary=makeToneDictionary(hanzistring2)
  File "D:\OneDrive\My Programs\zhuyin converter\Convert2BopomofoPunctuation.py", line 35, in makeToneDictionary
    bopomofoList=listBopomofo(hanzi)
  File "D:\OneDrive\My Programs\zhuyin converter\Convert2BopomofoPunctuation.py", line 11, in listBopomofo
    print(transcriptions.pinyin_to_zhuyin(ó))
NameError: name 'ó' is not defined

also the following string returns an error

 (1 4 事情是這樣的 , 父親讀到也看到許多偉大而奇妙的事時 , 他向主高呼許多事 , 諸如 : 哦 , 主神全能者 , 您的事工多麼偉大而奇妙 ! 您的寶座在高天之上 , 您的大能、良善和慈悲廣被世上全民 , 而且 , 由於您的慈悲 , 您不會讓歸向您的人滅亡 ! ) 
>>> pinyin=hanzi.to_zhuyin(hanzistring)
Traceback (most recent call last):
  File "C:\Users\Kei\AppData\Local\Programs\Python\Python35\lib\site-packages\dragonmapper\transcriptions.py", line 227, in pinyin_syllable_to_zhuyin
    zhuyin_syllable = _PINYIN_MAP[pinyin_syllable.lower()]['Zhuyin']
KeyError: 'o'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "D:\OneDrive\My Programs\zhuyin converter\Convert2BopomofoPunctuation.py", line 100, in <module>
    print(printBopomofo(eachLine)+"\n"*3)
  File "D:\OneDrive\My Programs\zhuyin converter\Convert2BopomofoPunctuation.py", line 42, in printBopomofo
    bopomofoDictionary=makeToneDictionary(hanzistring2)
  File "D:\OneDrive\My Programs\zhuyin converter\Convert2BopomofoPunctuation.py", line 35, in makeToneDictionary
    bopomofoList=listBopomofo(hanzi)
  File "D:\OneDrive\My Programs\zhuyin converter\Convert2BopomofoPunctuation.py", line 12, in listBopomofo
    pinyin=hanzi.to_zhuyin(hanzistring)
  File "C:\Users\Kei\AppData\Local\Programs\Python\Python35\lib\site-packages\dragonmapper\hanzi.py", line 190, in to_zhuyin
    zhuyin = pinyin_to_zhuyin(numbered_pinyin)
  File "C:\Users\Kei\AppData\Local\Programs\Python\Python35\lib\site-packages\dragonmapper\transcriptions.py", line 365, in pinyin_to_zhuyin
    remove_apostrophes=True, separate_syllables=True)
  File "C:\Users\Kei\AppData\Local\Programs\Python\Python35\lib\site-packages\dragonmapper\transcriptions.py", line 341, in _convert
    new += syllable_function(match.group())
  File "C:\Users\Kei\AppData\Local\Programs\Python\Python35\lib\site-packages\dragonmapper\transcriptions.py", line 229, in pinyin_syllable_to_zhuyin
    raise ValueError('Not a valid syllable: %s' % s)
ValueError: Not a valid syllable: o2
tsroten commented 7 years ago

Hi @kwebber3, thanks for using Dragon Mapper!

In your first example, the NameError is because ó wasn't surrounded by quotes (e.g. 'ó').

But, there is definitely a bug here, because even with quotes, you get a KeyError because o is missing from the transcriptions data in Dragon Mapper. I'll get that fixed :)

Thanks for reporting this issue!