summaryrefslogtreecommitdiff
path: root/spellchecker/src
diff options
context:
space:
mode:
Diffstat (limited to 'spellchecker/src')
-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;
}
}