我一直在寻找相同的功能,并努力寻找可在 64 位 Windows 中运行的现有库。 PyEnchant 虽然是一个很棒的库,但目前尚未激活并且无法在 64 位下运行。我发现的其他库在 Windows 中不起作用。
我终于找到了一个解决方案,我希望其他人会发现它有价值。
解决方案...
使用 nltk
从 nltk.corpus.brown 中提取单词列表
将单词列表转换为集合(以便高效搜索)
使用 in 关键字确定您的字符串是否在集合中
from nltk.corpus import brown
word_list = brown.words()
word_set = set(word_list)
# Check if word is in set
"looked" in word_set # Returns True
"hurrr" in word_set # Returns False
I was looking for the same functionality and struggled to find an existing library that works in Windows, 64 bit. PyEnchant, although a great library, isn't currently active and doesn't work in 64 bit. Other libraries I found didn't work in Windows.
I finally found a solution that I hope others will find valuable.
The solution...
Use nltk
Extract the word list from nltk.corpus.brown
Convert the word list to a set (for efficient searching)
Use the in keyword to determine if your string is in the set
from nltk.corpus import brown
word_list = brown.words()
word_set = set(word_list)
# Check if word is in set
"looked" in word_set # Returns True
"hurrr" in word_set # Returns False
Use a timer check and you'll see this takes virtually no time to search the set. A test on 1,000 words took 0.004 seconds.
发布评论
评论(4)
有两种可能的方法:
有效的话。将文件加载到
设置并比较每个单词看看
它是否存在于其中(集合中的单词)
PyEnchant 现在没有积极维护。
Two possible ways of doing it:
valid words. Load the file into a
set and compare each word to see
whether it exists in it (word in set)
PyEnchant is not actively maintained now.
我一直在寻找相同的功能,并努力寻找可在 64 位 Windows 中运行的现有库。 PyEnchant 虽然是一个很棒的库,但目前尚未激活并且无法在 64 位下运行。我发现的其他库在 Windows 中不起作用。
我终于找到了一个解决方案,我希望其他人会发现它有价值。
解决方案...
in
关键字确定您的字符串是否在集合中使用计时器检查,您会发现几乎不需要时间来搜索集合。对 1,000 个单词的测试花费了 0.004 秒。
I was looking for the same functionality and struggled to find an existing library that works in Windows, 64 bit. PyEnchant, although a great library, isn't currently active and doesn't work in 64 bit. Other libraries I found didn't work in Windows.
I finally found a solution that I hope others will find valuable.
The solution...
in
keyword to determine if your string is in the setUse a timer check and you'll see this takes virtually no time to search the set. A test on 1,000 words took 0.004 seconds.
我个人使用: http://textblob.readthedocs.io/en/dev/
这是一个活跃的项目,根据网站介绍:
拼写纠正基于 Peter Norvig 的“如何编写拼写纠正器”[1],并在模式库中实现。准确率约为 70%
I personally used: http://textblob.readthedocs.io/en/dev/
It is an active project and according to the website:
Spelling correction is based on Peter Norvig’s “How to Write a Spelling Corrector”[1] as implemented in the pattern library. It is about 70% accurate
Yahoo 通过 YQL 提供拼写检查 API。
它非常简单,您每天可以获得 5000 个查询/IP 地址用于非商业用途(免费)
Yahoo provides spell checking API through YQL.
Its pretty simple and you get 5000 queries/ip address/day for non-commercial use (FREE)