a guest Mar 19th, 2019 61 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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')
  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])
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand