如何在给定POS标签的NLTK中结合动词?

时间:2013-09-22 09:05:29

标签: python nlp nltk

鉴于POS标签,例如VBD,如何将动词与NLTK匹配?

e.g。

VERB: go
POS: VBD
RESULT: went

2 个答案:

答案 0 :(得分:14)

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 的(单数第一人称)未来是iré。在英语中, go 的未来由辅助和不定式 go 组成,导致 。在下面的代码中,输出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")
>>> 

答案 1 :(得分:1)

我使用MontyLingua进行单词拐点和结合。 https://pypi.python.org/pypi/MontyLingua/2.1

    mlg = MontyLingua.MontyNLGenerator.MontyNLGenerator()
    mlg.conjugate_verb(verb,mode)

更多信息:https://en.wikipedia.org/wiki/MontyLingua