gpt4 book ai didi

python - 信息功能不返回西里尔字符

转载 作者:太空宇宙 更新时间:2023-11-04 00:36:24 25 4
gpt4 key购买 nike

我现在已经切换到 Python 3.6,但是在运行信息功能时,当我试图在我的功能提取器中打印俄语时,我最终遇到了乱码。

Most Informative Features
three_last_letters = 'оÌ' noun : verb = 6.6 : 1.0
three_last_letters = 'гÐ' noun : verb = 5.4 : 1.0
three_last_letters = 'еÐ' noun : verb = 4.7 : 1.0
three_last_letters = 'мÐ' noun : verb = 4.4 : 1.0
three_last_letters = 'нÑ' noun : verb = 3.5 : 1.0

对于特征提取器本身

def POS_features(word):
return{'three_last_letters':word[-3:]}
print(POS_features(u'Богатир'))

我可以让 тир 打印得很好,我可以做些什么来让信息功能返回俄语字符吗?

最佳答案

我想出了我做错了什么,

vocab = nltk.corpus.reader.CategorizedPlaintextCorpusReader(
"C:\\Users\\Admin\\AppData\\Roaming\\nltk_data\\corpora\\russian\\vocab", r'.*\.txt', cat_pattern=r'^(noun|verb)', encoding="utf8"

当我导入我的 vocab 文件夹时,我将它编码为 latin-1一切都很好,西里尔字符已返回给我

 Most Informative Features
three_last_letters = 'ать' verb : noun = 15.2 : 1.0
three_last_letters = 'де' noun : verb = 2.6 : 1.0
three_last_letters = 'сть' noun : verb = 1.5 : 1.0
three_last_letters = 'пра' noun : verb = 1.4 : 1.0
three_last_letters = 'ина' noun : verb = 1.4 : 1.0

关于python - 信息功能不返回西里尔字符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43850175/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com