首页 > 解决方案 > 我已将 nltk 标签转换为 wordnet 标签。当我尝试对数据集应用词形还原时,我收到了这个错误。我该怎么办?

问题描述

----> 1 df8 = df7.apply (lambda x: [lemmamy.lemmatize(word, nltk_tag) for word, nltk_tag in x])

/opt/anaconda3/lib/python3.8/site-packages/pandas/core/series.py in apply(self, func, convert_dtype, args, **kwds) 4136 else: 4137 values = self.astype(object)。 _values -> 4138 mapped = lib.map_infer(values, f, convert=convert_dtype) 4139 4140 if len(mapped) and isinstance(mapped[0], Series):

pandas/_libs/lib.pyx 在 pandas._libs.lib.map_infer()

在 (x) ----> 1 df8 = df7.apply(lambda x: [lemmamy.lemmatize(word, nltk_tag) for word, nltk_tag in x])

in (.0) ----> 1 df8 = df7.apply(lambda x: [lemmamy.lemmatize(word, nltk_tag) for word, nltk_tag in x])

/opt/anaconda3/lib/python3.8/site-packages/nltk/stem/wordnet.py in lemmatize(self, word, pos) 36 37 def lemmatize(self, word, pos=NOUN): ---> 38 lemmas = wordnet._morphy(word, pos) 39 return min(lemmas, key=len) if lemmas else word 40

/opt/anaconda3/lib/python3.8/site-packages/nltk/corpus/reader/wordnet.py in _morphy(self, form, pos, check_exceptions) 1904 # 找到匹配项,否则你不能再继续 1905 - > 1906 例外 = self._exception_map[pos] 1907 替换 = self.MORPHOLOGICAL_SUBSTITUTIONS[pos] 1908

关键错误:无

标签: python-3.xdataframewordnetlemmatization

解决方案


推荐阅读