python-3.x - 从一个单词中获取所有可能的 pos 标签

标签 python-3.x nlp nltk

我目前正在尝试使用 Python 获取单个单词的所有可能的 pos 标签。
如果您输入单个单词,则从传统的 pos 标记器中您只会得到一个标签。
有没有办法获得所有的可能性?
是否可以在语料库(例如 brown)中搜索特定单词而不仅仅是类别?

亲切的问候和感谢您的帮助

最佳答案

您可以获得 pos_tag()使用这种方法 - 专门针对 brown ,

import nltk
from nltk.corpus import brown
from collections import Counter, defaultdict

# x is a dict which will have the word as key and pos tags as values 
x = defaultdict(list)

# looping for first 100 words and its pos tags
for word, pos in brown.tagged_words()[1:100]:
    if pos not in x[word]:        # to append one tag only once
        x[word].append(pos)       # adding key-value to x

# to print the pos tags for the word 'further'
print(x['further'])
#['RBR']

关于python-3.x - 从一个单词中获取所有可能的 pos 标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51722351/

相关文章:

python - 如何在 gensim 的 LDA 模型中获取主题编号

nlp - 斯坦福依存解析中的acl标签是什么?

Python 文本处理 : NLTK and pandas

python - 现在删除的模块 'nltk.model.NGramModel' 是否有替代品?

python - 添加来自列表+数字的输入

python-3.x - k 均值聚类中如何使用 tfidf 值

python-3.x - 从 API 中提取数据时的等待屏幕

nltk - 是否可以加速 Wordnet Lemmatizer?

python - for line in open(..) 在文件中间意外挂起

python - 每个程序只发出一次警告