summaryrefslogtreecommitdiff
path: root/spellchecker/src/SpellChecker.java
diff options
context:
space:
mode:
Diffstat (limited to 'spellchecker/src/SpellChecker.java')
-rw-r--r--spellchecker/src/SpellChecker.java50
1 files changed, 50 insertions, 0 deletions
diff --git a/spellchecker/src/SpellChecker.java b/spellchecker/src/SpellChecker.java
new file mode 100644
index 0000000..cdabf92
--- /dev/null
+++ b/spellchecker/src/SpellChecker.java
@@ -0,0 +1,50 @@
+
+
+import java.io.IOException;
+import java.util.Scanner;
+
+
+public class SpellChecker {
+
+ /**
+ * @param args the command line arguments
+ */
+ public static void main(String[] args)
+ {
+ boolean inPeach = false; // set this to true if you submit to peach!!!
+
+ try {
+ CorpusReader cr = new CorpusReader();
+ ConfusionMatrixReader cmr = new ConfusionMatrixReader();
+ SpellCorrector sc = new SpellCorrector(cr, cmr);
+ if (inPeach) {
+ peachTest(sc);
+ } else {
+ nonPeachTest(sc);
+ }
+ } catch (Exception ex) {
+ System.out.println(ex);
+ ex.printStackTrace();
+ }
+ }
+
+ static void nonPeachTest(SpellCorrector sc) throws IOException {
+ String[] sentences = {
+ "at the hme locations there were traces of water"
+ };
+
+ for(String s0: sentences) {
+ System.out.println("Input : " + s0);
+ String result=sc.correctPhrase(s0);
+ System.out.println("Answer: " +result);
+ System.out.println();
+ }
+ }
+
+ static void peachTest(SpellCorrector sc) throws IOException {
+ Scanner input = new Scanner(System.in);
+
+ String sentence = input.nextLine();
+ System.out.println("Answer: " + sc.correctPhrase(sentence));
+ }
+} \ No newline at end of file