lda - “解压的值太多(预期为 2)”错误
问题描述
我曾多次尝试为 LDA 运行 pos_tagger 和词形还原过程,但总是得到相同的错误。这是代码:
#Pos_tagger function
from nltk import pos_tag_sents
def pos_tagger(nltk_tag):
if nltk_tag.startswith('J'):
return wordnet.ADJ
elif nltk_tag.startswith('V'):
return wordnet.VERB
elif nltk_tag.startswith('N'):
return wordnet.NOUN
elif nltk_tag.startswith('R'):
return wordnet.ADV
else:
return None
pos_tagged = pos_tag_sents(tokenized_word)
print(pos_tagged)
#Lemmatization
from nltk import WordNetLemmatizer
from nltk.corpus import wordnet
lem = WordNetLemmatizer()
lemma_sent = []
for word, tag in pos_tagged:
if tag is None:
lemma_sent.append(word)
else:
lemma_sent.append(lem.lemmatize(word, tag))
lemma_sent = " ".join(lemma_sent)
print(lemma_sent)
当我尝试在词形还原步骤中运行 for 循环时,错误才浮出水面。
有谁知道如何修理它?
解决方案
推荐阅读
- java - PDF Box - 添加标题时出错
- javascript - 调用 JavaScript 函数时出现语法错误
- swift - SwiftUI 测量每个视图的创建时间
- azure - 导出调用后查询副本状态 - fhir azure
- acumatica - soapClient.GetList 不返回在 Acumatica I300 课程中创建的 CustomFields
- javascript - 为什么我们将 Vue 实例保存在变量或常量中?
- firefox - 如何检查 Firefox 中动态创建的 bootstrap4 元素?
- java - 当文件不存在时,如何从 recyclerview 隐藏删除按钮?
- javascript - 如何使用 HTML 和 CSS 使用 flex div 构建甘特图
- javascript - 从满足条件的对象数组中更新属性值