[nlp] Query from Traditional to Simplified

        Python's zhconv library provides  the maximum forward matching Simplified and Traditional Chinese conversion based on the MediaWiki vocabulary . Both pyhton2 and python3 support it, which can meet simple conversion needs.
        The following summarizes the method of zhconv from installation to use (python3). 

1. zhconv installation

pip install zhconv

2. How to use zhconv
zhconv supports the conversion of words in the following regions:
zh-cn Mainland Simplified
zh-sg Malaysia-Singapore Simplified (simplified Chinese characters used in Malaysia and Singapore)
zh-tw Taiwan Traditional (Taiwan Traditional)
zh-hk Hong Kong Traditional (Hong Kong Traditional) )
zh-hans Simplified
zh-hant Traditional (Traditional)

from zhconv import convert
# 繁体结果:無人陪我顧星辰, 無人醒我茶已冷。
s = '無人陪我顧星辰, 無人醒我茶已冷。'
s1 = convert(s, 'zh-cn')
print('转化为简体结果:', s1)
# 简体结果:无人陪我顾星辰, 无人醒我茶已冷。

Guess you like

Origin blog.csdn.net/Trance95/article/details/131500566