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();