Natural Language Processing · M2 · mocks
Q5 (3 marks)
M2 Mock C · mixed numerical practice
M2 · confirmed 2 + 2 + any two of 3 + 3 + 3 · worked practice
Q5
In a WSD training set, financial bank and river bank each have two labelled contexts. Token totals are N(F)=6 and N(R)=6. Vocabulary size is 8. Counts are C(loan,F)=2, C(loan,R)=0, C(water,F)=0, C(water,R)=3. Use add-one Naive Bayes to classify context {loan,water}. (3 marks)
Given
P(F)=P(R)=2/4=0.5; |V|=8; both class token totals=6.
To findSmoothed scores and winning sense.
Formula and why it applies
P(w\mid c)=\frac{C(w,c)+1}{N_c+|V|}s(c)=P(c)\prod_wP(w\mid c)Class priors use labelled-context counts; word likelihood denominators use class token totals. Do not exchange those two totals.
Solution
Step 1. Find the denominator
6+8=14Step 2. Financial likelihoods
P(loan\mid F)=\frac3{14},\quad P(water\mid F)=\frac1{14}Step 3. River likelihoods
P(loan\mid R)=\frac1{14},\quad P(water\mid R)=\frac4{14}Step 4. Compute financial score
s(F)=\frac12\times\frac3{14}\times\frac1{14}=\frac3{392}\approx0.007653061Step 5. Compute river score
s(R)=\frac12\times\frac1{14}\times\frac4{14}=\frac4{392}\approx0.010204082Step 6. Choose
4/392 > 3/392; the water evidence outweighs the loan evidence under these counts.
River sense wins. If normalised, P(R|context)=4/7≈0.571429.