简体中文繁体中文互转,可以用github上的OpenCC项目,全名是Open Chinese Convert 開放中文轉換,应该是世界上精度最高的简繁互转项目。
https://github.com/BYVoid/OpenCC
这是一个中文簡繁轉換開源項目,支持詞彙級別的轉換、異體字轉換和地區習慣用詞轉換(中國大陸、臺灣、香港、日本新字體)。不提供普通話與粵語的轉換。
支持网站在线转换,JS,C++,Python等。
我的实际使用需求是,将一个繁体内容的txt,转为简体。因为Python操作文件流比较方便,所以我用的是Python,代码如下:
[Python] 纯文本查看 复制代码 import opencc
converter = opencc.OpenCC('tw2sp.json')
with open("./1.txt", mode='r', encoding="UTF-8") as f1:
content = f1.read()
with open("./tmp.txt", mode='w', encoding="UTF-8") as f2:
f2.write(converter.convert(content))
Configurations 配置文件[color=var(--color-text-link)]預設配置文件- s2t.json Simplified Chinese to Traditional Chinese 簡體到繁體
- t2s.json Traditional Chinese to Simplified Chinese 繁體到簡體
- s2tw.json Simplified Chinese to Traditional Chinese (Taiwan Standard) 簡體到臺灣正體
- tw2s.json Traditional Chinese (Taiwan Standard) to Simplified Chinese 臺灣正體到簡體
- s2hk.json Simplified Chinese to Traditional Chinese (Hong Kong variant) 簡體到香港繁體
- hk2s.json Traditional Chinese (Hong Kong variant) to Simplified Chinese 香港繁體到簡體
- s2twp.json Simplified Chinese to Traditional Chinese (Taiwan Standard) with Taiwanese idiom 簡體到繁體(臺灣正體標準)並轉換爲臺灣常用詞彙
- tw2sp.json Traditional Chinese (Taiwan Standard) to Simplified Chinese with Mainland Chinese idiom 繁體(臺灣正體標準)到簡體並轉換爲中國大陸常用詞彙
- t2tw.json Traditional Chinese (OpenCC Standard) to Taiwan Standard 繁體(OpenCC 標準)到臺灣正體
- hk2t.json Traditional Chinese (Hong Kong variant) to Traditional Chinese 香港繁體到繁體(OpenCC 標準)
- t2hk.json Traditional Chinese (OpenCC Standard) to Hong Kong variant 繁體(OpenCC 標準)到香港繁體
- t2jp.json Traditional Chinese Characters (Kyūjitai) to New Japanese Kanji (Shinjitai) 繁體(OpenCC 標準,舊字體)到日文新字體
- jp2t.json New Japanese Kanji (Shinjitai) to Traditional Chinese Characters (Kyūjitai) 日文新字體到繁體(OpenCC 標準,舊字體)
- tw2t.json Traditional Chinese (Taiwan standard) to Traditional Chinese 臺灣正體到繁體(OpenCC 標準)
最后求一波免费评分,谢谢! |