\(N = 1{,}000{,}000\)。Evert 在這個例子沒有用視窗,而是數雙詞組(bigram):搭配詞 Y 就是緊鄰在目標詞 X 前面的那個詞。每個 X 前面只有 1 個位置,所以位置數就是 count(X)。N = 1,000,000. Evert does not use a window here but counts bigrams: the collocate Y is the word right before the target X. Each X has exactly one such slot, so the number of slots is just count(X).
the Iliad《伊利亞特》
搭配詞 Y = the:count = 100,000 目標詞 X = Iliad:count = 10 \(P(\text{the}) = \frac{100{,}000}{1{,}000{,}000} = 0.1\) \(E = 0.1 \times 10 = \mathbf{1}\) O = 10
must also「必須」「也」
搭配詞 Y = must:count = 1,000 目標詞 X = also:count = 1,000 \(P(\text{must}) = \frac{1{,}000}{1{,}000{,}000} = 0.001\) \(E = 0.001 \times 1000 = \mathbf{1}\) O = 10
兩個詞對的 O 和 E 完全一樣:O = 10,E = 1。Both pairs have exactly the same O and E.
簡單指標的問題(二):分數相同A problem with simple measures, part 2: identical scores
詞對pair
O
E
O / E
MI
the Iliad
10
1
10
3.32
must also
10
1
10
3.32
分數相同,但情況不同:Iliad 只出現 10 次,而且每一次前面都是 the(O = 10 已是最大可能值);must、also 各出現 1,000 次,本來可以共現多得多。Same score, different situations: Iliad occurs only 10 times and every one follows “the” (O = 10 is the maximum possible), while must and also occur 1,000 times each and could have co-occurred far more.
O 與 E 忽略了語料中其他的一切——我們還要看兩詞「沒有」共現的情況。O vs. E ignores everything else in the corpus. We also need to look at when the words do not co-occur.
列聯表Contingency table: two events, X and Y
Y 發生Y occurs
Y 不發生Y does not
X 發生X occurs
a
b
X 不發生X does not
c
d
每個個案恰好落入四格之一every case falls into exactly one cell
a = X 和 Y 都發生的個案數cases where both X and Y occur
b = 只有 X 發生(Y 沒有)X occurs, Y does not
c = 只有 Y 發生(X 沒有)Y occurs, X does not
d = 兩者都沒有發生neither X nor Y occurs
X、Y 可以是任何事件;表格也記錄了「都沒有」的情況。詞語只是其中一例(下一頁)。X and Y can be any events, and the table also records when neither happens. Words are just one example (next slide).
列聯表無處不在Contingency tables are everywhere
兩個「是/否」的性質,各自分成兩類,數一數各格有多少個案Two yes/no properties, cross-tabulated: how many cases fall in each cell?
吸煙 × 肺癌Smoking × lung cancer
吸煙者患肺癌的比例是否更高?Are smokers more likely to have cancer?
示意數字 illustrative
慣用手 × 性別Handedness × sex
左撇子的比例是否因性別而異?Does the share of left-handers differ by sex?
教科書例子 textbook example
好 × 天氣(句子)Two words × sentences
兩個詞是否傾向出現在同一個句子?Do the two words tend to share sentences?
本課的小語料 our toy corpus
結構完全相同:問題都是——兩個性質互相獨立嗎?搭配詞的判斷也是如此。Same structure every time: are the two properties independent? Collocations are no different.
n 選 k(一):放回 vs. 不放回Background “n choose k”, part 1: with vs. without replacement
ABCD
從這 4 個字母中,依序選出 4 個。順序算不同。Pick 4 letters one after another from these 4. The order counts.
放回(同一字母可再選):每次都有 4 種選擇With replacement (a letter may be chosen again): 4 choices every time
41st
×
42nd
×
43rd
×
44th
=
256\(4^4\)
不放回(每個字母只能用一次):每選一個,選擇就少一個Without replacement (each letter only once): one fewer choice after every pick
41st
×
32nd
×
23rd
×
14th
=
24\(4!\)
階乘:\(4! = 4 \times 3 \times 2 \times 1 = 24\),就是把 4 個字母全部排一遍的方法數。Factorial: \(4! = 4 \times 3 \times 2 \times 1 = 24\) is the number of ways to line up all 4 letters.
n 選 k(二):只選 2 個(不放回)Background “n choose k”, part 2: only pick 2, without replacement
ABCD
現在只選 2 個,不放回;順序仍然算不同(AB ≠ BA)。Now pick only 2, without replacement; the order still counts (AB ≠ BA).
第 1 個有 4 種選擇,第 2 個剩 3 種:4 choices for the 1st pick, 3 left for the 2nd:
41st
×
32nd
=
12AB, AC, AD, BA, …
用階乘寫:4! 除以 (4−2)!,去掉多餘的 ×2×1In factorial notation: divide 4! by (4−2)! to cut off the unneeded “×2×1”
下一頁的奶茶實驗:\(\binom{8}{4} = \dfrac{8!}{4!\,4!} = 70\) 種選法,只有 1 種全對 → \(p = 1/70\)。Tea experiment (next slide): \(\binom{8}{4} = 70\) ways to pick the 4 milk-first cups; only 1 is fully correct, so \(p = 1/70\).
Fisher 與「奶茶實驗」Fisher and the lady tasting tea (1935)
R. A. Fisher 1890–1962
Muriel Bristol 聲稱能分辨奶茶是「先倒牛奶」還是「先倒茶」。Ronald Fisher 設計了實驗來檢驗。A lady claims she can tell whether the milk or the tea was poured first. Fisher designs a test.
M
T
T
M
M
T
M
T
8 杯外觀相同:4 杯先牛奶 (M)、4 杯先茶 (T),隨機排列;她要指出哪 4 杯是先牛奶。8 identical-looking cups, 4 milk-first and 4 tea-first, in random order. She must pick the 4 milk-first cups.
全對時,靠猜的機率只有 1/70,這張表「太不可能」;答對 3 杯則可能只是運氣。這就是 Fisher 精確檢定。Guessing all 4 right has probability 1/70, so the table is very unlikely by chance. 3 of 4 could easily be luck. This is Fisher’s exact test.
一張表的機率怎麼算?How likely is one particular table? (hypergeometric distribution)
\(\textcolor{#7c3aed}{N} = a + b + c + d\):表中所有個案(項目)的總數。\(\textcolor{#7c3aed}{N}\) is the total number of items in the table.
分子 ①:「有 X」這一列有 \(\textcolor{#1f5fd6}{a+b}\) 個項目,其中 \(\textcolor{#e0570f}{a}\) 個有 Y —— 從 \(a+b\) 個中選出 \(a\) 個。Numerator ①: the “has X” row holds \(\textcolor{#1f5fd6}{a+b}\) items; choose the \(\textcolor{#e0570f}{a}\) of them that have Y.
分子 ②:「無 X」那一列有 \(\textcolor{#1f5fd6}{c+d}\) 個項目,其中 \(\textcolor{#e0570f}{c}\) 個有 Y。兩列的選法相乘。Numerator ②: the other row holds \(\textcolor{#1f5fd6}{c+d}\) items, \(\textcolor{#e0570f}{c}\) of which have Y. The two choices are independent, so we multiply.
分母:全部 \(\textcolor{#7c3aed}{N}\) 個項目中,任意挑 \(\textcolor{#e0570f}{a+c}\) 個當作「有 Y」的所有可能。Denominator: all ways to choose which \(\textcolor{#e0570f}{a+c}\) of the \(\textcolor{#7c3aed}{N}\) items have Y, ignoring the rows.
代入 \(a=8,\ b=2,\ c=2,\ d=8\)(\(N=20\)):Plug in the numbers:
這張表有多「不可能」?How unlikely is this table?
20 位學生:10 位女生、10 位男生;其中 10 位有在讀書,而讀書的人裡有 8 位是女生。性別與讀書有關嗎?20 students: 10 women, 10 men; 10 are studying, and 8 of those are women. Is studying related to sex? (illustrative numbers)
若兩者無關,純屬偶然,預期讀書的女生只有 5 位。If they were unrelated, we would expect only 5 studying women.
觀察到的表 observed table
更極端 more extreme
最極端 most extreme
Fisher 精確檢定:把觀察到的表與所有更極端的表的機率相加Fisher’s exact test sums the observed table and all more extreme ones
→ 顯著 significant
回到 the Iliad / must alsoBack to Evert’s example: what does Fisher’s test say?
兩者:O = 10,E = 1,O/E = 10,MI = 3.32 —— 簡單指標分不出來。Both have O = 10, E = 1, O/E = 10, MI = 3.32: the simple measures cannot separate them.
完整的列聯表:每一項是一個雙詞組(共 1,000,000 個);列 = 前一個詞是不是 the / must,欄 = 後一個詞是不是 Iliad / also。Full contingency tables: every item is a bigram (1,000,000 in total); row = is the first word the / must, column = is the second word Iliad / also.
the Iliad (count(the) = 100,000 · count(Iliad) = 10)
must also (count(must) = count(also) = 1,000)
the Iliad 的 c = 0:每個 Iliad 前面都是 the。must also 的 c = 990:also 大多沒有 must 在前。For the Iliad c = 0: every Iliad follows “the”. For must also c = 990: most alsos have no must before them.
兩者都「顯著」,但 the Iliad 的 p 小 1000 倍 → 用 p 值排序,the Iliad 排在前面。Both are significant, but the Iliad’s p is 1000 times smaller. Ranking by p-value puts the Iliad first, which O/E and MI cannot do.
三種定義「相鄰」的方法Three ways to define “near”
Evert:先決定什麼是一個共現項目 (item),再問每個項目是否含 w₁、是否含 w₂Evert: first define what an item is, then ask whether each item contains w₁ and whether it contains w₂
記號(Evert):w₁ = 目標詞 X,w₂ = 搭配詞 Y;f₁ = count(w₁),f₂ = count(w₂),N = 項目總數。O、E 的定義不變。Notation from here on (Evert): w₁ = target X, w₂ = collocate Y; f₁ = count(w₁), f₂ = count(w₂), N = total number of items.
視窗法Window (surface)
Y 在 X 左右 k 個詞之內Y is within k words of X
天氣那麼好我們
計數單位:詞unit: tokens
句子法Sentence (textual)
X 與 Y 在同一個句子裡X and Y are in the same sentence
好天氣…散步
計數單位:句子unit: sentences
語法關係法Grammatical (syntactic)
X 與 Y 有語法關係(如:形容詞→名詞)X and Y stand in a syntactic relation
好→天氣
計數單位:語法搭配對unit: grammatical pairs
視窗法Window approach: Y within k words of X
視窗horizon = 2↑↓
X = 好Y = 天氣橙色 O₁₁ = O視窗 window(不跨句 stays within a sentence)
項目:語料中每個詞(不含 w₁ 本身)item: every word token except w₁ itself
第 1 列:落在 w₁ 的視窗內row 1: falls inside a span around w₁
第 1 欄:就是搭配詞 w₂column 1: is the collocate w₂
Fisher 精確檢定 p 值Fisher's exact test p-value
Evert 的原例:視窗法 (hat, roll)Evert’s own example: surface cooccurrence, Fig. 58.1 and 58.8
視窗 (L4, R4):node 詞 hat 左右各 4 個詞,不跨句。Span (L4, R4) around the node word hat, limited by sentence boundaries.
第 2、3 個視窗各含一個 rolled → O = 2The 2nd and 3rd span each contain roll → O = 2