固有表現抽出

Python で学ぶ Natural Language Processing 入門

Katharine Jarmul

Founder, kjamistan

固有表現抽出とは?

  • テキスト中の重要な固有表現を識別するNLPタスク
    • 人物、場所、組織
    • 日付、州、芸術作品
    • ...その他のカテゴリも!
  • トピック識別と組み合わせて使用可能
    • ...単独での使用も可能!
  • 誰が?何を?いつ?どこで?
Python で学ぶ Natural Language Processing 入門

NERの例

Wikipediaの記事に対するNERの例

(出典:Europeana Newspapers (http://www.europeana-newspapers.eu))

Python で学ぶ Natural Language Processing 入門

nltkとStanford CoreNLPライブラリ

  • Stanford CoreNLPライブラリ:
    • nltk 経由でPythonに統合
    • Javaベース
    • NER、共参照解析、依存構造木をサポート
Python で学ぶ Natural Language Processing 入門

nltkを使った固有表現抽出

import nltk
sentence = '''In New York, I like to ride the Metro to 
              visit MOMA and some restaurants rated 
              well by Ruth Reichl.'''
tokenized_sent = nltk.word_tokenize(sentence)

tagged_sent = nltk.pos_tag(tokenized_sent)
tagged_sent[:3]
[('In', 'IN'), ('New', 'NNP'), ('York', 'NNP')]
Python で学ぶ Natural Language Processing 入門
print(nltk.ne_chunk(tagged_sent))
(S
  In/IN
  (GPE New/NNP York/NNP) 
  ,/,
  I/PRP
  like/VBP
  to/TO
  ride/VB
  the/DT
  (ORGANIZATION Metro/NNP)
  to/TO
  visit/VB
  (ORGANIZATION MOMA/NNP)
  and/CC
  some/DT
  restaurants/NNS
  rated/VBN
  well/RB
  by/IN
  (PERSON Ruth/NNP Reichl/NNP) 
  ./.)
Python で学ぶ Natural Language Processing 入門

練習しましょう!

Python で学ぶ Natural Language Processing 入門

Preparing Video For Download...