Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/305.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 咒语是什么意思_Python_Nlp_Hunspell_Misspelling - Fatal编程技术网

Python 咒语是什么意思

Python 咒语是什么意思,python,nlp,hunspell,misspelling,Python,Nlp,Hunspell,Misspelling,我正在进行文本分类,面临拼写错误的问题。我试图用spacy\u hunspell解决它,但无法得到hunspell\u spell属性的意义,因为它总是不返回任何值 for token in nlp('I can haz cheezeburger.'): print(token._.hunspell_spell) if not token._.hunspell_spell: print(token.text, token._.hunspell_suggest)

我正在进行文本分类,面临拼写错误的问题。我试图用spacy\u hunspell解决它,但无法得到hunspell\u spell属性的意义,因为它总是不返回任何值

for token in  nlp('I can haz cheezeburger.'):
    print(token._.hunspell_spell)
    if not token._.hunspell_spell:
        print(token.text, token._.hunspell_suggest)
上面列出的代码返回:

None
I ['I', 'Ia', 'In', 'Ir', 'It', 'Io', 'IE', 'IA', 'AI', 'IN', 'RI', 'IT', 'IL', 'ID', 'DI']
None
can ['Can', 'van', 'cab', 'cam', 'ca', 'an', 'cane', 'cans', 'scan', 'cant', 'clan', 'cyan', 'Scan', 'car', 'ran']
None
haz ['ha', 'haze', 'hazy', 'has', 'hat', 'had', 'hag', 'ham', 'hap', 'hay', 'haw', 'ha z']
None
cheezeburger ['cheeseburger', 'vegeburger']
None
. []
I is misspeled
can is correct
haz is misspeled
cheezeburger is misspeled
. is misspeled
一开始我认为这个属性返回的标记是否拼写错误。 有人知道这个咒语是什么意思吗? 如何检查单词是否拼写错误,拼写是否符合形态学规则? 我认为我的执行情况并不理想

for token in  nlp('I can haz cheezeburger.'):
    is_correct = any([token.text == str.lower(suggest) for suggest in token._.hunspell_suggest])
    is_correct = "correct" if is_correct else "misspeled"
    print(f"{token.text} is {is_correct}")
上面列出的代码返回:

None
I ['I', 'Ia', 'In', 'Ir', 'It', 'Io', 'IE', 'IA', 'AI', 'IN', 'RI', 'IT', 'IL', 'ID', 'DI']
None
can ['Can', 'van', 'cab', 'cam', 'ca', 'an', 'cane', 'cans', 'scan', 'cant', 'clan', 'cyan', 'Scan', 'car', 'ran']
None
haz ['ha', 'haze', 'hazy', 'has', 'hat', 'had', 'hag', 'ham', 'hap', 'hay', 'haw', 'ha z']
None
cheezeburger ['cheeseburger', 'vegeburger']
None
. []
I is misspeled
can is correct
haz is misspeled
cheezeburger is misspeled
. is misspeled

这是一个免费的拼写检查和形态分析器库和命令行工具