Python模块,用于识别文本中的简体或繁体中文。
项目描述
汉字标识符是一个简单的Python模块,用于识别字符串中的简体或繁体字符。
免费软件:MIT许可证
关于
易于使用的辅助函数,用于识别字符串
>>> import hanzidentifier
>>> hanzidentifier.has_chinese('Hello my name is John.')
False
>>> hanzidentifier.is_simplified('John说:你好!')
True
>>> hanzidentifier.is_traditional('John說:你好!')
True
>>> hanzidentifier.has_chinese('Country in Simplified: 国家. Country in Traditional: 國家.')
True
这里是没有辅助函数的
>>> hanzidentifier.identify('Hello my name is Thomas.') is hanzidentifier.UNKNOWN
True
>>> hanzidentifier.identify('Thomas 说:你好!') is hanzidentifier.SIMPLIFIED
True
>>> hanzidentifier.identify('Thomas 說:你好!') is hanzidentifier.TRADITIONAL
True
>>> hanzidentifier.identify('你好!') is hanzidentifier.BOTH
True
>>> hanzidentifier.identify('Country in Simplified: 国家. Country in Traditional: 國家.' ) is hanzidentifier.MIXED
True
hanzidentifier.identify 有五种可能的返回值
hanzidentifier.UNKNOWN:字符串中没有识别出的汉字。
hanzidentifier.BOTH:字符串与简体和繁体字符系统兼容。
hanzidentifier.TRADITIONAL:字符串由繁体字符组成。
hanzidentifier.SIMPLIFIED:字符串由简体字符组成。
hanzidentifier.MIXED:字符串由仅作为繁体字符识别的字符组成,也包含仅作为简体字符识别的字符。
在确定字符串身份时,未在CC-CEDICT中找到的字符将被忽略。Hanzi Identifier使用由Zhon提供的CC-CEDICT数据来识别汉字。
由于繁体和简体中文字符集重叠,包含简体字的字符串可能会根据字符是否也是繁体字而标识为hanzidentifier.SIMPLIFIED或hanzidentifier.BOTH。
入门指南
安装Hanzi Identifier: $ pip install hanzidentifier
通过GitHub Issues报告错误和提问