document.write('
Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. package edu.illinois.cs.cogcomp.tutorial;
  2.  
  3. import java.util.ArrayList;
  4. import java.util.Arrays;
  5. import java.util.List;
  6. import java.util.Scanner;
  7.  
  8. public class SpamClassifierApplication {
  9.  
  10.     public static void main(String[] args) {
  11.             // Here we call the classifier we have created, just like
  12.             // any other java object.
  13.             SpamClassifier sc = new SpamClassifier();
  14.            
  15.             System.out.print("Enter text to be classified (Ctrl-D to quit):\\n>> ");
  16.                
  17.             // Read data in
  18.             Scanner scanner = new Scanner(System.in);
  19.             while (scanner.hasNextLine()) {
  20.                 String email = scanner.nextLine();
  21.                 String[] words = email.split(" ");
  22.                
  23.                 List docwords = new ArrayList();
  24.                 docwords.addAll(Arrays.asList(words));
  25.  
  26.                 // Recall: the SpamClassifier understands how
  27.                 // to deal with Documents, so we create one.
  28.                 Document doc = new Document(docwords);
  29.  
  30.                 // Now we predict the label of that Document.
  31.                 String label = sc.discreteValue(doc);
  32.  
  33.                 // Hopefully this is correct!
  34.                 System.out.println("Classified as: " + label);
  35.                 System.out.print("Enter text to be classified (Ctrl-D to quit):\\n>> ");
  36.             }
  37.     }  
  38. }
');