Metadata-Version: 1.1
Name: pypinyin
Version: 0.8.4
Summary: 汉语拼音转换工具.
Home-page: https://github.com/mozillazg/python-pinyin
Author: mozillazg, 闲耘
Author-email: mozillazg101@gmail.com
License: MIT
Description: 汉语拼音转换工具（Python 版）
        =============================
        
        |Build| |Coverage| |Pypi version| |Pypi downloads|
        
        
        将汉语转为拼音。可以用于汉字注音、排序、检索。
        
        基于 `hotoo/pinyin <https://github.com/hotoo/pinyin>`__ 开发。
        
        * Documentation: http://pypinyin.rtfd.org
        * GitHub: https://github.com/mozillazg/python-pinyin
        * License: MIT license
        * PyPI: https://pypi.python.org/pypi/pypinyin
        * Python version: 2.6, 2.7, pypy, 3.3, 3.4
        
        
        特性
        ----
        
        * 根据词组智能匹配最正确的拼音。
        * 支持多音字。
        * 简单的繁体支持。
        * 支持多种不同拼音风格。
        
        
        安装
        ----
        
        .. code-block:: bash
        
            $ pip install pypinyin
        
        
        文档
        --------
        
        详细文档请访问：http://pypinyin.rtfd.org
        
        
        使用示例
        --------
        
        .. code-block:: python
        
            >>> from pypinyin import pinyin, lazy_pinyin
            >>> import pypinyin
            >>> pinyin(u'中心')
            [[u'zh\u014dng'], [u'x\u012bn']]
            >>> pinyin(u'中心', heteronym=True)  # 启用多音字模式
            [[u'zh\u014dng', u'zh\xf2ng'], [u'x\u012bn']]
            >>> pinyin(u'中心', style=pypinyin.INITIALS)  # 设置拼音风格
            [['zh'], ['x']]
            >>> pinyin('中心', style=pypinyin.TONE2, heteronym=True)
            [['zho1ng', 'zho4ng'], ['xi1n']]
            >>> lazy_pinyin(u'中心')  # 不考虑多音字的情况
            ['zhong', 'xin']
        
        命令行工具：
        
        .. code-block:: console
        
            $ pypinyin 音乐
            yīn yuè
            $ pypinyin -h
        
        
        处理不包含拼音的字符
        ---------------------
        
        当程序遇到不包含拼音的字符(串)时，会根据 ``errors`` 参数的值做相应的处理:
        
        * ``default`` (默认行为): 不做任何处理，原样返回::
        
              lazy_pinyin(u'你好☆')
              [u'ni', u'hao', u'\u2606']
        * ``ignore`` : 忽略该字符 ::
        
              lazy_pinyin(u'你好☆', errors='ignore')
              [u'ni', u'hao']
        * ``replace`` : 替换为去掉 ``\u`` 的 unicode 编码::
        
              lazy_pinyin(u'你好☆', errors='replace')
              [u'ni', u'hao', u'2606']
        
        * callable 对象 : 提供一个回调函数，接受无拼音字符(串)作为参数,
          支持的返回值类型: ``unicode`` 或 ``list`` ([unicode, ...]) 或 ``None`` 。
        
          可参考 `单元测试代码`_  ::
        
              lazy_pinyin(u'你好☆', errors=lambda x: u'star')
              [u'ni', u'hao', u'star']
        
        .. _单元测试代码: https://github.com/mozillazg/python-pinyin/blob/3d52fe821b7f55aecf5af9bad78380762484f4d9/tests/test_pinyin.py#L161-L166
        
        
        分词处理
        --------
        
        * 内置了简单的分词功能，对字符串按是否是中文字符进行分词。
        
          .. code-block:: python
        
                >> from pypinyin import lazy_pinyin
                >> lazy_pinyin(u'你好abcこんにちは')
                [u'ni', u'hao', u'abc\u3053\u3093\u306b\u3061\u306f']
        
          如果需要处理多音字问题，推荐同时安装其他分词模块。
        
        * 如果安装了 `jieba <https://github.com/fxsjy/jieba>`__ 分词模块，程序会自动调用。
        
        * 使用其他分词模块：
        
            1. 安装分词模块，比如 ``pip install snownlp`` ；
            2. 使用经过分词处理的字符串列表作参数：
        
               .. code-block:: python
        
                   >> from pypinyin import lazy_pinyin, TONE2
                   >> from snownlp import SnowNLP
                   >> hans = u'音乐123'
                   >> hans_seg = SnowNLP(hans).words  # 分词处理
                   >> hans_seg
                   [u'\u97f3\u4e50', u'123']
                   >> lazy_pinyin(hans_seg, style=TONE2)
                   [u'yi1n', u'yue4', u'123']
        
        
        自定义拼音库
        ------------
        
        如果对结果不满意，可以通过自定义拼音库的方式修正结果：
        
        
        **安装了 jieba 分词模块并且支持分词的词组**
        
        .. code-block:: python
        
            >> from pypinyin import lazy_pinyin, load_phrases_dict, TONE2
            >> hans = u'桔子'
            >> lazy_pinyin(hans, style=TONE2)
            [u'jie2', u'zi3']
            >> load_phrases_dict({u'桔子': [[u'jú'], [u'zǐ']]})
            >> lazy_pinyin(hans, style=TONE2)
            [u'ju2', u'zi3']
        
        
        **未安装 jieba 分词模块 and/or 不支持分词的词组**
        
        .. code-block:: python
        
            >> from pypinyin import lazy_pinyin, load_phrases_dict, TONE2, load_single_dict
            >> hans = u'还没'
            >> lazy_pinyin(hans, style=TONE2)
            ['hua2n', 'me2i']
            >>>  # 第一种自定义词组的方法
            >> load_phrases_dict({u'还没': [[u'hái'], [u'méi']]})
            >>> lazy_pinyin(u'还没', style=TONE2)})
            ['hua2n', 'me2i']
            >>> lazy_pinyin([u'还没'], style=TONE2)  # 手动指定 "还没" 为一个词组
            ['ha2i', 'me2i']
            >>>  # 第二种自定义词组的方法
            >> load_single_dict({ord(u'还'): u'hái,huán'})  # 调整 "还" 字的拼音顺序
            >>> lazy_pinyin(u'还没', style=TONE2)
            ['ha2i', 'me2i']
        
        
        Related Projects
        -----------------
        
        * `hotoo/pinyin`__: 汉语拼音转换工具 Node.js/JavaScript 版。
        * `mozillazg/go-pinyin`__: 汉语拼音转换工具 Go 版。
        
        __ https://github.com/hotoo/pinyin
        __ https://github.com/mozillazg/go-pinyin
        
        
        .. |Build| image:: https://img.shields.io/travis/mozillazg/python-pinyin/master.svg
           :target: https://travis-ci.org/mozillazg/python-pinyin
        .. |Coverage| image:: https://img.shields.io/coveralls/mozillazg/python-pinyin/master.svg
           :target: https://coveralls.io/r/mozillazg/python-pinyin
        .. |PyPI version| image:: https://img.shields.io/pypi/v/pypinyin.svg
           :target: https://pypi.python.org/pypi/pypinyin
        .. |PyPI downloads| image:: https://img.shields.io/pypi/dm/pypinyin.svg
           :target: https://pypi.python.org/pypi/pypinyin
        
        
        Changelog
        ---------
        
        
        0.8.4 (2015-08-23)
        ++++++++++++++++++++
        
        * ``y``, ``w`` 也不是声母. (`hotoo/pinyin#57 <https://github.com/hotoo/pinyin/issues/57>`__)
        
        
        0.8.3 (2015-08-20)
        ++++++++++++++++++++
        
        * 上传到 PyPI 出了点问题，但是又 `没法重新上传 <http://sourceforge.net/p/pypi/support-requests/468/>`__ ，只好新增一个版本
        
        
        0.8.2 (2015-08-20)
        ++++++++++++++++++++
        
        * **bugfix** 修复误把 yu 放入声母列表里的 BUG(`#22`_). Thanks `@MingStar`_
        
        
        0.8.1 (2015-07-04)
        ++++++++++++++++++++
        
        * **bugfix** 重构内置的分词功能，修复“无法正确处理包含空格的字符串的问题”
        
        
        0.8.0 (2015-06-27)
        +++++++++++++++++++++
        
        * **新增** 内置简单的分词功能，完善处理没有拼音的字符
          （如果不需要处理多音字问题, 现在可以不用安装 ``jieba`` 或其他分词模块了）::
        
                # 之前, 安装了结巴分词模块
                lazy_pinyin(u'你好abc☆☆')
                [u'ni', u'hao', 'a', 'b', 'c', u'\u2606', u'\u2606']
        
                # 现在, 无论是否安装结巴分词模块
                lazy_pinyin(u'你好abc☆☆')
                [u'ni', u'hao', u'abc\u2606\u2606']
        
        * | **[变更]** 当 ``errors`` 参数是回调函数时，函数的参数由 ``单个字符`` 变更为 ``单个字符或词组`` 。
          | 即: 对于 ``abc`` 字符串, 之前将调用三次 ``errors`` 回调函数: ``func('a') ... func('b') ... func('abc')``
          | 现在只调用一次: ``func('abc')`` 。
        * **[变更]** 将英文字符也纳入 ``errors`` 参数的处理范围::
        
                # 之前
                lazy_pinyin(u'abc', errors='ignore')
                [u'abc']
        
                # 现在
                lazy_pinyin(u'abc', errors='ignore')
                []
        
        0.7.0 (2015-06-20)
        +++++++++++++++++++++
        
        * **修复** Python 2 下无法使用 ``from pypinyin import *`` 的问题
        * **新增** 支持以下环境变量:
        
          * ``PYPINYIN_NO_JIEBA=true``: 禁用“自动调用结巴分词模块”
          * ``PYPINYIN_NO_PHRASES=true``: 禁用内置的“词组拼音库”
        
        
        0.6.0 (2015-06-10)
        +++++++++++++++++++++
        
        * **新增** ``errors`` 参数支持回调函数(`#17`_): ::
        
            def foobar(char):
                return 'a'
            pinyin(u'あ', errors=foobar)
        
        0.5.7 (2015-05-17)
        +++++++++++++++++++
        
        * 纠正包含 "便宜" 的一些词组的读音
        
        
        0.5.6 (2015-02-26)
        +++++++++++++++++++
        
        * **fix** "苹果" pinyin error. `#11`__
        * 精简 phrases_dict
        * **fix** 重复 import jieba 的问题
        * 更新文档
        
        __ https://github.com/mozillazg/python-pinyin/issues/11
        
        
        0.5.5 (2015-01-27)
        +++++++++++++++++++
        
        * **fix** phrases_dict error
        
        
        0.5.4 (2014-12-26)
        +++++++++++++++++++
        
        * **修复** 无法正确处理由分词模块产生的中英文混合词组（比如：B超，维生素C）的问题.  `#8`__
        
        __ https://github.com/mozillazg/python-pinyin/issues/8
        
        
        0.5.3 (2014-12-07)
        +++++++++++++++++++
        
        * 更新拼音库
        
        
        0.5.2 (2014-09-21)
        ++++++++++++++++++
        
        * 载入拼音库时，改为载入其副本。防止内置的拼音库被破坏
        * **修复** ``胜败乃兵家常事`` 的音标问题
        
        
        0.5.1 (2014-03-09)
        ++++++++++++++++++
        
        * **新增** 参数 ``errors`` 用来控制如何处理没有拼音的字符:
        
          * ``'default'``: 保留原始字符
          * ``'ignore'``: 忽略该字符
          * ``'replace'``: 替换为去掉 ``\u`` 的 unicode 编码字符串(``u'\u90aa'`` => ``u'90aa'``)
        
          只处理 ``[^a-zA-Z0-9_]`` 字符。
        
        
        0.5.0 (2014-03-01)
        ++++++++++++++++++
        
        * **使用新的单字拼音库内容和格式**
        
          | 新的格式：``{0x963F: u"ā,ē"}``
          | 旧的格式：``{u'啊': u"ā,ē"}``
        
        
        0.4.4 (2014-01-16)
        ++++++++++++++++++
        
        * 清理命令行命令的输出结果，去除无关信息
        * **修复** “ImportError: No module named runner”
        
        
        0.4.3 (2014-01-10)
        ++++++++++++++++++
        
        * **修复** 命令行工具在 Python 3 下的兼容性问题
        
        
        0.4.2 (2014-01-10)
        ++++++++++++++++++
        
        * **去除** 拼音风格前的 ``STYLE_`` 前缀（兼容包含 ``STYLE_`` 前缀的拼音风格）
        * **增加** 命令行工具，具体用法请见： ``pypinyin -h``
        
        
        0.4.1 (2014-01-04)
        ++++++++++++++++++
        
        * **新增** 支持自定义拼音库，方便用户修正程序结果
        
        
        0.4.0 (2014-01-03)
        ++++++++++++++++++
        
        * **变更** 将 ``jieba`` 模块改为可选安装，用户可以选择使用自己喜爱的分词模块对汉字进行分词处理
        * **新增** 支持 Python 3
        
        
        0.3.1 (2013-12-24)
        ++++++++++++++++++
        
        * **增加** ``lazy_pinyin`` ::
        
            >>> lazy_pinyin(u'中心')
            ['zhong', 'xin']
        
        
        0.3.0 (2013-09-26)
        ++++++++++++++++++
        
        * **修复** 首字母风格无法正确处理只有韵母的汉字
        
        * **新增** 三个拼音风格:
            * ``pypinyin.STYLE_FINALS`` ：       韵母风格1，只返回各个拼音的韵母部分，不带声调。如： ``ong uo``
            * ``pypinyin.STYLE_FINALS_TONE`` ：   韵母风格2，带声调，声调在韵母第一个字母上。如： ``ōng uó``
            * ``pypinyin.STYLE_FINALS_TONE2`` ：  韵母风格2，带声调，声调在各个拼音之后，用数字 [0-4] 进行表示。如： ``o1ng uo2``
        
        
        0.2.0 (2013-09-22)
        ++++++++++++++++++
        
        * 完善对中英文混合字符串的支持::
        
            >> pypinyin.pinyin(u'你好abc')
            [[u'n\u01d0'], [u'h\u01ceo'], [u'abc']]
        
        
        0.1.0 (2013-09-21)
        ++++++++++++++++++
        
        * 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
        
Keywords: pinyin,拼音
Platform: UNKNOWN
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 2
Classifier: Programming Language :: Python :: 2.6
Classifier: Programming Language :: Python :: 2.7
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.3
Classifier: Programming Language :: Python :: 3.4
Classifier: Programming Language :: Python :: Implementation :: CPython
Classifier: Programming Language :: Python :: Implementation :: PyPy
Classifier: Topic :: Utilities
