summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Wu <peter@lekensteyn.nl>2015-04-02 10:53:04 +0200
committerPeter Wu <peter@lekensteyn.nl>2015-04-02 10:53:04 +0200
commitc2965ed04707ac744058957f7cbd34a9da19a392 (patch)
treef21153d781386fe5da25bc92620fed74454f2825
parentd5979ace2a56e6333d4c0e304c5e4f13373ed6ad (diff)
downloadassignment4-c2965ed04707ac744058957f7cbd34a9da19a392.tar.gz
Score debugging
-rw-r--r--spellchecker/src/SpellCorrector.java13
1 files changed, 13 insertions, 0 deletions
diff --git a/spellchecker/src/SpellCorrector.java b/spellchecker/src/SpellCorrector.java
index ef67622..4ba1c7e 100644
--- a/spellchecker/src/SpellCorrector.java
+++ b/spellchecker/src/SpellCorrector.java
@@ -19,6 +19,8 @@ public class SpellCorrector {
*/
private final static double LM_PROBABILITY_UNMODIFIED = .95;
+ private final boolean DEBUG_SCORE = System.getenv("DEBUG_SCORE") != null;
+
public SpellCorrector(CorpusReader cr, ConfusionMatrixReader cmr) {
this.cr = cr;
this.cmr = cmr;
@@ -313,6 +315,17 @@ public class SpellCorrector {
String word = best_modification.word;
double score = best_modification.score;
+ if (DEBUG_SCORE) {
+ System.err.println();
+ System.err.println("Word: " + words[index] + " -> " + word);
+ System.err.println("Word score: " + word_likelihoods[index] + " -> " + score);
+ System.err.println("Phrase score: " + evaluateWord(-1));
+ for (int i = 0; i < words.length; i++) {
+ System.err.println(String.format("%28s %s", words[i], word_likelihoods[i]));
+ }
+ System.err.println();
+ }
+
// save the word and its associated score
assert word_likelihoods[index] < score :
"The score should only get better for word " + word