命名實體識別

Python 中文本特徵工程

Rounak Banik

Data Scientist

應用場景

  • 高效搜尋演算法
  • 問答系統
  • 新聞分類
  • 客服應用
Python 中文本特徵工程

命名實體識別

  • 將命名實體辨識並歸類到預先定義的類別。
  • 類別包含人名、組織、國家等。
    "John Doe is a software engineer working at Google. He lives in France."
    
  • 命名實體
  • John Doe → person
  • Google → organization
  • France → country (geopolitical entity)
Python 中文本特徵工程

使用 spaCy 的 NER

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 中文本特徵工程

spaCy 的 NER 標註

spaCy 文件:NER 標註

Python 中文本特徵工程

提醒與限制

  • 並非完美
  • 表現取決於訓練與測試資料
  • 針對細微情境以專門資料訓練模型
  • 與語言相關
Python 中文本特徵工程

一起來練習吧!

Python 中文本特徵工程

Preparing Video For Download...