Sad*_*dik 1 python nltk wordnet
我想写一个简单的函数,看看这个词是否通过NLTK在WordNet中"存在".
def is_known(word):
"""return True if this word "exists" in WordNet
(or at least in nltk.corpus.stopwords)."""
if word.lower() in nltk.corpus.stopwords.words('english'):
return True
synset = wn.synsets(word)
if len(synset) == 0:
return False
else:
return True
Run Code Online (Sandbox Code Playgroud)
为什么会这样的话会could, since, without, although返回False?它们不会出现在WordNet中吗?有没有更好的方法来确定WN中是否存在单词(使用NLTK)?
我的第一个尝试是消除"停止词",这些词是类似的to, if, when, then, I, you,但仍然有很常见的词(比如could),我找不到.
WordNet不包含这些单词或类似单词.有关说明,请参阅WordNet文档中的以下内容:
Q. Why is WordNet missing: of, an, the, and, about, above, because, etc.
A. WordNet only contains "open-class words": nouns, verbs, adjectives, and adverbs. Thus, excluded words include determiners, prepositions, pronouns, conjunctions, and particles.
Run Code Online (Sandbox Code Playgroud)
您也不会在WordNet的在线版本中找到这些单词.
| 归档时间: |
|
| 查看次数: |
1418 次 |
| 最近记录: |