Search in sources :

Example 16 with View

use of edu.illinois.cs.cogcomp.core.datastructures.textannotation.View in project cogcomp-nlp by CogComp.

the class TestPOSWindowTwo method test.

@Test
public final void test() throws EdisonException {
    log.debug("POSWindowTwo 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");
    List<Constituent> testlist = TOKENS.getConstituentsCoveringSpan(0, 20);
    for (Constituent c : testlist) {
        log.debug(c.getSurfaceForm());
    }
    Constituent test = testlist.get(1);
    log.debug("The constituent we are extracting features from in this test is: " + test.getSurfaceForm());
    POSWindowTwo POSW = new POSWindowTwo("POSWindowTwo");
    log.debug("Startspan is " + test.getStartSpan() + " and Endspan is " + test.getEndSpan());
    Set<Feature> feats = POSW.getFeatures(test);
    String[] expected_outputs = { "POSWindowTwo:0(DT)", "POSWindowTwo:1(VBZ)", "POSWindowTwo:2(DT)", "POSWindowTwo:3(NN)" };
    if (feats == null) {
        log.debug("Feats are returning NULL.");
    }
    log.debug("Printing Set of Features");
    for (Feature f : feats) {
        assert (ArrayUtils.contains(expected_outputs, f.getName()));
    }
// 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)

Example 17 with View

use of edu.illinois.cs.cogcomp.core.datastructures.textannotation.View in project cogcomp-nlp by CogComp.

the class TestSrlVerbSimplePredicateFeatures method test.

public final void test() throws Exception {
    logger.info("PredicateFeatures Feature Extractor");
    String[] viewsToAdd = { ViewNames.POS, ViewNames.LEMMA, ViewNames.SHALLOW_PARSE, ViewNames.PARSE_GOLD, ViewNames.SRL_VERB, ViewNames.PARSE_STANFORD, ViewNames.NER_CONLL };
    TextAnnotation ta = DummyTextAnnotationGenerator.generateAnnotatedTextAnnotation(viewsToAdd, true, 3);
    int i = 0;
    ta.addView(ClauseViewGenerator.STANFORD);
    ta.addView(PseudoParse.STANFORD);
    logger.info("This textannotation annotates the text: \n" + ta.getText());
    View TOKENS = ta.getView("TOKENS");
    List<Constituent> testlist = TOKENS.getConstituentsCoveringSpan(10, 13);
    testlist.addAll(TOKENS.getConstituentsCoveringSpan(26, 27));
    FeatureManifest featureManifest;
    FeatureExtractor fex;
    String fileName = Constant.prefix + "/Verb/Predicate/predicate-features.fex";
    featureManifest = new FeatureManifest(new FileInputStream(fileName));
    FeatureManifest.setFeatureExtractor("hyphen-argument-feature", FeatureGenerators.hyphenTagFeature);
    FeatureManifest.setTransformer("parse-left-sibling", FeatureGenerators.getParseLeftSibling(ViewNames.PARSE_STANFORD));
    FeatureManifest.setTransformer("parse-right-sibling", FeatureGenerators.getParseRightSibling(ViewNames.PARSE_STANFORD));
    FeatureManifest.setFeatureExtractor("pp-features", FeatureGenerators.ppFeatures(ViewNames.PARSE_STANFORD));
    FeatureManifest.setFeatureExtractor("projected-path", new ProjectedPath(ViewNames.PARSE_STANFORD));
    featureManifest.useCompressedName();
    featureManifest.setVariable("*default-parser*", ViewNames.PARSE_STANFORD);
    fex = featureManifest.createFex();
    SrlVerbSimplePredicateFeatures pf = new SrlVerbSimplePredicateFeatures();
    for (Constituent test : testlist) {
        assertTrue(SRLFeaturesComparator.isEqual(test, fex, pf));
    }
}
Also used : FeatureExtractor(edu.illinois.cs.cogcomp.edison.features.FeatureExtractor) FeatureManifest(edu.illinois.cs.cogcomp.edison.features.manifest.FeatureManifest) ProjectedPath(edu.illinois.cs.cogcomp.edison.features.lrec.ProjectedPath) TextAnnotation(edu.illinois.cs.cogcomp.core.datastructures.textannotation.TextAnnotation) View(edu.illinois.cs.cogcomp.core.datastructures.textannotation.View) Constituent(edu.illinois.cs.cogcomp.core.datastructures.textannotation.Constituent) FileInputStream(java.io.FileInputStream)

Example 18 with View

use of edu.illinois.cs.cogcomp.core.datastructures.textannotation.View in project cogcomp-nlp by CogComp.

the class TestSrlVerbPredicateFeatures method test.

public final void test() throws Exception {
    logger.info("PredicateFeatures Feature Extractor");
    String[] viewsToAdd = { ViewNames.POS, ViewNames.LEMMA, ViewNames.SHALLOW_PARSE, ViewNames.PARSE_GOLD, ViewNames.SRL_VERB, ViewNames.PARSE_STANFORD, ViewNames.NER_CONLL };
    TextAnnotation ta = DummyTextAnnotationGenerator.generateAnnotatedTextAnnotation(viewsToAdd, true, 3);
    int i = 0;
    ta.addView(ClauseViewGenerator.STANFORD);
    ta.addView(PseudoParse.STANFORD);
    logger.info("This textannotation annotates the text: \n" + ta.getText());
    View TOKENS = ta.getView("TOKENS");
    List<Constituent> testlist = TOKENS.getConstituentsCoveringSpan(10, 13);
    testlist.addAll(TOKENS.getConstituentsCoveringSpan(26, 27));
    FeatureManifest featureManifest;
    FeatureExtractor fex;
    String fileName = Constant.prefix + "/Verb/Identifier/predicate-features.fex";
    featureManifest = new FeatureManifest(new FileInputStream(fileName));
    FeatureManifest.setFeatureExtractor("hyphen-argument-feature", FeatureGenerators.hyphenTagFeature);
    FeatureManifest.setTransformer("parse-left-sibling", FeatureGenerators.getParseLeftSibling(ViewNames.PARSE_STANFORD));
    FeatureManifest.setTransformer("parse-right-sibling", FeatureGenerators.getParseRightSibling(ViewNames.PARSE_STANFORD));
    FeatureManifest.setFeatureExtractor("pp-features", FeatureGenerators.ppFeatures(ViewNames.PARSE_STANFORD));
    FeatureManifest.setFeatureExtractor("projected-path", new ProjectedPath(ViewNames.PARSE_STANFORD));
    featureManifest.useCompressedName();
    featureManifest.setVariable("*default-parser*", ViewNames.PARSE_STANFORD);
    fex = featureManifest.createFex();
    SrlVerbPredicateFeatures af = new SrlVerbPredicateFeatures();
    for (Constituent test : testlist) {
        assertTrue(SRLFeaturesComparator.isEqual(test, fex, af));
    }
}
Also used : SrlVerbPredicateFeatures(edu.illinois.cs.cogcomp.edison.features.lrec.srl.Verb.SrlVerbPredicateFeatures) FeatureExtractor(edu.illinois.cs.cogcomp.edison.features.FeatureExtractor) FeatureManifest(edu.illinois.cs.cogcomp.edison.features.manifest.FeatureManifest) ProjectedPath(edu.illinois.cs.cogcomp.edison.features.lrec.ProjectedPath) TextAnnotation(edu.illinois.cs.cogcomp.core.datastructures.textannotation.TextAnnotation) View(edu.illinois.cs.cogcomp.core.datastructures.textannotation.View) Constituent(edu.illinois.cs.cogcomp.core.datastructures.textannotation.Constituent) FileInputStream(java.io.FileInputStream)

Example 19 with View

use of edu.illinois.cs.cogcomp.core.datastructures.textannotation.View in project cogcomp-nlp by CogComp.

the class TestPOSContext method test.

public final void test() throws Exception {
    logger.info("POSContext Feature Extractor");
    String[] viewsToAdd = { ViewNames.POS, ViewNames.LEMMA, ViewNames.SHALLOW_PARSE, ViewNames.PARSE_GOLD, ViewNames.SRL_VERB, ViewNames.PARSE_STANFORD, ViewNames.NER_CONLL };
    TextAnnotation ta = DummyTextAnnotationGenerator.generateAnnotatedTextAnnotation(viewsToAdd, true, 3);
    int i = 0;
    ta.addView(ClauseViewGenerator.STANFORD);
    ta.addView(PseudoParse.STANFORD);
    logger.info("This textannotation annotates the text: \n" + ta.getText());
    View TOKENS = ta.getView("TOKENS");
    List<Constituent> testlist = TOKENS.getConstituentsCoveringSpan(10, 13);
    FeatureManifest featureManifest;
    FeatureExtractor fex;
    String fileName = Constant.prefix + "/Nom/Classifier/pos-context.fex";
    featureManifest = new FeatureManifest(new FileInputStream(fileName));
    FeatureManifest.setFeatureExtractor("hyphen-argument-feature", FeatureGenerators.hyphenTagFeature);
    FeatureManifest.setTransformer("parse-left-sibling", FeatureGenerators.getParseLeftSibling(ViewNames.PARSE_STANFORD));
    FeatureManifest.setTransformer("parse-right-sibling", FeatureGenerators.getParseRightSibling(ViewNames.PARSE_STANFORD));
    FeatureManifest.setFeatureExtractor("pp-features", FeatureGenerators.ppFeatures(ViewNames.PARSE_STANFORD));
    FeatureManifest.setFeatureExtractor("projected-path", new ProjectedPath(ViewNames.PARSE_STANFORD));
    featureManifest.useCompressedName();
    featureManifest.setVariable("*default-parser*", ViewNames.PARSE_STANFORD);
    fex = featureManifest.createFex();
    POSContextWindowTwo pc = new POSContextWindowTwo();
    for (Constituent test : testlist) {
        assertTrue(SRLFeaturesComparator.isEqual(test, fex, pc));
    }
}
Also used : FeatureExtractor(edu.illinois.cs.cogcomp.edison.features.FeatureExtractor) FeatureManifest(edu.illinois.cs.cogcomp.edison.features.manifest.FeatureManifest) ProjectedPath(edu.illinois.cs.cogcomp.edison.features.lrec.ProjectedPath) TextAnnotation(edu.illinois.cs.cogcomp.core.datastructures.textannotation.TextAnnotation) View(edu.illinois.cs.cogcomp.core.datastructures.textannotation.View) Constituent(edu.illinois.cs.cogcomp.core.datastructures.textannotation.Constituent) FileInputStream(java.io.FileInputStream)

Example 20 with View

use of edu.illinois.cs.cogcomp.core.datastructures.textannotation.View in project cogcomp-nlp by CogComp.

the class TestParseSibling method test.

public final void test() throws Exception {
    logger.info("ParseSibling Feature Extractor");
    String[] viewsToAdd = { ViewNames.POS, ViewNames.LEMMA, ViewNames.SHALLOW_PARSE, ViewNames.PARSE_GOLD, ViewNames.SRL_VERB, ViewNames.PARSE_STANFORD, ViewNames.NER_CONLL };
    TextAnnotation ta = DummyTextAnnotationGenerator.generateAnnotatedTextAnnotation(viewsToAdd, true, 3);
    int i = 0;
    ta.addView(ClauseViewGenerator.STANFORD);
    ta.addView(PseudoParse.STANFORD);
    logger.info("This textannotation annotates the text: \n" + ta.getText());
    View TOKENS = ta.getView("TOKENS");
    List<Constituent> testlist = TOKENS.getConstituentsCoveringSpan(10, 13);
    testlist.addAll(TOKENS.getConstituentsCoveringSpan(26, 27));
    FeatureManifest featureManifest;
    FeatureExtractor fex;
    String fileName = Constant.prefix + "/Verb/Classifier/parse-sibling.fex";
    featureManifest = new FeatureManifest(new FileInputStream(fileName));
    FeatureManifest.setFeatureExtractor("hyphen-argument-feature", FeatureGenerators.hyphenTagFeature);
    FeatureManifest.setTransformer("parse-left-sibling", FeatureGenerators.getParseLeftSibling(ViewNames.PARSE_STANFORD));
    FeatureManifest.setTransformer("parse-right-sibling", FeatureGenerators.getParseRightSibling(ViewNames.PARSE_STANFORD));
    FeatureManifest.setFeatureExtractor("pp-features", FeatureGenerators.ppFeatures(ViewNames.PARSE_STANFORD));
    FeatureManifest.setFeatureExtractor("projected-path", new ProjectedPath(ViewNames.PARSE_STANFORD));
    featureManifest.useCompressedName();
    featureManifest.setVariable("*default-parser*", ViewNames.PARSE_STANFORD);
    fex = featureManifest.createFex();
    ParseSibling ps = new ParseSibling();
    for (Constituent test : testlist) {
        assertTrue(SRLFeaturesComparator.isEqual(test, fex, ps));
    }
}
Also used : ParseSibling(edu.illinois.cs.cogcomp.edison.features.lrec.srl.generic.ParseSibling) FeatureExtractor(edu.illinois.cs.cogcomp.edison.features.FeatureExtractor) FeatureManifest(edu.illinois.cs.cogcomp.edison.features.manifest.FeatureManifest) ProjectedPath(edu.illinois.cs.cogcomp.edison.features.lrec.ProjectedPath) TextAnnotation(edu.illinois.cs.cogcomp.core.datastructures.textannotation.TextAnnotation) View(edu.illinois.cs.cogcomp.core.datastructures.textannotation.View) Constituent(edu.illinois.cs.cogcomp.core.datastructures.textannotation.Constituent) FileInputStream(java.io.FileInputStream)

Aggregations

View (edu.illinois.cs.cogcomp.core.datastructures.textannotation.View)64 Constituent (edu.illinois.cs.cogcomp.core.datastructures.textannotation.Constituent)51 TextAnnotation (edu.illinois.cs.cogcomp.core.datastructures.textannotation.TextAnnotation)49 Feature (edu.illinois.cs.cogcomp.edison.features.Feature)22 Test (org.junit.Test)21 FeatureExtractor (edu.illinois.cs.cogcomp.edison.features.FeatureExtractor)16 ProjectedPath (edu.illinois.cs.cogcomp.edison.features.lrec.ProjectedPath)16 FeatureManifest (edu.illinois.cs.cogcomp.edison.features.manifest.FeatureManifest)16 FileInputStream (java.io.FileInputStream)16 AnnotatorException (edu.illinois.cs.cogcomp.annotation.AnnotatorException)7 PredicateArgumentView (edu.illinois.cs.cogcomp.core.datastructures.textannotation.PredicateArgumentView)7 ArrayList (java.util.ArrayList)7 DiscreteFeature (edu.illinois.cs.cogcomp.edison.features.DiscreteFeature)6 LinkedHashSet (java.util.LinkedHashSet)6 Set (java.util.Set)6 POSBaseLineCounter (edu.illinois.cs.cogcomp.edison.utilities.POSBaseLineCounter)5 POSMikheevCounter (edu.illinois.cs.cogcomp.edison.utilities.POSMikheevCounter)5 IOException (java.io.IOException)5 EdisonException (edu.illinois.cs.cogcomp.edison.utilities.EdisonException)4 JsonObject (com.google.gson.JsonObject)3