Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to conjugate a verb in NLTK given POS tag?

Tags:

python

nlp

nltk

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
like image 593
mix Avatar asked Sep 22 '13 09:09

mix


1 Answers

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")
>>> 
like image 89
arturomp Avatar answered Sep 27 '22 22:09

arturomp