From c2965ed04707ac744058957f7cbd34a9da19a392 Mon Sep 17 00:00:00 2001 From: Peter Wu Date: Thu, 2 Apr 2015 10:53:04 +0200 Subject: Score debugging --- spellchecker/src/SpellCorrector.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) 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 -- cgit v1.2.1