9. 一つの単語の素性
!10
- レンマ化 (lemmatizing)
‣ レンマ (lemma): 辞書見出し語
‣ booking, booked, books -> book
- ステミング (stemming)
‣ レンマ化よりも粗い処理
‣ picture, pictures, pictured -> pictur
原文 A stemmer maps sequences of words to shorter sequences
WordNet Lemmatizer A stemmer map sequence of word to shorter sequence
Porter A stemmer map sequenc of word to shorter sequenc
Lancaster a stem map sequ of word to short sequ
* Stemming and Lemmatization with Python NLTK
15. テキストの素性
!16
- 単語バッグ (Bag of Words: BOW)
‣ テキスト中の単語の出現数のヒストグラム
- TF-IDF の重み付け [Manning et al., 2008]
• Term Frequency-Inverse Document Frequency
‣ 特定の文書で多数回出現している単語を重要視
• a / for などは多数回現れるが特徴的ではない https://www.pytry3g.com/entry/2018/03/21/181514
#d(w)
P
w02d #d(w0)<latexit sha1_base64="eq9A2AGwHGKX4XAIKzdU/Yx30FY=">AAACl3ichVHLLgRBFD3aa4zXYENsJiaEzaQaCbEhJGJpMEg0ne6eGir6le6emdCZH/ADJFYkIuIfbCz4AQufIJYkNhbu9HQiCG6nq06de8+tU1W6awo/YOyxQWpsam5pTbQl2zs6u7pTPb3rvlPyDJ43HNPxNnXN56aweT4Qgck3XY9rlm7yDX1/oZbfKHPPF469Fhy4fNvSdm1RFIYWEKWmxpWipxmhklELo5Wxaqj4JUsNKzuK6wmLK8JOF6r1ZEyNVdVUhmVZFOmfQI5BBnEsO6lLKCjAgYESLHDYCAib0ODTtwUZDC5x2wiJ8wiJKM9RRZK0JariVKERu0/jLq22Ytamda2nH6kN2sWk3yNlGsPsgV2xF3bPrtkTe/+1Vxj1qHk5oFmva7mrdh/1r779q7JoDrD3qfrTc4AipiOvgry7EVM7hVHXlw+PX1ZnVobDEXbOnsn/GXtkt3QCu/xqXOT4yimS9ADy9+v+CdbHs/JEVs5NZubm46dIYBBDGKX7nsIclrCMPO17ghvc4V4akGalRWmpXio1xJo+fAkp9wEvRp1/</latexit>
|{d 2 D : w 2 d}|
|D|<latexit sha1_base64="mbL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xf266+14qxG2sseeSvXisAYP3i+9vO/Kpe8wvYf1T97VmjhTdarpN6DjElvYef67v7h9dr86nT8gh2zH9T/R3bOvtINvO6NfbIiVo9Qog/Q7z73fbA+V9Nf1vSVV9WFxeIrRjCJKczQe7/GAt5hGXU69wsucIkrbVHb1nxtN0/VBgrNBG6Ztv8bMP+vZA==</latexit>
単語頻度 (TF)
文書頻度 (DF)
TF-IDF
文書 d 中の全単語出現数で正規化した単語 w の出現数
単語 w が出現する文書 d の数のコーパスサイズ ¦D¦ に対する割合
19. 6.2.2 推測される言語学的特徴
!20
- 統語 (syntax)
‣ 自然言語における文の構造を支配する規則
the boy with the black shirt opened the door with a key
NP PP NP VP NP PP NP
S
NP
DT NN NPPP PPVBD
VP
NP PP NP VP NP PP NP
S
NP VP
NP PP NP VP NP PP NP
S
NP
DT
the boy openedIN INNNNP NPDT
DTwith withthe
the black shirt a key
doorJJ NN NNDT
NN NPPP PPVBD
VP
the boy with the black shirt opened the door with a key
det prep
prep
amod
det
pobj
nsubj
root
dobj pobj
det det
品詞 (Part of Speech; POS)
統語的チャンク
(syntactic chunk)
構成要素木
(constituency tree)
句構造木
(phrase-structure tree)
依存構造木
(dependency tree)
20. 6.2.2 推測される言語学的特徴
!21
the boy with the black shirt opened the door with a key
det prep
prep
amod
det
pobj
nsubj
root
dobj pobj
det det
依存構造木
(dependency tree)
the boy with the black shirt opened the door with a smile
the boy with the black shirt opened the door with a key
Agent
Instrument
Patient
Manner
Patient
Agent
意味役割ラベル付け
(semantic role labeling)
21. 6.2.2 推測される言語学的特徴
!22
- 品詞 (Part of Speech tag; POS)
‣ 名詞、動詞、形容詞、限定詞
- 統語的役割 (syntactic role)
‣ 動詞の主語、目的語、主動詞、副詞的修飾語
- 意味役割 (semantic role)
‣ the key (道具) open the door / the boy (動作主) opens the door
- 統語的依存構造木 (syntactic dependency tree)
‣ 多くの単語で隔てられる二つの単語が統語構造においては隣接してることも
- 談話関係 (discourse relations)
‣ 文と文との関係。詳細化 (moreover)、反論 (however)、因果 (because) など(接続詞ない場合も)
- 照応 (anaphora)
‣ the boy opened the door with a key. It1 wasn t locked and he1 entered the room. He2 saw a man. He3 was smiling.
24. 6.2.4 n-グラム素性
!25
- n-グラム (n-gram)
‣ New York / not good / Paris Hilton のような構造を獲得できる
• of the / on a / the boy などのバイグラムは一般的
- モデルの調整で小さい重みを割り当てる
‣ MLP は X Y という組み合わせは学習できるが XY (bigram) は認識できない
• 畳み込みネットワークは n-gram feature を見つけ出すように設計されている
• bidirectional RNN は可変長 n-gramや、間にギャップを含む n-gram を感知
25. 6.2.5 分布論的素性
!26
- 言語の分布仮説 (distributional hypothesis) [Firth 1957, Harris 1954]
‣ Firth: You shall know a word by the company it keeps!
• 単語の意味はそれが用いられる文脈から推論できる (by Wittgenstein?)
Firth, J.R. (1957). A synopsis of linguistic theory 1930-1955
・pizza
chair・ ・burger
・pizza
chair・
・burger
原文めちゃくちゃ下品な例で笑う
27. まとめ
!28
- テキストデータの素性として使われているものを列挙
‣ 分類対象は単語、テキスト、テキスト対、文章中の単語、単語の関係
‣ 6.2.1 直接観察できる素性
• レンマ、ステミング、語彙資源、TF-IDF、Window
‣ 6.2.2 推測される言語的特徴
• 文法
‣ 6.2.3 核となる素性と組み合わせ素性
• NNを用いて組み合わせ素性を獲得
‣ 6.2.4 n-グラム素性
• New York など複数の単語から構成される言葉を捉える
‣ 6.2.6 分布論的素性
• You shall know a word by the company it keeps!