我需要检查一个列表中的单词是否存在于pdf文件中,但是我有一些错误TypeError: argument of type 'spacy.tokens.token.Token' is not iterable
的问题,我不明白我该如何修复它。
word_list = ['Education', 'Skills']
for word in word_list:
lst = []
for sentence in words:
if word in sentence:
lst.append(word)
print('{0} key word(s) in sentence: {1}'.format(len(lst), ', '.join(lst)))
print(sentence + "n")
我想你的意思是:
word_list = ['Education', 'Skills']
lst = []
for word in word_list:
if word in sentence:
lst.append(word)
if len(last) > 0:
print('{0} key word(s) in sentence: {1}'.format(len(lst), ', '.join(lst)))
print(sentence + "n")
,其中sentence
是字符串。我想你可能在使用words
时打错了,它之前被定义为空格标记,导致了这个令人困惑的错误消息。