Created
July 4, 2018 04:20
-
-
Save RamonYeung/feb57efbe735a90fbea4158ea8d02171 to your computer and use it in GitHub Desktop.
Demo for Converting Traditional Chinese Characters to Simplified Chinese Characters.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# copy and paste two modules. | |
# https://raw.githubusercontent.com/skydark/nstools/master/zhtools/langconv.py | |
# https://raw.githubusercontent.com/skydark/nstools/master/zhtools/zh_wiki.py | |
from langconv import * | |
def Traditional2Simplified(sentence): | |
sentence = Converter('zh-hans').convert(sentence) | |
return sentence | |
if __name__=="__main__": | |
traditional_sentence = '憂郁的臺灣烏龜' | |
simplified_sentence = Traditional2Simplified(traditional_sentence) | |
print(simplified_sentence) | |
''' | |
输出结果: | |
忧郁的台湾乌龟 | |
''' | |
# from langconv import * | |
# def Simplified2Traditional(sentence): | |
# sentence = Converter('zh-hant').convert(sentence) | |
# return sentence | |
# if __name__=="__main__": | |
# simplified_sentence = '忧郁的台湾乌龟' | |
# traditional_sentence = Simplified2Traditional(simplified_sentence) | |
# print(traditional_sentence) | |
# ''' | |
# 输出结果: | |
# 憂郁的臺灣烏龜 | |
# ''' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment