Giter Site home page Giter Site logo

gumblex / zhconv Goto Github PK

View Code? Open in Web Editor NEW
504.0 8.0 35.0 937 KB

Simple conversion and localization between simplified and traditional Chinese using tables from MediaWiki.

Home Page: https://pypi.python.org/pypi/zhconv

License: MIT License

Python 100.00%
chinese-simplified chinese-traditional mediawiki

zhconv's Issues

MediaWiki 转换词典的版权问题

MediaWiki 的代码是 GPL 的,他的转换词典有通过其他协议释出的版本吗?如果没有的话 MIT 协议的项目应该没法用他的词典。

命令行含义不明

https://pypi.org/project/zhconv/1.4.0/#description

这里我试了半天,不知道怎么输入命令执行

python -mzhconv [-w] {zh-cn|zh-tw|zh-hk|zh-sg|zh-hans|zh-hant|zh} < input > output

我试过以下命令,怎么用都是错的

python3 -mzhconv -w zh-cn ./tc/ ./out
python3 -mzhconv -zh-cn ./tc ./out
python3 -mzhconv zh-cn ./tc ./out

请吾作纯浏览器 JavaScript 之版

我以此事颇有意思,欲为纯浏览器本者,并加之级段落启发式模板,卿可议开源许我做这衍生本乎?

(我觉得这个工作很有意思,想做一个纯浏览器的版本,并加入一些段落级的启发式模板,你的开源协议可以允许我做这样的衍生版本吗?)

古文翻译

老王,你的古文翻译功能,能给个接口不

Maybe raise a keyerror is a better way to process the locale not supported

Because return the not actually converted sentence may confuse someone that is careless about the supported locales.
And I think raise an error early can stop future big error for user codes.

zhconv/zhconv/zhconv.py

Lines 235 to 254 in 078838e

def convert(s, locale, update=None):
"""
Main convert function.
:param s: must be `unicode` (Python 2) or `str` (Python 3).
:param locale: should be one of ``('zh-hans', 'zh-hant', 'zh-cn', 'zh-sg'
'zh-tw', 'zh-hk', 'zh-my', 'zh-mo')``.
:param update: a dict which updates the conversion table, eg.
``{'from1': 'to1', 'from2': 'to2'}``
>>> print(convert('我幹什麼不干你事。', 'zh-cn'))
我干什么不干你事。
>>> print(convert('我幹什麼不干你事。', 'zh-cn', {'不干': '不幹'}))
我干什么不幹你事。
>>> print(convert('人体内存在很多微生物', 'zh-tw'))
人體內存在很多微生物
"""
if locale == 'zh' or locale not in Locales:
# "no conversion"
return s

Let's see a mistake that may confuse the users in using the locale:

inputs = "我幹什麼不干你事"
print(convert(temp, locale='zh_cn'))
#output the same as the inputs but no warnings or erros 

Maybe many users like me use zh_cn instead of the correct zh_cn by mistake sometime.

pkg_resources is deprecated as an API

  C:\pv\tts\lib\site-packages\zhconv\zhconv.py:33: DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html
    from pkg_resources import resource_stream

..\..\..\..\..\pv\tts\lib\site-packages\pkg_resources\__init__.py:2868
..\..\..\..\..\pv\tts\lib\site-packages\pkg_resources\__init__.py:2868
..\..\..\..\..\pv\tts\lib\site-packages\pkg_resources\__init__.py:2868
..\..\..\..\..\pv\tts\lib\site-packages\pkg_resources\__init__.py:2868
  C:\pv\tts\lib\site-packages\pkg_resources\__init__.py:2868: DeprecationWarning: Deprecated call to `pkg_resources.declare_namespace('google')`.
  Implementing implicit namespace packages (as specified in PEP 420) is preferred to `pkg_resources.declare_namespace`. See https://setuptools.pypa.io/en/latest/references/keywords.html#keyword-namespace-packages
    declare_namespace(pkg)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.