Advertisement
Guest User

Untitled

a guest
Mar 19th, 2019
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.40 KB | None | 0 0
  1. import stanfordnlp
  2. MODELS_DIR = 'C:\\Users\\user\\stanfordnlp_resources\\'
  3. nlp = stanfordnlp.Pipeline(processors='tokenize,pos,lemma', models_dir=MODELS_DIR, lang='es')
  4.  
  5. def get_lemmas(line):
  6. line = nlp(line)
  7. tagged = [[w.lemma for w in sent.words if w.pos == 'ADV' or w.pos == 'ADJ' or w.pos == 'VERB']
  8. for sent in line.sentences]
  9. return ' '.join([w for sent in tagged for w in sent])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement