From bec3ac2780fce9f90830f9f21a03b6c5487cd21c Mon Sep 17 00:00:00 2001 From: Peter Wu Date: Tue, 31 Mar 2015 18:57:57 +0200 Subject: Add simple getSmoothedCount implementation --- spellchecker/src/CorpusReader.java | 10 +++++++--- 1 file 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; } } -- cgit v1.2.1