1. Opencc-python
If the link on the directory is blocked, manually copy the https://pypi.python.org/pypi/opencc-python/
First introduced the OPENCC Python implementation Library, it has the advantages of simple installation, accurate translation, easy to use and so on. We are fully capable of our needs. Use the following steps:
1.1 Installing the Opencc-python in terminal
Pip Install Opencc-python
If the following error occurs in the installation:
Install opencc-python error message
Please download Distribute_setup.zip first, unzip, put distribute_setup.py to C:\Python27\Lib. The PIP command is then executed.
1.2 Using code:
# -*-Coding:utf8-*- Import = OPENCC. OPENCC ('t2s')print cc.convert (u'Open Chinese Convert (OPENCC) "Open Chinese Translation" is a project dedicated to the simplified translation of Chinese, providing a high quality dictionary and library (LIBOPENCC). ')
The output is:
Open Chinese Convert (OPENCC) is a project dedicated to Simplified Chinese conversion, providing high-quality thesaurus and function libraries (LIBOPENCC).
There are four types of built-in OPENCC translation configurations:
- T2s-Traditional to simplified (traditional Chinese to Simplified Chinese)
- S2T-Simplified to traditional (Simplified Chinese to Traditional Chinese)
- MIX2T-Mixed to traditional (Mixed to traditional Chinese)
- Mix2s-Mixed transfer simplified (Mixed to Simplified Chinese)
2. Zhtools
The brief steps are as follows:
2.1 Chinese Simplified and traditional conversion required Python library: zh_wiki.py (new Word library added in the original author's library), Langconv
2.2 Using Code
fromLangconvImport*defsimple2tradition (line):#convert simplified to traditionalline = Converter ('zh-hant'). Convert (Line.decode ('Utf-8')) Line= Line.encode ('Utf-8') return LinedefTradition2simple (line):#convert traditional to simplifiedline = Converter ('Zh-hans'). Convert (Line.decode ('Utf-8')) Line= Line.encode ('Utf-8') returnLine
The advantages of the program are light weight, easy to use, concise, but may not be translated very accurately, for example, the original author's library is translated into traditional:
\ before, Hou Yi \
And the exact traditional is this:
\ before, Hou Yi \
3. Summary
The final project is also a second scenario, because the second scenario is lightweight and has no unpredictable impact on the game after the library is filled and the accuracy is available. Of course the first solution is very mature and accurate, both as research and work tools are very good choices.
Python for Simplified Chinese and traditional to convert each other