diff options
author | Peter Wu <peter@lekensteyn.nl> | 2015-04-04 11:05:12 +0200 |
---|---|---|
committer | Peter Wu <peter@lekensteyn.nl> | 2015-04-04 11:05:12 +0200 |
commit | a6fbffe08e9217c16ef2afa0d69e8a7c527d5f8d (patch) | |
tree | 5d1a9904c2a226eba8099c575941e0e747623875 | |
parent | 864afee73644051b5d4e1b21760f92f5659010da (diff) | |
download | assignment4-a6fbffe08e9217c16ef2afa0d69e8a7c527d5f8d.tar.gz |
Changes must always be better than the latest modification
-rw-r--r-- | spellchecker/src/SpellCorrector.java | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/spellchecker/src/SpellCorrector.java b/spellchecker/src/SpellCorrector.java index 2e03f26..e3f2955 100644 --- a/spellchecker/src/SpellCorrector.java +++ b/spellchecker/src/SpellCorrector.java @@ -388,9 +388,11 @@ public class SpellCorrector { // group the effects of this modifications for tracking. WordModification effect = new WordModification(index, word, scores); - if ((best_modification != null - && effect.probability > best_modification.probability) - || effect.probability > sentence_probability) { + // if there was a previous best modification, the proposed + // modification must be better than that. Otherwise, it must be + // better than the original sentence. + if ((best_modification != null && effect.probability > best_modification.probability) + || (best_modification == null && effect.probability > sentence_probability)) { best_modification = effect; } } |