Last active
March 15, 2019 00:33
-
-
Save luismond/f66f20c0a3e0bf679667f11fe965036b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import stanfordnlp | |
| MODELS_DIR = 'C:\\Users\\user\\stanfordnlp_resources\\' | |
| nlp = stanfordnlp.Pipeline(processors='tokenize,pos,lemma', models_dir=MODELS_DIR, lang='es') | |
| def get_lemmas(line): | |
| line = nlp(line) | |
| tagged = [[w.lemma for w in sent.words if w.pos == 'ADV' or w.pos == 'ADJ' or w.pos == 'VERB'] | |
| for sent in line.sentences] | |
| return ' '.join([w for sent in tagged for w in sent]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment