summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Wu <peter@lekensteyn.nl>2015-03-31 18:57:57 +0200
committerPeter Wu <peter@lekensteyn.nl>2015-03-31 18:57:57 +0200
commitbec3ac2780fce9f90830f9f21a03b6c5487cd21c (patch)
tree6facce81c2a27c5f1aa284fe24587e539d6e6bab
parentecce7ed7b203ac6937df1ff705cd4e14217cb3ca (diff)
downloadassignment4-bec3ac2780fce9f90830f9f21a03b6c5487cd21c.tar.gz
Add simple getSmoothedCount implementation
-rw-r--r--spellchecker/src/CorpusReader.java10
1 files changed, 7 insertions, 3 deletions
diff --git a/spellchecker/src/CorpusReader.java b/spellchecker/src/CorpusReader.java
index 1392654..536a41b 100644
--- a/spellchecker/src/CorpusReader.java
+++ b/spellchecker/src/CorpusReader.java
@@ -99,6 +99,10 @@ public class CorpusReader {
return vocabulary.contains(word);
}
+ /**
+ * Returns a smoothed value based on the number of occurrences of the n-gram
+ * in the corpus.
+ */
public double getSmoothedCount(String NGram) {
if (NGram == null || NGram.length() == 0) {
throw new IllegalArgumentException("NGram must be non-empty.");
@@ -106,9 +110,9 @@ public class CorpusReader {
double smoothedCount = 0.0;
- /**
- * ADD CODE HERE *
- */
+ // simplest smoothing implementation: plus 1.
+ smoothedCount = getNGramCount(NGram) + 1;
+
return smoothedCount;
}
}