aparrish / pronouncingpy

A simple interface for the CMU pronouncing dictionary
BSD 3-Clause "New" or "Revised" License
301 stars 42 forks source link

cannot search for 'A' #41

Closed liangnet closed 6 years ago

liangnet commented 6 years ago

In this page, http://www.speech.cs.cmu.edu/cgi-bin/cmudict?in=A, I can search for an alphabet such as 'A'. But for this python package, I cannot search for alphabet 'A' even for 'ABT' listed in the cmu dictionary 0.7d


I known why I cannot search for 'A'. 'A' should be search by 'a'

hugovk commented 6 years ago

Pronouncing converts all the words in the CMU dictionary to lowercase when reading it in, but then assumes searched words are lower case.

https://github.com/aparrish/pronouncingpy/blob/ea3f37921352e4fc6cecc626718d9be708272d5f/pronouncing/__init__.py#L30

So you'll need to use .lower() on your input.

Python 3.6.5 (default, Apr 25 2018, 14:23:58)
[GCC 4.2.1 Compatible Apple LLVM 9.1.0 (clang-902.0.39.1)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import pronouncing
>>> word = "A"
>>> pronouncing.phones_for_word(word)
[]
>>> pronouncing.phones_for_word(word.lower())
['AH0', 'EY1']
>>>

Please see PR https://github.com/aparrish/pronouncingpy/pull/42 to allow uppercase letters.

hugovk commented 6 years ago

42 has been merged, this can be closed.

aparrish commented 6 years ago

fixed in repo and in version on pypi.