summaryrefslogtreecommitdiff
path: root/spellchecker/src/ConfusionMatrixReader.java
diff options
context:
space:
mode:
authorPeter Wu <peter@lekensteyn.nl>2015-04-01 02:54:48 +0200
committerPeter Wu <peter@lekensteyn.nl>2015-04-01 02:54:48 +0200
commit82eadc91f0f697103e965bd3600475df60e8282f (patch)
tree62826bc20e70f400d09572f3a2915d33e268dbc3 /spellchecker/src/ConfusionMatrixReader.java
parent61f7bd4f37dc85f49a1732af58f6bd42e556ad21 (diff)
downloadassignment4-82eadc91f0f697103e965bd3600475df60e8282f.tar.gz
Calculate noisy channel probability
Diffstat (limited to 'spellchecker/src/ConfusionMatrixReader.java')
-rw-r--r--spellchecker/src/ConfusionMatrixReader.java11
1 files changed, 11 insertions, 0 deletions
diff --git a/spellchecker/src/ConfusionMatrixReader.java b/spellchecker/src/ConfusionMatrixReader.java
index c9e79ab..90a8cef 100644
--- a/spellchecker/src/ConfusionMatrixReader.java
+++ b/spellchecker/src/ConfusionMatrixReader.java
@@ -60,4 +60,15 @@ public class ConfusionMatrixReader {
Integer count = confusionMatrix.get(error + "|" + correct);
return count == null ? 0 : count;
}
+
+ /**
+ * Given the error {@code error}, find the number of occurrences of the
+ * error.
+ *
+ * @param error
+ * @return
+ */
+ public int getErrorsCount(String error) {
+ return countMatrix.getOrDefault(error, 0);
+ }
}