Python Don';在检查单词时,我不理解打字错误的原因
我需要检查pdf文件中是否存在列表中的单词,但我遇到了一些错误Python Don';在检查单词时,我不理解打字错误的原因,python,spacy,Python,Spacy,我需要检查pdf文件中是否存在列表中的单词,但我遇到了一些错误TypeError:type'spacy.tokens.token.token'参数不可编辑的问题,我不知道如何修复它 word_list = ['Education', 'Skills'] for word in word_list: lst = [] for sentence in words: if word in sentence:
TypeError:type'spacy.tokens.token.token'参数不可编辑的问题,我不知道如何修复它
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")
其中,句子
是一个字符串。我认为您可能输入了单词
,之前它被定义为spacy标记,导致了这条令人困惑的错误消息。我们需要查看整个回溯,以便有机会帮助您。请回答您的问题并添加它。在这一行:对于单词中的句子:
您有未定义的单词,您的意思是在“word”中吗?此代码根本不使用spacy库,但您的错误表明使用了spacy标记
类型。问题中不存在导致错误的原因。跟踪错误和代码片段似乎无关。“单词”在哪里定义?单词是我文档中文本的标记化