Package org.apache.mahout.classifier.bayes

Examples of org.apache.mahout.classifier.bayes.ClassifierContext.classifyDocument()


      while (ts.incrementToken()) {
        tokens.add(ts.getAttribute(CharTermAttribute.class).toString());
      }
      String[] document = tokens.toArray(new String[tokens.size()]);
     
      ClassifierResult[] cr = ctx.classifyDocument(document, "unknown", 5);
     
      for (ClassifierResult r: cr) {
        System.err.println(r.getLabel() + "\t" + r.getScore());
      }
    } catch (OptionException e) {
View Full Code Here


   
    List<String> doc = new NGrams(line.toString(), gramSize).generateNGramsWithoutLabel();
   
    log.info("Done converting");
    log.info("Classifying document: {}", docPath);
    ClassifierResult category = classifier.classifyDocument(doc.toArray(new String[doc.size()]), defaultCat);
    log.info("Category for {} is {}", docPath, category);
   
  }
}
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.