Python 中的 NLP 特征工程
Rounak Banik
Data Scientist
"John Doe is a software engineer working at Google. He lives in France."
John Doe → 人名Google → 组织France → 国家(地缘政治实体)import spacy string = "John Doe is a software engineer working at Google. He lives in France." # Load model and create Doc object nlp = spacy.load('en_core_web_sm') doc = nlp(string)# Generate named entities ne = [(ent.text, ent.label_) for ent in doc.ents] print(ne)
[('John Doe', 'PERSON'), ('Google', 'ORG'), ('France', 'GPE')]

Python 中的 NLP 特征工程