summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Wu <peter@lekensteyn.nl>2015-04-02 17:37:39 +0200
committerPeter Wu <peter@lekensteyn.nl>2015-04-02 17:37:39 +0200
commitd303a5bde5002d2099958bcac6838b5bc463a623 (patch)
tree591cc40c2ef5d66eadcb3e7af157c6c5cd1c8091
parent5508b2fa5c5b25d97a441aae305cb2f858307d55 (diff)
downloadassignment4-d303a5bde5002d2099958bcac6838b5bc463a623.tar.gz
Improve debugging
-rw-r--r--spellchecker/src/SpellCorrector.java19
1 files 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]));
}