mix
mix

Reputation: 7151

How to conjugate a verb in NLTK given POS tag?

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

Upvotes: 14

Views: 8052

Answers (2)

arturomp
arturomp

Reputation: 29580

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'ir\xe1'
>>> from pattern.en import conjugate as conjugate_en
>>> verb = "go"
>>> conjugate_en(verb, tense = "future")
>>> 

Upvotes: 21

Josep Valls
Josep Valls

Reputation: 5560

I used MontyLingua for word inflexion and conjugation. https://pypi.python.org/pypi/MontyLingua/2.1

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

More info: https://en.wikipedia.org/wiki/MontyLingua

Upvotes: 1

Related Questions