赞
踩
import spacy
nlp = spacy.load('en') #加载英文模型
doc = nlp(u"it's word tokenize test for spacy")
print(doc)
for d in doc:
print(d)
test_doc = nlp(u"you are best. it is lemmatize test for spacy. I love these books")
for t in test_doc:
print(t , t.lemma_ , t.lemma) #词干化
for t in test_doc:
print(t , t.pos_ , t.pos) #词性标注
test_doc = nlp(u"Rami Eid is studying at Stony Brook University in New York")
for ent in test_doc.ents:
print(ent, ent.label_, ent.label) #命名实体
输出:
it's word tokenize test for spacy it 's word tokenize test for spacy you -PRON- 757862 are be 536 best good 673 . . 453 it -PRON- 757862 is be 536 lemmatize lemmatize 776982 test test 1877 for for 531 spacy spacy 776981 . . 453 I -PRON- 757862 love love 949 these these 742 books book 1300 you PRON 93 are VERB 98 best ADJ 82 . PUNCT 95 it PRON 93 is VERB 98 lemmatize ADJ 82 test NOUN 90 for ADP 83 spacy NOUN 90 . PUNCT 95 I PRON 93 love VERB 98 these DET 88 books NOUN 90 Rami Eid PERSON 377 Stony Brook University ORG 380
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。