Search in sources :

Example 71 with Feature

use of edu.illinois.cs.cogcomp.edison.features.Feature in project cogcomp-nlp by CogComp.

the class TestPOSandPositionWindowThree method test.

@Test
public final void test() throws EdisonException {
    log.debug("POSWindowpp Feature Extractor");
    // Using the first TA and a constituent between span of 30-40 as a test
    TextAnnotation ta = tas.get(2);
    View TOKENS = ta.getView("TOKENS");
    log.debug("GOT TOKENS FROM TEXTAnn");
    List<Constituent> testlist = TOKENS.getConstituentsCoveringSpan(0, 20);
    for (Constituent c : testlist) {
        log.debug(c.getSurfaceForm());
    }
    log.debug("Testlist size is " + testlist.size());
    Constituent test = testlist.get(1);
    log.debug("The constituent we are extracting features from in this test is: " + test.getSurfaceForm());
    POSandPositionWindowThree POSWpp = new POSandPositionWindowThree("POSandPositionWindowThree");
    // Formpp.initViews(test);
    log.debug("Startspan is " + test.getStartSpan() + " and Endspan is " + test.getEndSpan());
    Set<Feature> feats = POSWpp.getFeatures(test);
    String[] expected_outputs = { "POSandPositionWindowThree:0_0(DT)", "POSandPositionWindowThree:1_0(VBZ)", "POSandPositionWindowThree:2_0(DT)", "POSandPositionWindowThree:3_0(NN)", "POSandPositionWindowThree:4_0(.)", "POSandPositionWindowThree:5_0(null)", "POSandPositionWindowThree:6_0(null)", "POSandPositionWindowThree:0_1(DT_VBZ)", "POSandPositionWindowThree:1_1(VBZ_DT)", "POSandPositionWindowThree:2_1(DT_NN)", "POSandPositionWindowThree:3_1(NN_.)", "POSandPositionWindowThree:4_1(._null)", "POSandPositionWindowThree:5_1(null_null)", "POSandPositionWindowThree:6_1(null)", "POSandPositionWindowThree:0_2(DT_VBZ_DT)", "POSandPositionWindowThree:1_2(VBZ_DT_NN)", "POSandPositionWindowThree:2_2(DT_NN_.)", "POSandPositionWindowThree:3_2(NN_._null)", "POSandPositionWindowThree:4_2(._null_null)", "POSandPositionWindowThree:5_2(null_null)", "POSandPositionWindowThree:6_2(null)" };
    if (feats == null) {
        log.debug("Feats are returning NULL.");
    }
    log.debug("Printing Set of Features");
    for (Feature f : feats) {
        log.debug(f.getName());
        assert (ArrayUtils.contains(expected_outputs, f.getName()));
    }
    log.debug("GOT FEATURES YES!");
// System.exit(0);
}
Also used : TextAnnotation(edu.illinois.cs.cogcomp.core.datastructures.textannotation.TextAnnotation) PredicateArgumentView(edu.illinois.cs.cogcomp.core.datastructures.textannotation.PredicateArgumentView) View(edu.illinois.cs.cogcomp.core.datastructures.textannotation.View) Feature(edu.illinois.cs.cogcomp.edison.features.Feature) Constituent(edu.illinois.cs.cogcomp.core.datastructures.textannotation.Constituent) Test(org.junit.Test)

Aggregations

Feature (edu.illinois.cs.cogcomp.edison.features.Feature)71 TextAnnotation (edu.illinois.cs.cogcomp.core.datastructures.textannotation.TextAnnotation)48 Constituent (edu.illinois.cs.cogcomp.core.datastructures.textannotation.Constituent)44 DiscreteFeature (edu.illinois.cs.cogcomp.edison.features.DiscreteFeature)41 LinkedHashSet (java.util.LinkedHashSet)24 View (edu.illinois.cs.cogcomp.core.datastructures.textannotation.View)22 EdisonException (edu.illinois.cs.cogcomp.edison.utilities.EdisonException)17 Test (org.junit.Test)13 TreeView (edu.illinois.cs.cogcomp.core.datastructures.textannotation.TreeView)12 HashSet (java.util.HashSet)11 Relation (edu.illinois.cs.cogcomp.core.datastructures.textannotation.Relation)10 ArrayList (java.util.ArrayList)9 PredicateArgumentView (edu.illinois.cs.cogcomp.core.datastructures.textannotation.PredicateArgumentView)8 RealFeature (edu.illinois.cs.cogcomp.edison.features.RealFeature)8 Set (java.util.Set)6 TokenLabelView (edu.illinois.cs.cogcomp.core.datastructures.textannotation.TokenLabelView)5 POSBaseLineCounter (edu.illinois.cs.cogcomp.edison.utilities.POSBaseLineCounter)5 POSMikheevCounter (edu.illinois.cs.cogcomp.edison.utilities.POSMikheevCounter)5 ModelInfo (edu.illinois.cs.cogcomp.verbsense.core.ModelInfo)3 List (java.util.List)3