use of org.dkpro.tc.api.features.Feature in project dkpro-tc by dkpro.
the class InstanceTest method instanceInitializationByListTest.
@Test
public void instanceInitializationByListTest() throws Exception {
Feature f1 = new Feature("feature1", "value1", FeatureType.STRING);
Feature f2 = new Feature("feature2", "value1", FeatureType.STRING);
List<Feature> features = new ArrayList<>();
features.add(f1);
features.add(f2);
Instance instance = new Instance(features, "outcome");
assertEquals(2, instance.getFeatures().size());
}
use of org.dkpro.tc.api.features.Feature in project dkpro-tc by dkpro.
the class InstanceTest method instanceInitializationBySetTest.
@Test
public void instanceInitializationBySetTest() throws Exception {
Feature f1 = new Feature("feature1", "value1", FeatureType.STRING);
Feature f2 = new Feature("feature2", "value1", FeatureType.STRING);
Set<Feature> features = new HashSet<Feature>();
features.add(f1);
features.add(f2);
Instance instance = new Instance(features, "outcome");
assertEquals(2, instance.getFeatures().size());
}
use of org.dkpro.tc.api.features.Feature in project dkpro-tc by dkpro.
the class InstanceTest method instanceSetSeveralOutcomesTest.
@Test
public void instanceSetSeveralOutcomesTest() throws Exception {
Feature f1 = new Feature("feature1", "value1", FeatureType.STRING);
Feature f2 = new Feature("feature2", "value1", FeatureType.STRING);
List<Feature> features = new ArrayList<>();
features.add(f1);
features.add(f2);
Instance instance = new Instance(features, "outcome");
List<String> newOutcomes = new ArrayList<String>();
newOutcomes.add("outcome1");
newOutcomes.add("outcome2");
instance.setOutcomes(newOutcomes);
assertEquals(2, instance.getOutcomes().size());
}
use of org.dkpro.tc.api.features.Feature in project dkpro-tc by dkpro.
the class InstanceTest method instanceInitializationWithListOfOutcomes.
@Test
public void instanceInitializationWithListOfOutcomes() throws Exception {
Feature f1 = new Feature("feature1", "value1", FeatureType.STRING);
Feature f2 = new Feature("feature2", "value1", FeatureType.STRING);
List<Feature> features = new ArrayList<>();
features.add(f1);
features.add(f2);
List<String> outcomes = new ArrayList<>();
outcomes.add("outcome1");
outcomes.add("outcome2");
Instance instance = new Instance(features, outcomes);
assertEquals(2, instance.getFeatures().size());
assertEquals(2, instance.getOutcomes().size());
}
use of org.dkpro.tc.api.features.Feature in project dkpro-tc by dkpro.
the class GreedyStringTilingFeatureExtractorTest method greedyStringTilingFeatureExtractorTest.
@Test
public void greedyStringTilingFeatureExtractorTest() throws Exception {
AnalysisEngine engine = createEngine(NoOpAnnotator.class);
JCas jcas = engine.newJCas();
jcas.setDocumentLanguage("en");
jcas.setDocumentText("1234567890");
engine.process(jcas);
JCas jcas2 = engine.newJCas();
jcas2.setDocumentLanguage("en");
jcas2.setDocumentText("12345");
engine.process(jcas2);
GreedyStringTilingFeatureExtractor extractor = new GreedyStringTilingFeatureExtractor();
Set<Feature> features1 = extractor.extract(jcas, jcas2);
assertEquals(1, features1.size());
Feature f1 = features1.iterator().next();
assertEquals(f1.getValue(), 0.5);
}
Aggregations