我尝试使用Spacy来获取动词的词法属性,如下所示:
import spacy
from spacy.lang.it.examples import sentences
nlp = spacy.load('it_core_news_sm')
doc = nlp('Ti è piaciuto il film?')
token = doc[2]
nlp.vocab.morphology.tag_map[token.tag_]
输出为:
{'pos':'VERB'}
但是我要提取
V__Mood = Cnd | Number = Plur | Person = 1 | Tense = Pres | VerbForm = Fin“:{POS:VERB}
是否可以使用Spacy提取标签映射https://github.com/explosion/spacy/blob/master/spacy/lang/it/tag_map.py中指定的心情,时态,人数,人员信息?
答案 0 :(得分:1)
nlp.vocab.morphology.tag_map
从详细标签映射到具有更简单标签的字典,因此您只需要跳过该步骤并直接检查标签:
import spacy
nlp = spacy.load('it')
doc = nlp('Ti è piaciuto il film?')
print(doc[2].tag_)
应该返回
VA__Mood = Ind | Number = Sing | Person = 3 | Tense = Pres | VerbForm = Fin
(使用spacy 2.0.11,it_core_news_sm-2.0.0)