From d4b12e91df83753913cd9c9535dc34431ff0d323 Mon Sep 17 00:00:00 2001 From: Peter Wu Date: Fri, 3 Apr 2015 20:05:17 +0200 Subject: Correctly check read-only words --- spellchecker/src/SpellCorrector.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/spellchecker/src/SpellCorrector.java b/spellchecker/src/SpellCorrector.java index edff671..a435f74 100644 --- a/spellchecker/src/SpellCorrector.java +++ b/spellchecker/src/SpellCorrector.java @@ -276,9 +276,9 @@ public class SpellCorrector { public double getWordLikelihood(int index, double channel_probability) { double prior, score, p, igram_p; String word = words[index]; - // a suggested word not in the vocabulary is certainly wrong, - // changed (or consequentive) words should also not be changed. - if (!cr.inVocabulary(word) || words_readonly[index]) { + + // a suggested word not in the vocabulary is certainly wrong + if (!cr.inVocabulary(word)) { return 0.0; } @@ -354,6 +354,12 @@ public class SpellCorrector { double[] scores; int index_left, index_right; + // Words that have previously been changed (or conseqentive words) + // should not be changed again. + if (words_readonly[index]) { + return; + } + // Simulate the change of changing this word. words[index] = word; -- cgit v1.2.1