summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--spellchecker/src/SpellCorrector.java8
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;
}
}