python - 使用 NLTK 的数据集行的 POS 标签

标签 python nltk pos-tagger

我正在尝试创建一个新列,其中包含数据框中的 clean_word 列的 pos 标记。此列包含单个单词,如下图所示。因此不需要标记化等。

enter image description here

下面是我的代码。

import nltk

datahitword['pos_tag'] = nltk.pos_tag(datahitword['clean_word'])
datahitword.head()

即使将列转换为列表和系列以单独处理它然后添加到数据框后,我仍收到以下错误。

TypeError: argument of type 'float' is not iterable

我在这里缺少什么吗?

最佳答案

正如@alvas 推荐的那样。只需要将单词转换为字符串即可

datahitword['clean_word'] = datahitword['clean_word'].astype(str)

关于python - 使用 NLTK 的数据集行的 POS 标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46636047/

相关文章:

python - 查找并替换为以小写字母开头的正确句子案例句子。正则表达式或崇高

java - 使用斯坦福大学的词性标记器标记大文件

python - 如何在 Python 中向左或向右移动列表中的所有元素?

python - 字符串的递归 - 回到字符串的开头?

python-3.x - 导入 NLTK 后辅助命令不起作用

python - nltk.TweetTokenizer 中的 Tokenize() 通过拆分返回整数

python - NLTK 无法找到 stanford-postagger.jar!设置 CLASSPATH 环境变量

nlp - 我如何在斯坦福 Pos tagger 中创建自己的模型?

Python截断一个长字符串

python - 如何消除 NumPy 特征向量分量的复杂角度的不连续性?