diff options
-rw-r--r-- | spellchecker/src/SpellCorrector.java | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/spellchecker/src/SpellCorrector.java b/spellchecker/src/SpellCorrector.java index 475e889..e4086aa 100644 --- a/spellchecker/src/SpellCorrector.java +++ b/spellchecker/src/SpellCorrector.java @@ -86,11 +86,10 @@ public class SpellCorrector { // add-one smoothing p_channel = (correctionCount + 1) / (errorCount + 1); - // TODO: take the max instead of addition? - // Sum the probabilities as independent modifications can result in - // the same word ("acess" -> "access" by "a|ac", "e|ce"). + // while we could sum here, it does not make sense for the + // probability. Use the probability of the most likely change type. double p = candidates.getOrDefault(word2, 0.0); - p += p_channel; + p = Math.max(p, p_channel); candidates.put(word2, p); }; |