我目前正在尝试使用 Python 获取单个单词的所有可能的 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']
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)