`

汉语言处理工具pyhanlp的简繁转换

 
阅读更多

 

 

繁简转换

HanLP几乎实现了所有我们需要的繁简转换方式,并且已经封装到了HanLP中,使得我们可以轻松的使用,而分词器中已经默认支持多种繁简格式或者混合。这里我们不再做过多描述。

说明

·HanLP能够识别简繁分歧词,比如打印机=印表機。许多简繁转换工具不能区分“以后”“皇后”中的两个“后”字,HanLP可以。

算法详解

·《汉字转拼音与简繁转换的Java实现》——请查阅此文

<!--[if !supportLists]-->1. <!--[endif]-->from pyhanlp import *

<!--[if !supportLists]-->2. <!--[endif]--># 繁简转化

<!--[if !supportLists]-->3. <!--[endif]-->print(HanLP.convertToTraditionalChinese("“以后等你当上皇后,就能买草莓庆祝了”。发现一根白头发"))

<!--[if !supportLists]-->4. <!--[endif]-->print(HanLP.convertToSimplifiedChinese("憑藉筆記簿型電腦寫程式HanLP"))

<!--[if !supportLists]-->5. <!--[endif]--># 简体转台湾繁体

<!--[if !supportLists]-->6. <!--[endif]-->print(HanLP.s2tw("hankcs在台湾写代码"))

<!--[if !supportLists]-->7. <!--[endif]--># 台湾繁体转简体

<!--[if !supportLists]-->8. <!--[endif]-->print(HanLP.tw2s("hankcs在臺灣寫程式碼"))

<!--[if !supportLists]-->9. <!--[endif]--># 简体转香港繁体

<!--[if !supportLists]-->10. <!--[endif]-->print(HanLP.s2hk("hankcs在香港写代码"))

<!--[if !supportLists]-->11. <!--[endif]--># 香港繁体转简体

<!--[if !supportLists]-->12. <!--[endif]-->print(HanLP.hk2s("hankcs在香港寫代碼"))

<!--[if !supportLists]-->13. <!--[endif]--># 香港繁体转台湾繁体

<!--[if !supportLists]-->14. <!--[endif]-->print(HanLP.hk2tw("hankcs在臺灣寫代碼"))

<!--[if !supportLists]-->15. <!--[endif]--># 台湾繁体转香港繁体

<!--[if !supportLists]-->16. <!--[endif]-->print(HanLP.tw2hk("hankcs在香港寫程式碼"))

17.

18.# 香港/台湾繁体和HanLP标准繁体的互转

19.print(HanLP.t2tw("hankcs在臺灣寫代碼"))

20.print(HanLP.t2hk("hankcs在臺灣寫代碼"))

21.

22.print(HanLP.tw2t("hankcs在臺灣寫程式碼"))

23.print(HanLP.hk2t("hankcs在台灣寫代碼"))

 

 

1.「以後等你當上皇后,就能買草莓慶祝了」。發現一根白頭髮

2.凭借笔记本电脑写程序HanLP

3.hankcs在臺灣寫程式碼

4.hankcs在台湾写代码

5.hankcs在香港寫代碼

6.hankcs在香港写代码

7.hankcs在臺灣寫程式碼

8.hankcs在香港寫代碼

9.hankcs在臺灣寫程式碼

10.hankcs在台灣寫代碼

11.hankcs在臺灣寫代碼

12.hankcs在臺灣寫代碼

---------------------

作者:Font Tian

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics