use of edu.illinois.cs.cogcomp.edison.features.FeatureExtractor in project cogcomp-nlp by CogComp.
the class FeatureManifestTest method testCreateFex.
@Test
public void testCreateFex() throws Exception {
FeatureManifest featureManifest = new FeatureManifest(file);
featureManifest.useCompressedName();
featureManifest.setVariable("*default-parser*", ViewNames.PARSE_STANFORD);
FeatureExtractor fex = featureManifest.createFex();
Constituent c = tas.get(0).getView(ViewNames.TOKENS).getConstituents().get(0);
assertEquals("My", c.getSurfaceForm());
Set<Feature> features = fex.getFeatures(c);
Iterator<Feature> iterator = features.iterator();
Feature feature = iterator.next();
assertEquals("f:#ctxt#:context1::#wd:mother-in-law", feature.getName());
}
use of edu.illinois.cs.cogcomp.edison.features.FeatureExtractor in project cogcomp-nlp by CogComp.
the class TestSrlNomArgumentFeatures method test.
/**
* Only in and out relations in the SRL_VERB view are used for the purpose of testing.
*/
public final void test() throws Exception {
logger.info("ArgumentFeatures 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);
ta.addView(ClauseViewGenerator.STANFORD);
ta.addView(PseudoParse.STANFORD);
logger.info("This textannotation annotates the text: \n" + ta.getText());
View SRL_VERB = ta.getView("SRL_VERB");
List<Constituent> testlist = SRL_VERB.getConstituentsCoveringSpan(10, 13);
testlist.addAll(SRL_VERB.getConstituentsCoveringSpan(26, 27));
FeatureManifest featureManifest;
FeatureExtractor fex;
String fileName = Constant.prefix + "/Nom/Classifier/arg-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();
SrlNomArgumentFeatures af = new SrlNomArgumentFeatures();
for (Constituent test : testlist) {
assertTrue(SRLFeaturesComparator.isEqual(test, fex, af));
}
}
use of edu.illinois.cs.cogcomp.edison.features.FeatureExtractor in project cogcomp-nlp by CogComp.
the class TestSrlNomClassifierPredicateFeatures method test.
/**
* Only in and out relations in the SRL_VERB view are used for the purpose of testing.
*
*/
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 SRL_VERB = ta.getView("SRL_VERB");
List<Constituent> testlist = SRL_VERB.getConstituentsCoveringSpan(10, 13);
testlist.addAll(SRL_VERB.getConstituentsCoveringSpan(26, 27));
FeatureManifest featureManifest;
FeatureExtractor fex;
String fileName = Constant.prefix + "/Nom/Classifier/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();
SrlNomClassifierPredicateFeatures pf = new SrlNomClassifierPredicateFeatures();
for (Constituent test : testlist) {
assertTrue(SRLFeaturesComparator.isEqual(test, fex, pf));
}
}
use of edu.illinois.cs.cogcomp.edison.features.FeatureExtractor in project cogcomp-nlp by CogComp.
the class TestSrlNomHeadWordFeatures method test.
public final void test() throws Exception {
logger.info("HeadWordFeatures 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 + "/Nom/Identifier/head-word-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();
SrlNomHeadWordFeatures hwf = new SrlNomHeadWordFeatures();
for (Constituent test : testlist) {
assertTrue(SRLFeaturesComparator.isEqual(test, fex, hwf));
}
}
use of edu.illinois.cs.cogcomp.edison.features.FeatureExtractor in project cogcomp-nlp by CogComp.
the class TestSrlNomIdentifierPredicateFeatures 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 + "/Nom/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();
SrlNomIdentifierPredicateFeatures pf = new SrlNomIdentifierPredicateFeatures();
for (Constituent test : testlist) {
assertTrue(SRLFeaturesComparator.isEqual(test, fex, pf));
}
}
Aggregations