使用 Spacy 模型查找 fr、es、ru 语言的情态动词
Use Spacy Models to find Modal Verb for languages fr, es, ru
我正在使用 Spacy 模型从以下语言中查找情态动词 (MD)。
en
de
fr
es
ru
从 tag_map.py
到 en and de it is clear that "VerbType": "mod"
is a modal verb. But tag_map.py
for fr, es and ru 没有这样的 属性。我如何找出这三种语言中的情态动词(我应该关注哪些属性)?还有什么通用的方法可以让我找出 Spacy 将来发布的任何语言的模态动词,比如说希腊语发布?
注意:我不是在寻找高级标签,而是在寻找低级标签。在 Spacy 术语中,我更喜欢 token.tag_
属性.
我认为目前没有独立于语言的方式来做到这一点。但是情态词是封闭式词,所以只需检查 token.tag_ == 'AUX'
(尽管在德语中,情态动词被标记为 VERB
)以及 token.lemma_
是否在一组情态动词中应该做这份工作。
目前我正在做一个类似的项目。
对于英语,您可以使用 token.dep_ == 'AUX' and token.tag_ = 'MD'
。
例如:
for token in doc:
if token.dep_ == 'aux' and token.tag_ == 'MD':
print(token.text)
对于德语,我得到的最接近的是这样的:
sent = 'Ich muss auf den Lehrer hören'
nlp = spacy.load("de_core_news_sm")
doc = nlp(sent)
print(doc.text)
for token in doc:
print(token.text, token.pos_, token.dep_, token.morph)
Ich muss auf den Lehrer hören
Ich PRON sb Case=Nom|Number=Sing|Person=1|PronType=Prs
muss VERB ROOT Mood=Ind|Number=Sing|Person=1|Tense=Pres|VerbForm=Fin
auf ADP mo
den DET nk Case=Acc|Definite=Def|Gender=Masc|Number=Sing|PronType=Art
Lehrer NOUN nk Case=Acc|Gender=Masc|Number=Sing
hören VERB oc VerbForm=Inf
for token in doc:
if token.morph.get('VerbForm') == ['Fin']:
print(token.text)
muss
您还可以为德语情态词创建非索引字表并添加查询以查找 token.lemma_
modals = ['mussen']
for token in doc:
if token.lemma_ in modals:
print(token.text)
muss
我不确定其他语言但是停止列表方法可能有效。
我正在使用 Spacy 模型从以下语言中查找情态动词 (MD)。
en
de
fr
es
ru
从 tag_map.py
到 en and de it is clear that "VerbType": "mod"
is a modal verb. But tag_map.py
for fr, es and ru 没有这样的 属性。我如何找出这三种语言中的情态动词(我应该关注哪些属性)?还有什么通用的方法可以让我找出 Spacy 将来发布的任何语言的模态动词,比如说希腊语发布?
注意:我不是在寻找高级标签,而是在寻找低级标签。在 Spacy 术语中,我更喜欢 token.tag_
属性.
我认为目前没有独立于语言的方式来做到这一点。但是情态词是封闭式词,所以只需检查 token.tag_ == 'AUX'
(尽管在德语中,情态动词被标记为 VERB
)以及 token.lemma_
是否在一组情态动词中应该做这份工作。
目前我正在做一个类似的项目。
对于英语,您可以使用 token.dep_ == 'AUX' and token.tag_ = 'MD'
。
例如:
for token in doc:
if token.dep_ == 'aux' and token.tag_ == 'MD':
print(token.text)
对于德语,我得到的最接近的是这样的:
sent = 'Ich muss auf den Lehrer hören'
nlp = spacy.load("de_core_news_sm")
doc = nlp(sent)
print(doc.text)
for token in doc:
print(token.text, token.pos_, token.dep_, token.morph)
Ich muss auf den Lehrer hören
Ich PRON sb Case=Nom|Number=Sing|Person=1|PronType=Prs
muss VERB ROOT Mood=Ind|Number=Sing|Person=1|Tense=Pres|VerbForm=Fin
auf ADP mo
den DET nk Case=Acc|Definite=Def|Gender=Masc|Number=Sing|PronType=Art
Lehrer NOUN nk Case=Acc|Gender=Masc|Number=Sing
hören VERB oc VerbForm=Inf
for token in doc:
if token.morph.get('VerbForm') == ['Fin']:
print(token.text)
muss
您还可以为德语情态词创建非索引字表并添加查询以查找 token.lemma_
modals = ['mussen']
for token in doc:
if token.lemma_ in modals:
print(token.text)
muss
我不确定其他语言但是停止列表方法可能有效。