a guest Mar 19th, 2019 61 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
- 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])
RAW Paste Data