Skip to content

Commit

Permalink
Fix conversion for characters with vowel ü (v)
Browse files Browse the repository at this point in the history
  • Loading branch information
iccanobif committed Oct 8, 2016
1 parent 4dbd542 commit 287e34a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pinyin/pinyin.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def _pinyin_generator(chars, format):
elif format == "diacritical":
# Find first vowel -- where we should put the diacritical mark
vowels = itertools.chain((c for c in pinyin if c in "aeo"),
(c for c in pinyin if c in "iu"))
(c for c in pinyin if c in "iuv"))
vowel = pinyin.index(next(vowels)) + 1
pinyin = pinyin[:vowel] + tonemarks[tone] + pinyin[vowel:]
else:
Expand Down
2 changes: 2 additions & 0 deletions test_pinyin.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ def test_get(self):

self.assertEqual(pinyin.get('你好'), u('nǐhǎo'))
self.assertEqual(pinyin.get('叶'), u('yè'))
self.assertEqual(pinyin.get('少女'), u('shǎonv̌'))

def test_get_with_delimiter(self):
self.assertEqual(pinyin.get('你好', " "), u('nǐ hǎo'))
Expand All @@ -46,6 +47,7 @@ def test_correct_diacritical(self):
self.assertEqual(pinyin.get("小"), u("xiǎo"))
self.assertEqual(pinyin.get("绝"), u("jué"))
self.assertEqual(pinyin.get("被"), u("bèi"))
self.assertEqual(pinyin.get("略"), u("lvè"))


if __name__ == '__main__':
Expand Down

0 comments on commit 287e34a

Please sign in to comment.