前置知识: Python

Python与NLP

1 minIntermediate2026/6/14

自然语言处理

1. spaCy

import spacy

nlp = spacy.load("zh_core_web_sm")
doc = nlp("自然语言处理是人工智能的重要方向")

for ent in doc.ents:
  print(ent.text, ent.label_)

2. Transformers

from transformers import pipeline

classifier = pipeline("sentiment-analysis")
result = classifier("这个产品非常好用")