summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Wu <peter@lekensteyn.nl>2015-04-02 02:21:05 +0200
committerPeter Wu <peter@lekensteyn.nl>2015-04-02 02:21:05 +0200
commitcc9d613274b9cb7945cbcad2874c3a106728804e (patch)
treecebb80e3469b71b822ec0f8d09ac6fb7b457d6a7
parent4615358ae4f3aab0e18bb0b290e7c0caaa7441ea (diff)
downloadassignment4-cc9d613274b9cb7945cbcad2874c3a106728804e.tar.gz
Calculate probability for unigram
Find L * P(word) instead of L * #word.
-rw-r--r--spellchecker/src/SpellCorrector.java2
1 files changed, 1 insertions, 1 deletions
diff --git a/spellchecker/src/SpellCorrector.java b/spellchecker/src/SpellCorrector.java
index ab41c3d..3202949 100644
--- a/spellchecker/src/SpellCorrector.java
+++ b/spellchecker/src/SpellCorrector.java
@@ -234,7 +234,7 @@ public class SpellCorrector {
// Now obtain n-gram probabilities. Use interpolation to combine
// unigrams and bigrams.
- p = LAMBDAS[0] * cr.getSmoothedCount(word);
+ p = LAMBDAS[0] * cr.getSmoothedCount(word) / cr.getUnigramCount();
// Add probability of bi-grams.
// For words u and w, P(w|u) = P(u, w) / P(u).