1 使用spacy做简单nlp任务 需要先下载模型,这里下了中文模型,更多可以参考模型列表 python -m spacy download zh_core_web_sm 分析: import spacy nlp = spacy.load('zh_core_web_sm') doc = nlp(u'有一个老师是很幸福的,可以有学习机会,有做比较的机会。如果从这些角度来说我是果粉呢,也不为过。') for token in doc: print(token.text, token.pos_, token.dep_) 这里token上常用的如下,更多参考: text:文本 pos_:part-of-speech,词性标注,列表见这里 tag_:详细的pos dep_:Syntactic dependency relation,语义分析关联 上面的nlp默认是一个pipeline,任务有: nlp.pipeline [('tok2vec', <spacy.pipeline.tok2vec.Tok2Vec at 0x78615a5f2620>), ('tagger', <spacy.pipeline.tagger.Tagger at 0x78615a5f3160>), ('parser', <spacy.pipeline.dep_parser.DependencyParser at 0x786157d4c200>), ('attribute_ruler', <spacy.pipeline.attributeruler.AttributeRuler at 0x78615ac70780>), ('ner', <spacy.pipeline.ner.EntityRecognizer at 0x786157d4ceb0>)] […]