Lynten / stanford-corenlp

Python wrapper for Stanford CoreNLP.
MIT License
922 stars 200 forks source link

Get lemmas #75

Closed rpinquie closed 5 years ago

rpinquie commented 5 years ago

I can't figure out how to get the lemma for each token. Any idea?

rpinquie commented 5 years ago

I wrote a new function in corenlp.py

def lemmatization(self, sentence): r_dict = self._request('lemma', sentence) words = [] lemmas = [] for s in r_dict['sentences']: for token in s['tokens']: words.append(token['originalText']) lemmas.append(token['lemma']) return list(zip(words, lemmas))