给定POS标签(例如VBD),如何使动词与NLTK匹配?

例如

VERB: go
POS: VBD
RESULT: went

最佳答案

NLTK当前不提供共轭。 Pattern-ennodebox进行共轭。

有时,pattern-en网站中的示例无法按所示方式工作。这为我工作:

>>> 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(唯一的第一人称视角)的 future 是iré。用英语来说,围棋的 future 是由辅助围棋和不定式围棋组成的,从而形成围棋。在下面的代码中,输出iré,但不会输出。
>>> 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")
>>>

关于python - 如何在给定POS标签的情况下将动词与NLTK结合?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/18942096/

10-12 16:55