我遇到了一种情况,我必须从spacy doc对象获取pos&tag。在
例如
text = "Australian striker John hits century"
doc = nlp(text)
for nc in doc.noun_chunks:
print(nc) #Australian striker John
doc[1].tag_ # gives for striker
如果我想得到pos_
&;tag_
这个词,我需要再给nlp()
这个句子吗??在
还有doc[1],tag_u在那里,但我需要像doc['Stroker']这样的东西。。在
有没有可能?在
您只需处理文本一次:
如果您只想在名词chunck中获得一个特定的单词,可以通过将第二个print语句改为例如
^{pr2}$请注意,这可能会打印多个点击,具体取决于您的模型和输入语句。在
您可以执行以下操作:
输出:
striker NN
如果需要x1作为变量,也可以很容易地使其成为动态的。在
相关问题 更多 >
编程相关推荐