summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Wu <peter@lekensteyn.nl>2015-04-03 20:05:17 +0200
committerPeter Wu <peter@lekensteyn.nl>2015-04-03 20:05:17 +0200
commitd4b12e91df83753913cd9c9535dc34431ff0d323 (patch)
tree39abdd9ee9ac0b08e8ee322cc5d0b2edd20d07f0
parent401c3279a87b46230e4a555d7dd86641394bff6b (diff)
downloadassignment4-d4b12e91df83753913cd9c9535dc34431ff0d323.tar.gz
Correctly check read-only words
-rw-r--r--spellchecker/src/SpellCorrector.java12
1 files 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;