Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
mozillazg committed Jan 10, 2014
2 parents 1f040e0 + e8ceceb commit 48ba7c7
Show file tree
Hide file tree
Showing 13 changed files with 295 additions and 104 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Expand Up @@ -11,7 +11,7 @@ install:
- "pip install -e . --use-mirrors"

script:
- if [[ $TRAVIS_PYTHON_VERSION == 2* ]]; then pip install -r requirements.txt --use-mirrors; fi
- if [[ $TRAVIS_PYTHON_VERSION == 2* ]]; then pip install -r requirements_dev.txt --use-mirrors; fi
- "python setup.py test"
- "python setup.py develop"
- "py.test --cov pypinyin tests/"
Expand Down
7 changes: 7 additions & 0 deletions CHANGELOG.rst
Expand Up @@ -2,6 +2,13 @@ Changelog
---------


0.4.2 (2014-01-10)
++++++++++++++++++

* 去除拼音风格前的 ``STYLE_`` 前缀(兼容包含 ``STYLE_`` 前缀的拼音风格)
* 增加命令行工具,具体用法请见: ``pypinyin -h``


0.4.1 (2014-01-04)
++++++++++++++++++

Expand Down
22 changes: 15 additions & 7 deletions README.rst
Expand Up @@ -15,13 +15,13 @@
* Python 版本: 2.6, 2.7, pypy, 3.3


.. 特性
.. ----
..
.. * 根据词组智能匹配最正确的拼音。
.. * 支持多音字。
.. * 简单的繁体支持。
.. * 支持多种不同拼音风格。
特性
----

* 根据词组智能匹配最正确的拼音。
* 支持多音字。
* 简单的繁体支持。
* 支持多种不同拼音风格。


安装
Expand Down Expand Up @@ -51,6 +51,14 @@
>>> lazy_pinyin(u'中心')
['zhong', 'xin']
命令行工具:

.. code-block:: console
$ pypinyin 音乐
yīn yuè
$ pypinyin -h
分词处理
--------
Expand Down
2 changes: 1 addition & 1 deletion docs/conf.py
Expand Up @@ -260,7 +260,7 @@
epub_title = 'pypinyin'
epub_author = 'mozillazg'
epub_publisher = 'mozillazg'
epub_copyright = '2013, mozillazg'
epub_copyright = '2014 mozillazg'

# The language of the text. It defaults to the language option
# or en if the language is not set.
Expand Down
72 changes: 45 additions & 27 deletions docs/index.rst
Expand Up @@ -3,6 +3,7 @@
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
汉语拼音转换工具(Python 版)
=============================

Expand All @@ -13,20 +14,20 @@

基于 `hotoo/node-pinyin <https://github.com/hotoo/node-pinyin>`__ 开发。

* 文档 http://pypinyin.rtfd.org
* 文档: http://pypinyin.rtfd.org
* GitHub: https://github.com/mozillazg/python-pinyin
* 开源协议: MIT license
* PyPI: https://pypi.python.org/pypi/pypinyin
* Python 版本: 2.6, 2.7, pypy, 3.3


.. 特性
.. ----
..
.. * 根据词组智能匹配最正确的拼音。
.. * 支持多音字。
.. * 简单的繁体支持。
.. * 支持多种不同拼音风格。
特性
----

* 根据词组智能匹配最正确的拼音。
* 支持多音字。
* 简单的繁体支持。
* 支持多种不同拼音风格。


安装
Expand All @@ -36,8 +37,8 @@
$ pip install pypinyin
为了更好的包含处理多音字及中英文混合的字符串
推荐安装 `jieba <https://github.com/fxsjy/jieba>`__ 分词模块。
为了更好的处理包含多音字及非中文字符的字符串
推荐同时安装 `jieba <https://github.com/fxsjy/jieba>`__ 分词模块。


使用示例
Expand All @@ -56,6 +57,14 @@
>>> lazy_pinyin(u'中心')
['zhong', 'xin']
命令行工具:

.. code-block:: console
$ pypinyin 音乐
yīn yuè
$ pypinyin -h
分词处理
--------
Expand Down Expand Up @@ -111,28 +120,29 @@
:target: https://crate.io/packages/pypinyin



API
---

拼音风格:

+-----------------------------+----------------------------------------------------------------------------------+
|pypinyin.STYLE_NORMAL |普通风格(0),不带声调。如: ``pin yin`` |
+-----------------------------+----------------------------------------------------------------------------------+
|pypinyin.STYLE_TONE |声调风格(1),拼音声调在韵母第一个字母上(默认风格)。如: ``pīn yīn`` |
+-----------------------------+----------------------------------------------------------------------------------+
|pypinyin.STYLE_TONE2 |声调风格2(2),即拼音声调在各个拼音之后,用数字 [0-4] 进行表示。如: ``pi1n yi1n`` |
+-----------------------------+----------------------------------------------------------------------------------+
|pypinyin.STYLE_INITIALS |声母风格(3),只返回各个拼音的声母部分。如: ``中国`` 的拼音 ``zh g`` |
+-----------------------------+----------------------------------------------------------------------------------+
|pypinyin.STYLE_FIRST_LETTER |首字母风格(4),只返回拼音的首字母部分。如: ``p y`` |
+-----------------------------+----------------------------------------------------------------------------------+
|pypinyin.STYLE_FINALS |韵母风格1(5),只返回各个拼音的韵母部分,不带声调。如: ``ong uo`` |
+-----------------------------+----------------------------------------------------------------------------------+
|pypinyin.STYLE_FINALS_TONE |韵母风格2(6),带声调,声调在韵母第一个字母上。如: ``ōng uó`` |
+-----------------------------+----------------------------------------------------------------------------------+
|pypinyin.STYLE_FINALS_TONE2 |韵母风格2(7),带声调,声调在各个拼音之后,用数字 [0-4] 进行表示。如: ``o1ng uo2``|
+-----------------------------+----------------------------------------------------------------------------------+
+-----------------------+----------------------------------------------------------------------------------+
|pypinyin.NORMAL |普通风格(0),不带声调。如: ``pin yin`` |
+-----------------------+----------------------------------------------------------------------------------+
|pypinyin.TONE |声调风格(1),拼音声调在韵母第一个字母上(默认风格)。如: ``pīn yīn`` |
+-----------------------+----------------------------------------------------------------------------------+
|pypinyin.TONE2 |声调风格2(2),即拼音声调在各个拼音之后,用数字 [0-4] 进行表示。如: ``pi1n yi1n`` |
+-----------------------+----------------------------------------------------------------------------------+
|pypinyin.INITIALS |声母风格(3),只返回各个拼音的声母部分。如: ``中国`` 的拼音 ``zh g`` |
+-----------------------+----------------------------------------------------------------------------------+
|pypinyin.FIRST_LETTER |首字母风格(4),只返回拼音的首字母部分。如: ``p y`` |
+-----------------------+----------------------------------------------------------------------------------+
|pypinyin.FINALS |韵母风格1(5),只返回各个拼音的韵母部分,不带声调。如: ``ong uo`` |
+-----------------------+----------------------------------------------------------------------------------+
|pypinyin.FINALS_TONE |韵母风格2(6),带声调,声调在韵母第一个字母上。如: ``ōng uó`` |
+-----------------------+----------------------------------------------------------------------------------+
|pypinyin.FINALS_TONE2 |韵母风格2(7),带声调,声调在各个拼音之后,用数字 [0-4] 进行表示。如: ``o1ng uo2``|
+-----------------------+----------------------------------------------------------------------------------+


.. autofunction:: pypinyin.pinyin
Expand All @@ -150,6 +160,13 @@ Changelog
---------


0.4.2 (2014-xx-yy)
++++++++++++++++++

* 去除拼音风格前的 ``STYLE_`` 前缀(兼容包含 ``STYLE_`` 前缀的拼音风格)
* 增加命令行工具,具体用法请见: ``pypinyin -h``


0.4.1 (2014-01-04)
++++++++++++++++++

Expand Down Expand Up @@ -198,6 +215,7 @@ Changelog
* Initial Release



Indices and tables
------------------

Expand Down
54 changes: 54 additions & 0 deletions docs/index.rst.txt
@@ -0,0 +1,54 @@
.. pypinyin documentation master file, created by
sphinx-quickstart on Fri Sep 06 22:22:13 2013.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
${readme}


API
---

拼音风格:

+-----------------------+----------------------------------------------------------------------------------+
|pypinyin.NORMAL |普通风格(0),不带声调。如: ``pin yin`` |
+-----------------------+----------------------------------------------------------------------------------+
|pypinyin.TONE |声调风格(1),拼音声调在韵母第一个字母上(默认风格)。如: ``pīn yīn`` |
+-----------------------+----------------------------------------------------------------------------------+
|pypinyin.TONE2 |声调风格2(2),即拼音声调在各个拼音之后,用数字 [0-4] 进行表示。如: ``pi1n yi1n`` |
+-----------------------+----------------------------------------------------------------------------------+
|pypinyin.INITIALS |声母风格(3),只返回各个拼音的声母部分。如: ``中国`` 的拼音 ``zh g`` |
+-----------------------+----------------------------------------------------------------------------------+
|pypinyin.FIRST_LETTER |首字母风格(4),只返回拼音的首字母部分。如: ``p y`` |
+-----------------------+----------------------------------------------------------------------------------+
|pypinyin.FINALS |韵母风格1(5),只返回各个拼音的韵母部分,不带声调。如: ``ong uo`` |
+-----------------------+----------------------------------------------------------------------------------+
|pypinyin.FINALS_TONE |韵母风格2(6),带声调,声调在韵母第一个字母上。如: ``ōng uó`` |
+-----------------------+----------------------------------------------------------------------------------+
|pypinyin.FINALS_TONE2 |韵母风格2(7),带声调,声调在各个拼音之后,用数字 [0-4] 进行表示。如: ``o1ng uo2``|
+-----------------------+----------------------------------------------------------------------------------+


.. autofunction:: pypinyin.pinyin

.. autofunction:: pypinyin.slug

.. autofunction:: pypinyin.lazy_pinyin

.. autofunction:: pypinyin.load_single_dict

.. autofunction:: pypinyin.load_phrases_dict


${changelog}


Indices and tables
------------------

* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`

22 changes: 22 additions & 0 deletions docs/update_index_rst.py
@@ -0,0 +1,22 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""更新 index.rst"""

from string import Template

readme_rst = '../README.rst'
changelog_rst = '../CHANGELOG.rst'
template_file = 'index.rst.txt'
index_rst = 'index.rst'

kwargs = {}

with open(readme_rst) as f:
kwargs['readme'] = f.read()
with open(changelog_rst) as f:
kwargs['changelog'] = f.read()

with open(index_rst, 'w') as f:
with open(template_file) as f2:
f.write(Template(f2.read()).safe_substitute(kwargs))

0 comments on commit 48ba7c7

Please sign in to comment.