无法弄清楚我在做什么错

问题描述 投票:-1回答:1

我正在尝试检查单词是否为英语单词。不知道这是否是最好的方法,有什么建议吗?它不想工作。

from nltk import wordnet
word_to_test = input("Please enter a word: ")
if not wordnet.synsets(word_to_test):
print("FALSE")
    #not english word
else:
    print("TRUE")
python shared-libraries
1个回答
0
投票

使用以下代码:

Synset

输出:

from nltk.corpus.reader import wordnet

word_to_test = input("Please enter a word: ")
if not wordnet.Synset(word_to_test):
    print("FALSE")
    #not english word
else:
    print("TRUE")
© www.soinside.com 2019 - 2024. All rights reserved.