I am trying to find out a faster way to lemmatize words in a list (named text) using the NLTK Word Net Lemmatizer. Apparently this is the most time consuming step in my whole program(used cProfiler to find the same).
Following is the piece of code that I am trying to optimize for speed -
def lemmed(text):
l = len(text)
i = 0
wnl = WordNetLemmatizer()
while (i<l):
text[i] = wnl.lemmatize(text[i])
i = i + 1
return text
Using the lemmatizer decreases my performance by 20x. Any help would be appreciated.