Package com.digitalpebble.classification

Examples of com.digitalpebble.classification.Field


public class TestMultiFieldDocs extends AbstractLearnerTest {

  public void testMultiField() throws Exception {
    Field[] fields = new Field[3];
    fields[0] = new Field("title", new String[] { "This", "is", "a",
        "title" });
    fields[1] = new Field("abstract", new String[] { "abstract" });
    fields[2] = new Field("content", new String[] { "This", "is", "the",
        "content", "this", "will", "have", "a", "large", "value" });
    learner.setMethod(Parameters.WeightingMethod.TFIDF);
    Document doc = learner.createDocument(fields, "large");

    Field[] fields2 = new Field[2];
    fields2[0] = new Field("title", new String[] { "This", "is", "not",
        "a", "title" });
    // fields2[1] = new Field("abstract", new String[]{"abstract"});
    fields2[1] = new Field("content", new String[] { "This", "is", "the",
        "content", "this", "will", "have", "a", "small", "value" });
    learner.setMethod(Parameters.WeightingMethod.TFIDF);
    Document doc2 = learner.createDocument(fields2, "small");

    // try putting the same field several times
    Field[] fields3 = new Field[3];
    fields3[0] = new Field("title", new String[] { "This", "is", "not",
        "a", "title" });
    // fields2[1] = new Field("abstract", new String[]{"abstract"});
    fields3[1] = new Field("content", new String[] { "This", "is", "the",
        "content", "this", "will", "have", "a", "small", "value" });
    fields3[2] = new Field("title", new String[] { "some", "different",
        "content" });
    learner.setMethod(Parameters.WeightingMethod.TFIDF);
    Document doc3 = learner.createDocument(fields3, "small");

    RAMTrainingCorpus corpus = new RAMTrainingCorpus();
View Full Code Here


    assertEquals("small", classi.getBestLabel(scores));
  }

  public void testCustomWeightingScheme() throws Exception {
    Field[] fields = new Field[1];
    fields[0] = new Field("keywords", new String[] { "test","keywords"});
    learner.setMethod(Parameters.WeightingMethod.FREQUENCY);
    learner.getLexicon().setMethod(Parameters.WeightingMethod.BOOLEAN, "keywords");
    Document doc = learner.createDocument(fields, "large");
    Vector vector = doc.getFeatureVector(learner.getLexicon());
   
View Full Code Here

public class TestTrainingCorpus extends AbstractLearnerTest {

  public void testMultiField() throws Exception {
    Field[] fields = new Field[3];
    fields[0] = new Field("title", new String[] { "This", "is", "a",
        "title" });
    fields[1] = new Field("abstract", new String[] { "abstract" });
    fields[2] = new Field("content", new String[] { "This", "is", "the",
        "content", "this", "will", "have", "a", "large", "value" });
    Document doc = learner.createDocument(fields, "large");

    String[] simplecontent = new String[] { "This", "is", "the", "content",
        "this", "will", "have", "a", "small", "value" };
View Full Code Here

TOP

Related Classes of com.digitalpebble.classification.Field

Copyright © 2018 www.massapicom. 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.