How to get the infinitive form of the verb using NLTK (pos tagging)
Asked Answered
R

1

12

I'm trying to learn natural language processing (of English) using NLTK and Python. Is there a way to get the infinitive form of the verb during or after POS-tagging.

For example:

  • is (VBZ) => to be
  • provided (VBN) => to provide
  • using (VBG) => to use
Recurvate answered 18/3, 2012 at 23:51 Comment(1)
ot a full answer, but I would investigate WordNet (yes, NLTK had WordNet as a download)Marrero
N
22

Close, you'll need to add the 'to' at the beginning:

>>> from nltk.stem.wordnet import WordNetLemmatizer
>>> lemmatizer = WordNetLemmatizer()
>>> lemmatizer.lemmatize('is', 'v')
'be'
>>> lemmatizer.lemmatize('provided', 'v')
'provide'
>>> lemmatizer.lemmatize('using', 'v')
'use'
Noni answered 19/3, 2012 at 2:52 Comment(2)
Do you have some suggestion for other langage like French?Trochal
@Trochal use SnowballStemmer("french")Henke

© 2022 - 2024 — McMap. All rights reserved.