詞性標註

Python 中文本特徵工程

Rounak Banik

Data Scientist

應用

  • 詞義消歧
    • "The bear is a majestic animal"
    • "Please bear with me"
  • 情緒分析
  • 問答系統
  • 假新聞與意見垃圾偵測
Python 中文本特徵工程

詞性標註(POS)

  • 為每個單字指定對應的詞性。
    "Jane is an amazing guitarist."
    
  • 詞性標註(POS Tagging):
    • Jane專有名詞
    • is動詞
    • an限定詞
    • amazing形容詞
    • guitarist名詞
Python 中文本特徵工程

使用 spaCy 進行詞性標註

import spacy

# Load the en_core_web_sm model
nlp = spacy.load('en_core_web_sm')
# Initiliaze string
string = "Jane is an amazing guitarist"
# Create a Doc object
doc = nlp(string)
Python 中文本特徵工程

使用 spaCy 進行詞性標註

...
...
# Generate list of tokens and pos tags
pos = [(token.text, token.pos_) for token in doc]
print(pos)
[('Jane', 'PROPN'), 
 ('is', 'VERB'), 
 ('an', 'DET'), 
 ('amazing', 'ADJ'), 
 ('guitarist', 'NOUN')]
Python 中文本特徵工程

spaCy 的詞性標註

spaCy 文件中的詞性標註

Python 中文本特徵工程

一起來練習吧!

Python 中文本特徵工程

Preparing Video For Download...