From d303a5bde5002d2099958bcac6838b5bc463a623 Mon Sep 17 00:00:00 2001 From: Peter Wu Date: Thu, 2 Apr 2015 17:37:39 +0200 Subject: Improve debugging --- spellchecker/src/SpellCorrector.java | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/spellchecker/src/SpellCorrector.java b/spellchecker/src/SpellCorrector.java index 971e91e..f5f5472 100644 --- a/spellchecker/src/SpellCorrector.java +++ b/spellchecker/src/SpellCorrector.java @@ -252,6 +252,7 @@ public class SpellCorrector { // determine the rating of the current sentence without ignoring // words. best_sentence_probability = evaluateWord(-1); + debugScore(); } /** @@ -351,14 +352,22 @@ public class SpellCorrector { return best_modification != null; } + private void debugScore() { + debugScore(-1, null, 0, 0); + } + private void debugScore(int index, String old_word, double old_score, double old_evaluation) { System.err.println(); - System.err.println("Word: " + old_word + " -> " + words[index]); - System.err.println("Word score : " + old_score - + " -> " + word_likelihoods[index]); - System.err.println("Phrase evaluation: " + old_evaluation - + " -> " + evaluateWord(-1)); + if (index >= 0) { + System.err.println("Word: " + old_word + " -> " + words[index]); + System.err.println("Word score : " + old_score + + " -> " + word_likelihoods[index]); + System.err.println("Phrase evaluation: " + old_evaluation + + " -> " + evaluateWord(-1)); + } else { + System.err.println("Phrase evaluation: " + evaluateWord(-1)); + } for (int i = 0; i < words.length; i++) { System.err.println(String.format("%28s %s", words[i], word_likelihoods[i])); } -- cgit v1.2.1