Skip to content

Instantly share code, notes, and snippets.

@RamonYeung
Created July 4, 2018 04:20
Show Gist options
  • Save RamonYeung/feb57efbe735a90fbea4158ea8d02171 to your computer and use it in GitHub Desktop.
Save RamonYeung/feb57efbe735a90fbea4158ea8d02171 to your computer and use it in GitHub Desktop.
Demo for Converting Traditional Chinese Characters to Simplified Chinese 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