如何在给定POS标签的情况下将动词与NLTK进行共轭? [英] How to conjugate a verb in NLTK given POS tag?
问题描述
考虑到POS标签(例如VBD),我该如何使动词与NLTK匹配?
Given a POS tag, such as VBD, how can I conjugate a verb to match with NLTK?
例如
VERB: go
POS: VBD
RESULT: went
推荐答案
NLTK当前不提供共轭. 模式和
NLTK doesn't currently provide conjugations. Pattern-en and nodebox do conjugations.
有时,pattern-en网站中的示例不起作用,如图所示.这对我有用:
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'
>>>
注意
似乎conjugate
仅在时态不需要辅助动词时才输出.例如,在西班牙语中, ir 的(单数第一人称)未来是iré.用英语, go 的未来由辅助 will 和不定式 go 组成,导致 will go .在下面的代码中,输出iré,但不会输出 .
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'ir\xe1'
>>> from pattern.en import conjugate as conjugate_en
>>> verb = "go"
>>> conjugate_en(verb, tense = "future")
>>>
这篇关于如何在给定POS标签的情况下将动词与NLTK进行共轭?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!