我目前正在尝试使用 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/