如何在给定 POS 标签的 NLTK 中结合动词? [英] How to conjugate a verb in NLTK given POS tag?

查看:19
本文介绍了如何在给定 POS 标签的 NLTK 中结合动词?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

给定一个词性标签,例如 VBD,我如何结合动词以与 NLTK 匹配?

例如

动词:去POS:VBD结果:去了

解决方案

NLTK 目前不提供共轭.Pattern-en 和 nodebox 进行结合.

有时pattern-en 网站中的示例无法正常工作.这对我有用:

<预><代码>>>>from pattern.en 导入共轭>>>动词 = 去">>>共轭(动词,... 时态 = 过去",# 不定式,现在,过去,未来... person = 3, # 1, 2, 3 或 None... number = "singular", # SG, PL...心情=指示性",#指示性,命令性,条件性,主观性... aspect = "imperfective", # IMPERFECTIVE, PERFECTIVE, PROGRESSIVE... 否定 = False) # True 或 False你去了>>>

注意

似乎 共轭 只在时态不需要助动词时输出.例如,在西班牙语中,ir 的(单数第一人称)未来是 iré.在英语中,go 的将来时由助动词will 和不定式go 构成,导致will go.在下面的代码中,iré 是输出,但不是 will go.

<预><代码>>>>from pattern.es 将共轭导入为共轭_es>>>动词 = ir">>>共轭_es(动词,时态=未来")u'irxe1'>>>from pattern.en 将共轭导入为共轭_en>>>动词 = 去">>>共轭_en(动词,时态=未来")>>>

Given a POS tag, such as VBD, how can I conjugate a verb to match with NLTK?

e.g.

VERB: go
POS: VBD
RESULT: went

解决方案

NLTK doesn't currently provide conjugations. Pattern-en and nodebox do conjugations.

Sometimes the examples in the pattern-en website don't work as shown. This worked for me:

>>> from pattern.en import conjugate
>>> verb = "go"
>>> conjugate(verb, 
...     tense = "past",           # INFINITIVE, PRESENT, PAST, FUTURE
...    person = 3,                # 1, 2, 3 or None
...    number = "singular",       # SG, PL
...      mood = "indicative",     # INDICATIVE, IMPERATIVE, CONDITIONAL, SUBJUNCTIVE
...    aspect = "imperfective",   # IMPERFECTIVE, PERFECTIVE, PROGRESSIVE 
...   negated = False)            # True or False
u'went'
>>> 

NOTE

It seems like conjugate only outputs when the tense doesn't require an auxiliary verb. For instance, in Spanish the (singular first person) future of ir is iré. In English, the future of go is formed with the auxiliary will and the infinitive go, resulting in will go. In the code below, iré is output, but not will go.

>>> from pattern.es import conjugate as conjugate_es
>>> verb = "ir"
>>> conjugate_es(verb, tense = "future")
u'irxe1'
>>> from pattern.en import conjugate as conjugate_en
>>> verb = "go"
>>> conjugate_en(verb, tense = "future")
>>> 

这篇关于如何在给定 POS 标签的 NLTK 中结合动词?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆