0. Background
The agent's game is a simplified Chinese version, in order to make the game become a traditional Chinese version of Hong Kong and Macao. The custom of the Simplified Chinese (the vast majority) is to find the local translation of Taiwanese, but there is a voice recognition function, because it is not a custom content, so found two simplified Chinese to traditional simple implementation. 1. Opencc-python
If the link on the directory is blocked, please copy https://pypi.python.org/pypi/opencc-python/manually
This paper first introduces the Python implementation Library of OPENCC, which has the advantages of simple installation, accurate translation and convenient use. We are fully qualified for our needs. Use the following steps:
1.1 Installing Opencc-python in terminal
Pip Install Opencc-python
If the following error occurred in the installation:
Please download Distribute_setup.zip first, after decompression, put the distribute_setup.py to C:\Python27\Lib. And then execute the PIP command.
1.2 Using code:
#-*-Coding:utf8-*-
import opencc
cc = OPENCC. The OPENCC (' T2s ')
print cc.convert (U ' Open Chinese convert (OPENCC), "opening Chinese conversion", is an item dedicated to Chinese simplicity, providing a high quality vocabulary and function library (LIBOPENCC). ')
The output is:
Open Chinese Convert (OPENCC) is a project dedicated to Chinese Simplified translation, providing a high quality thesaurus and function library (LIBOPENCC).
There are four built-in OPENCC translation configurations:
-T2s-Traditional to simplified (traditional Chinese to Simplified Chinese)
-s2t-Simplified traditional (Simplified Chinese to Traditional Chinese)
-mix2t-Mixed to traditional (Mixed to traditional Chinese)
-Mix2s-Mixed to simplified (Mixed to Simplified Chinese) 2. Zhtools
The reference blog "Python implementation Chinese characters traditional and Simplified Chinese conversion", the brief steps are as follows:
2.1 Simplified and Traditional Chinese translation required Python library: zh_wiki.py (add a new thesaurus to the original author's library), Langconv
2.2 Using Code
From Langconv import *
def simple2tradition (line):
#将简体转换成繁体 Line
= Converter (' zh-hant '). CONVERT ( Line.decode (' Utf-8 ') line
= Line.encode (' utf-8 ') return line
def tradition2simple (line):
# Convert traditional to simplified line
= Converter (' Zh-hans '). Convert (Line.decode (' utf-8 ')) line
= Line.encode (' utf-8 ') return
Line
The advantages of the scheme are lightweight, easy to use, concise, but may not be very accurate translation, for example, the original author of the Library is so translated into traditional:
Before, Hou Yi
And the exact traditional is this:
Before, Hou yi \ 3. Summary
The final project uses the second scenario, because the second scenario, when accuracy is still available after the library is populated, does not have an unforeseen impact on the game. Of course the first option is very mature and accurate, both as research and work tools are very good choices.
Directory
Background Opencc-python Zhtools Summary