擅长:python、mysql、java
<p>看起来您的问题是<code>truecase.get_true_case(texts)</code>希望接收一个类似字符串/字节的参数,而您正在向它传递一个字符串列表</p>
<p>您需要遍历<code>texts</code>并分别预处理列表中的每个项目:</p>
<pre><code>def preprocess (text):
case = truecase.get_true_case(text)
doc = nlp(case)
return doc
def summarize_texts(texts):
actions = {}
entities = {}
for text in texts:
doc = preprocess(text)
for token in doc:
if token.pos_ == "VERB":
actions[token.lemma_] = actions.get(token.text, 0) +1
for token in doc.ents:
entities[token.label_] = [token.text]
return {
'actions': actions,
'entities': entities
})
</code></pre>