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
왜 could, since, without, although
과 같은 단어가 거짓입니까? WordNet에 나타나지 않습니까? WN (NLTK 사용)에 단어가 있는지 여부를 알아내는 더 좋은 방법이 있습니까?
내 첫 번째 시도는 to, if, when, then, I, you
과 같은 단어 인 "stopwords"를 제거하는 것이었지만 아직 찾을 수없는 매우 일반적인 단어 (예 : could
)가 있습니다.
The water can is heavy
대I can foo bar.
왜 True를 반환합니까? – alvas그것은 단지이 단어들을 무시하려고했습니다. 그러나 나는 모든 일반적인 단어가 불어 구어가 아니라는 것을 알아 차렸다. – Sadik