use of edu.illinois.cs.cogcomp.core.datastructures.textannotation.TextAnnotation in project cogcomp-nlp by CogComp.
the class TestCorlex method test.
public final void test() throws EdisonException {
log.debug("Corlex Feature Extractor");
// Using the first TA and a constituent between span of 30-40 as a test
TextAnnotation ta = tas.get(1);
View TOKENS = ta.getView("TOKENS");
log.debug("Got tokens FROM TextAnnotation");
CorelexFeatureExtractor testInstance = new CorelexFeatureExtractor(true);
Set<Feature> feats = testInstance.getWordFeatures(ta, 1);
String[] expected_outputs = { "atr" };
if (feats == null) {
log.debug("Feats are returning NULL.");
}
log.debug("Printing Set of Features");
for (Feature f : feats) {
log.debug(f.getName());
assertTrue(ArrayUtils.contains(expected_outputs, f.getName()));
}
}
use of edu.illinois.cs.cogcomp.core.datastructures.textannotation.TextAnnotation in project cogcomp-nlp by CogComp.
the class TestLabelOneBefore method test.
public final void test() throws Exception {
logger.info("LabelOneBefore 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");
logger.info("GOT TOKENS FROM TEXTAnn");
List<Constituent> testlist = TOKENS.getConstituentsCoveringSpan(0, 20);
for (Constituent c : testlist) {
logger.info(c.getSurfaceForm());
}
logger.info("Testlist size is " + testlist.size());
// Constituent test = testlist.get(1);
// logger.info("The constituent we are extracting features from
// in this test is: " + test.getSurfaceForm());
POSBaseLineCounter posBaseLine = new POSBaseLineCounter("posBaseLine");
posBaseLine.buildTable(TestPosHelper.corpus);
POSMikheevCounter posMikheev = new POSMikheevCounter("posMikheev");
posMikheev.buildTable(TestPosHelper.corpus);
LabelOneBefore l1bPOS = new LabelOneBefore("l1bPOS");
LabelOneBefore l1bPOSBaseLine = new LabelOneBefore("l1bPOSBaseLine", posBaseLine);
LabelOneBefore l1bPOSMikheev = new LabelOneBefore("l1bPOSMikheev", posMikheev);
// Test when using POS View
ArrayList<Set<Feature>> featslist = new ArrayList<>();
for (Constituent test : testlist) featslist.add(l1bPOS.getFeatures(test));
if (featslist.isEmpty()) {
logger.info("Feats list is returning NULL.");
}
logger.info("\n" + "Test when using POS View");
logger.info("Printing list of Feature set");
for (Set<Feature> feats : featslist) {
for (Feature f : feats) logger.info(f.getName());
}
// Test when using POS baseline Counting
featslist.clear();
for (Constituent test : testlist) featslist.add(l1bPOSBaseLine.getFeatures(test));
if (featslist.isEmpty()) {
logger.info("Feats list is returning NULL.");
}
logger.info("\n" + "Test when using POS baseline Counting");
logger.info("Printing list of Feature set");
for (Set<Feature> feats : featslist) {
for (Feature f : feats) logger.info(f.getName());
}
// Test when using POS Mikheev Counting
featslist.clear();
for (Constituent test : testlist) featslist.add(l1bPOSMikheev.getFeatures(test));
if (featslist.isEmpty()) {
logger.info("Feats list is returning NULL.");
}
logger.info("\n" + "Test when using POS Mikheev Counting");
logger.info("Printing list of Feature set");
for (Set<Feature> feats : featslist) {
for (Feature f : feats) logger.info(f.getName());
}
logger.info("GOT FEATURES YES!");
}
use of edu.illinois.cs.cogcomp.core.datastructures.textannotation.TextAnnotation in project cogcomp-nlp by CogComp.
the class TestPOSBaseLineFeatureExtractor method test.
@Test
public final void test() throws Exception {
logger.info("POSBaseLine 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");
logger.info("GOT TOKENS FROM TEXTAnn");
List<Constituent> testlist = TOKENS.getConstituentsCoveringSpan(0, 20);
for (Constituent c : testlist) {
logger.info(c.getSurfaceForm());
}
logger.info("Testlist size is " + testlist.size());
// Constituent test = testlist.get(1);
// logger.info("The constituent we are extracting features from
// in this test is: " + test.getSurfaceForm());
// logger.info(TestPOSBaseLineFeatureExtractor.class.getProtectionDomain().getCodeSource().getLocation());
// logger.info(System.getProperty("user.dir"));
POSBaseLineFeatureExtractor posBaseLine = new POSBaseLineFeatureExtractor("posBaseLine", "test_corpus", TestPosHelper.corpus);
ArrayList<Set<Feature>> featslist = new ArrayList<>();
for (Constituent test : testlist) featslist.add(posBaseLine.getFeatures(test));
if (featslist.isEmpty()) {
logger.info("Feats list is returning NULL.");
}
logger.info("Printing list of Feature set");
for (Set<Feature> feats : featslist) {
for (Feature f : feats) logger.info(f.getName());
}
/*
* Set<Feature> feats = posBaseLine.getFeatures(test);
*
* if (feats == null) { logger.info("Feats are returning NULL."); }
*
* logger.info("Printing Set of Features");
*
* for (Feature f : feats) { logger.info(f.getName()); }
*/
logger.info("GOT FEATURES YES!");
}
use of edu.illinois.cs.cogcomp.core.datastructures.textannotation.TextAnnotation in project cogcomp-nlp by CogComp.
the class TestPOSMikheevFeatureExtractor method test.
@Test
public final void test() throws Exception {
POSMikheevFeatureExtractor posMikheev = new POSMikheevFeatureExtractor("posMikheev", "test_corpus", TestPosHelper.corpus);
logger.info("POSMikheev Feature Extractor");
logger.info("Only print the features with known tags");
// Using the first TA and a constituent between span of 30-40 as a test
int i = 0;
for (TextAnnotation ta : tas) {
ArrayList<String> outFeatures = new ArrayList<>();
View TOKENS = ta.getView("TOKENS");
for (Constituent TOKEN : TOKENS) {
Set<Feature> feats = posMikheev.getFeatures(TOKEN);
if (feats.isEmpty()) {
logger.info("Feats list is returning NULL.");
}
for (Feature f : feats) if (!f.getName().contains("UNKNOWN")) {
outFeatures.add(f.getName());
}
}
if (!outFeatures.isEmpty()) {
logger.info("-------------------------------------------------------");
logger.info("Text Annotation: " + i);
logger.info("Text Features: ");
for (String out : outFeatures) logger.info(out);
logger.info("-------------------------------------------------------");
}
i++;
}
logger.info("GOT FEATURES YES!");
}
use of edu.illinois.cs.cogcomp.core.datastructures.textannotation.TextAnnotation 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);
}
Aggregations