* Test of extractFeatures method, of class FeatureExtractionImpl.
*/
@Test
public void testExtractFeatures() {
System.out.println("extractFeatures");
SegmentSet segments = new SegmentSet();
Segment seg0 = new Segment();
seg0.add(new Message(0, new Date(), "Alice", "it's"));
seg0.add(new Message(1, new Date(), "Bob", "cow"));
seg0.add(new Message(2, new Date(), "Alice", "time"));
seg0.setTrueLabel(Boolean.TRUE);
segments.add(seg0);
Segment seg1 = new Segment();
seg1.add(new Message(3, new Date(), "Bob", "noooooooo"));
seg1.setTrueLabel(Boolean.FALSE);
segments.add(seg1);
Segment seg2 = new Segment();
seg2.add(new Message(4, new Date(), "Bob", "once"));
seg2.add(new Message(5, new Date(), "Alice", "upon"));
seg2.setTrueLabel(Boolean.FALSE);
segments.add(seg2);
Segment seg3 = new Segment();
seg3.add(new Message(6, new Date(), "Bob", "a"));
seg3.add(new Message(7, new Date(), "Alice", "time"));
seg3.setTrueLabel(Boolean.TRUE);
segments.add(seg3);
Instances basicInstances = segments.getBasicExamples().getInstances();
String attrName = "newAtt";
Add addFilter = new Add();
addFilter.setAttributeName(attrName);
addFilter.setAttributeType(new SelectedTag(0, Add.TAGS_TYPE));
try {
addFilter.setInputFormat(basicInstances);
} catch (Exception e) {
assertTrue(e.getMessage(), false);
}
RemoveWithValues removeFilter = new RemoveWithValues();
removeFilter.setAttributeIndex("3"); //the label attribute
removeFilter.setNominalIndicesArr(new int[]{0}); //false
try {
removeFilter.setInputFormat(addFilter.getOutputFormat());
} catch (Exception e) {
assertTrue(e.getMessage(), false);
}
FeatureSpecification spec = new FeatureSpecification();
spec.addFilter(addFilter);
spec.addFilter(removeFilter);
FeatureExtractionImpl instance = new FeatureExtractionImpl();
ExampleSet examples = instance.extractFeatures(segments.getBasicExamples(), spec);
assertNotNull(examples);
assertNotNull(examples.getInstances());
Instances instances = examples.getInstances();
//3 base attrs + 4 basic features + 1 label