Package com.digitalpebble.classification

Examples of com.digitalpebble.classification.TextClassifier.classify()


            .getClassifier(new File(resourceDir));
        // create a document from a String
        String[] tokens = Tokenizer.tokenize(text.toString(), true);
        Document doc = classifier.createDocument(tokens);
        // classify
        double[] scores = classifier.classify(doc);
        // get best label
        String label = classifier.getBestLabel(scores);
        System.out.println("Classified as : "+label);
      } catch (Exception e) {
        // TODO Auto-generated catch block
View Full Code Here


            .getClassifier(new File(resourceDir));
        // create a document from a String
        String[] tokens = Tokenizer.tokenize(text.toString(), true);
        Document doc = classifier.createDocument(tokens);
        // classify
        double[] scores = classifier.classify(doc);
        // get best label
        String label = classifier.getBestLabel(scores);
        System.out.println("Classified as : " + label);
      } catch (Exception e) {
        // TODO Auto-generated catch block
View Full Code Here

    List subjectiveCorpus = getCorpus(fileSubj,"subjective",applier);
    List objectiveCorpus = getCorpus(fileObj,"objective",applier);
  
    long l0 = System.currentTimeMillis();
   
    double[][] scores = applier.classify(subjectiveCorpus);
    int totalDocs = scores.length;
    int totalcorrect = 0;
    int correct = 0;
    // this one should be positive
    for (int i=0;i<scores.length;i++){
View Full Code Here

    }
    totalcorrect=correct;
    System.out.println("----- Subjectives -----");
    System.out.println(correct+" correct");
   
    scores = applier.classify(objectiveCorpus);
    correct = 0;
    totalDocs += scores.length;
    // this one should be negative
    for (int i=0;i<scores.length;i++){
      if (scores[i][0]<scores[i][1])correct++;
View Full Code Here

    corpus.add(doc);
    corpus.add(doc2);
    learner.learn(corpus);

    TextClassifier classi = TextClassifier.getClassifier(tempFile);
    double[] scores = classi.classify(doc);
    assertEquals("large", classi.getBestLabel(scores));
    scores = classi.classify(doc2);
    assertEquals("small", classi.getBestLabel(scores));
    scores = classi.classify(doc3);
    assertEquals("small", classi.getBestLabel(scores));
View Full Code Here

    learner.learn(corpus);

    TextClassifier classi = TextClassifier.getClassifier(tempFile);
    double[] scores = classi.classify(doc);
    assertEquals("large", classi.getBestLabel(scores));
    scores = classi.classify(doc2);
    assertEquals("small", classi.getBestLabel(scores));
    scores = classi.classify(doc3);
    assertEquals("small", classi.getBestLabel(scores));
  }
View Full Code Here

    TextClassifier classi = TextClassifier.getClassifier(tempFile);
    double[] scores = classi.classify(doc);
    assertEquals("large", classi.getBestLabel(scores));
    scores = classi.classify(doc2);
    assertEquals("small", classi.getBestLabel(scores));
    scores = classi.classify(doc3);
    assertEquals("small", classi.getBestLabel(scores));
  }

  public void testCustomWeightingScheme() throws Exception {
    Field[] fields = new Field[1];
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.