diff options
Diffstat (limited to 'spellchecker/src/SpellCorrector.java')
-rw-r--r-- | spellchecker/src/SpellCorrector.java | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/spellchecker/src/SpellCorrector.java b/spellchecker/src/SpellCorrector.java index 33b804f..2bc788b 100644 --- a/spellchecker/src/SpellCorrector.java +++ b/spellchecker/src/SpellCorrector.java @@ -294,12 +294,16 @@ public class SpellCorrector { } // compute bigrams, etc. - String ngram = word; + String ngram = ""; for (int i = 1; i < NGRAM_N; i++) { // are there actually enough words to compute this metric? if (index - i >= 0) { // increase ngram prefix - ngram += " " + words[index - i]; + if (ngram.isEmpty()) { + ngram = words[index - i]; + } else { + ngram = words[index - i] + " " + ngram; + } // Obtain n-gram probs and combine using interpolation. igram_p = cr.getNgramProbability(word, ngram); |