Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
v0.8.2
  • Loading branch information
mozillazg committed Aug 20, 2015
2 parents c3d73db + 4a4d9d2 commit 60f91a5
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 29 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.rst
Expand Up @@ -2,6 +2,12 @@ Changelog
---------


0.8.2 (2015-08-20)
++++++++++++++++++++

* **bugfix** 修复误把 yu 放入声母列表里的 BUG(`#22`_). Thanks `@MingStar`_


0.8.1 (2015-07-04)
++++++++++++++++++++

Expand Down Expand Up @@ -187,3 +193,5 @@ __ https://github.com/mozillazg/python-pinyin/issues/8
* Initial Release

.. _#17: https://github.com/mozillazg/python-pinyin/pull/17
.. _#22: https://github.com/mozillazg/python-pinyin/pull/22
.. _@MingStar: https://github.com/MingStar
2 changes: 1 addition & 1 deletion pypinyin/__init__.py
Expand Up @@ -14,7 +14,7 @@
from . import phonetic_symbol, pinyin_dict

__title__ = 'pypinyin'
__version__ = '0.8.1'
__version__ = '0.8.2'
__author__ = 'mozillazg, 闲耘'
__license__ = 'MIT'
__copyright__ = 'Copyright (c) 2014 mozillazg, 闲耘'
Expand Down
2 changes: 2 additions & 0 deletions setup.py
Expand Up @@ -63,6 +63,8 @@ def long_description():
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.3',
'Programming Language :: Python :: 3.4',
'Programming Language :: Python :: Implementation :: CPython',
'Programming Language :: Python :: Implementation :: PyPy',
'Topic :: Utilities',
],
keywords='pinyin, 拼音',
Expand Down
79 changes: 51 additions & 28 deletions tests/test_pinyin.py
Expand Up @@ -170,34 +170,6 @@ def __call__(self, chars):
assert lazy_pinyin('あ' * n, errors=Foobar()) == ['a' * n]


def test_update():
data = {
'便宜': 'pia2n yi2',
'便宜从事': 'bia4n yi2 co2ng shi4',
'便宜施行': 'bia4n yi2 shi1 xi2ng',
'便宜货': 'pia2n yi2 huo4',
'贪便宜': 'ta1n pia2n yi2',
'讨便宜': 'ta3o pia2n yi2',
'小便宜': 'xia3o pia2n yi2',
'占便宜': 'zha4n pia2n yi2',
'\u3400': 'qiu1', # CJK 扩展 A:[3400-4DBF]
'\u4E00': 'yi1', # CJK 基本:[4E00-9FFF]
'\uFA29': 'da3o', # CJK 兼容:[F900-FAFF]
}
for h, p in data.items():
assert slug([h], style=TONE2, separator=' ') == p


# @pytest.mark.skipif(not has_module('jieba'), reason='cant import jieba')
# def test_set_no_jieba():
# hans = '音乐ba'
# ret = [['yi1n'], ['yue4'], ['ba']]
# assert pinyin(hans, style=TONE2) != ret
# pypinyin.seg.no_jieba = True
# assert pinyin(hans, style=TONE2) == ret
# pypinyin.seg.no_jieba = None


def test_simple_seg():
data = {
'北京abcc': 'be3i ji1ng abcc',
Expand All @@ -210,3 +182,54 @@ def test_simple_seg():
ret = 'ni3 ha3o'
errors = lambda x: None
assert slug(hans, style=TONE2, separator=' ', errors=errors) == ret


data_for_update = [
# 便宜的发音
[
['便宜'], {'style': TONE2}, ['pia2n', 'yi2']
],
[
['便宜从事'], {'style': TONE2}, ['bia4n', 'yi2', 'co2ng', 'shi4']
],
[
['便宜施行'], {'style': TONE2}, ['bia4n', 'yi2', 'shi1', 'xi2ng']
],
[
['便宜货'], {'style': TONE2}, ['pia2n', 'yi2', 'huo4']
],
[
['贪便宜'], {'style': TONE2}, ['ta1n', 'pia2n', 'yi2']
],
[
['讨便宜'], {'style': TONE2}, ['ta3o', 'pia2n', 'yi2']
],
[
['小便宜'], {'style': TONE2}, ['xia3o', 'pia2n', 'yi2']
],
[
['占便宜'], {'style': TONE2}, ['zha4n', 'pia2n', 'yi2']
],
#
[
'\u3400', {'style': TONE2}, ['qiu1'], # CJK 扩展 A:[3400-4DBF]
],
[
'\u4E00', {'style': TONE2}, ['yi1'], # CJK 基本:[4E00-9FFF]
],
[
'\uFA29', {'style': TONE2}, ['da3o'], # CJK 兼容:[F900-FAFF]
],
# 误把 yu 放到声母列表了
['鱼', {'style': TONE2}, ['yu2']],
['鱼', {'style': FINALS}, ['u']],
['雨', {'style': TONE2}, ['yu3']],
['雨', {'style': FINALS}, ['u']],
['元', {'style': TONE2}, ['yua2n']],
['元', {'style': FINALS}, ['uan']],
]


@pytest.mark.parametrize('hans, kwargs,result', data_for_update)
def test_update(hans, kwargs, result):
assert lazy_pinyin(hans, **kwargs) == result

0 comments on commit 60f91a5

Please sign in to comment.