品詞タグ付け

Pythonで学ぶNLPの特徴量エンジニアリング

Rounak Banik

Data Scientist

応用例

  • 語義曖昧性解消
    • "The bear is a majestic animal"
    • "Please bear with me"
  • 感情分析
  • 質問応答
  • フェイクニュース・意見スパム検出
Pythonで学ぶNLPの特徴量エンジニアリング

品詞タグ付け

  • 各単語に対応する品詞を割り当てる。
    "Jane is an amazing guitarist."
    
  • 品詞タグ付け:
    • Jane固有名詞
    • is動詞
    • an限定詞
    • amazing形容詞
    • guitarist名詞
Pythonで学ぶNLPの特徴量エンジニアリング

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で学ぶNLPの特徴量エンジニアリング

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で学ぶNLPの特徴量エンジニアリング

spaCyの品詞アノテーション

品詞アノテーションに関するspaCyドキュメント

Pythonで学ぶNLPの特徴量エンジニアリング

練習しましょう!

Pythonで学ぶNLPの特徴量エンジニアリング

Preparing Video For Download...