import spacy
nlp = spacy.load('en')from spacy import displacy
from collections import Counter, defaultdict
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
1 文本处理
doc = nlp('Weather is good, very windy and sunny. We have no classes in the afternoon.')# 分词for token in doc:print(token)# 分句for sent in doc.sents:print(sent)
2 词性
for token in doc:print('{}-{}'.format(token, token.pos_))
3 命名体识别
doc_2 = nlp("I went to Paris where I met my old friend Jack from uni.")for ent in doc_2.ents:print('{}-{}'.format(ent, ent.label_)