Search in sources :

Example 1 with LabelOneAfter

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

the class TestLabelOneAfter method test.

public final void test() {
    logger.info("LabelOneAfter 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());
    // String fileName =
    // "C:\\Users\\Jason\\Desktop\\UIUC 2015 Fall\\Cogcomp\\pos-translation\\pos";
    POSBaseLineCounter posBaseLine = new POSBaseLineCounter("posBaseLine");
    try {
        posBaseLine.buildTable(TestPosHelper.corpus);
    } catch (Exception e) {
        e.printStackTrace();
        fail(e.getMessage());
    }
    POSMikheevCounter posMikheev = new POSMikheevCounter("posMikheev");
    try {
        posMikheev.buildTable(TestPosHelper.corpus);
    } catch (Exception e) {
        e.printStackTrace();
        fail(e.getMessage());
    }
    LabelOneAfter l1aPOS = new LabelOneAfter("l1aPOS");
    LabelOneAfter l1aPOSBaseLine = new LabelOneAfter("l1aPOSBaseLine", posBaseLine);
    LabelOneAfter l1aPOSMikheev = new LabelOneAfter("l1aPOSMikheev", posMikheev);
    // Test when using POS View
    ArrayList<Set<Feature>> featslist = new ArrayList<>();
    for (Constituent test : testlist) try {
        featslist.add(l1aPOS.getFeatures(test));
    } catch (EdisonException e) {
        fail(e.getMessage());
    }
    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) try {
        featslist.add(l1aPOSBaseLine.getFeatures(test));
    } catch (EdisonException e) {
        e.printStackTrace();
        fail(e.getMessage());
    }
    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) try {
        featslist.add(l1aPOSMikheev.getFeatures(test));
    } catch (EdisonException e) {
        e.printStackTrace();
        fail(e.getMessage());
    }
    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!");
}
Also used : Set(java.util.Set) LabelOneAfter(edu.illinois.cs.cogcomp.edison.features.lrec.LabelOneAfter) ArrayList(java.util.ArrayList) EdisonException(edu.illinois.cs.cogcomp.edison.utilities.EdisonException) View(edu.illinois.cs.cogcomp.core.datastructures.textannotation.View) Feature(edu.illinois.cs.cogcomp.edison.features.Feature) EdisonException(edu.illinois.cs.cogcomp.edison.utilities.EdisonException) POSBaseLineCounter(edu.illinois.cs.cogcomp.edison.utilities.POSBaseLineCounter) TextAnnotation(edu.illinois.cs.cogcomp.core.datastructures.textannotation.TextAnnotation) Constituent(edu.illinois.cs.cogcomp.core.datastructures.textannotation.Constituent) POSMikheevCounter(edu.illinois.cs.cogcomp.edison.utilities.POSMikheevCounter)

Aggregations

Constituent (edu.illinois.cs.cogcomp.core.datastructures.textannotation.Constituent)1 TextAnnotation (edu.illinois.cs.cogcomp.core.datastructures.textannotation.TextAnnotation)1 View (edu.illinois.cs.cogcomp.core.datastructures.textannotation.View)1 Feature (edu.illinois.cs.cogcomp.edison.features.Feature)1 LabelOneAfter (edu.illinois.cs.cogcomp.edison.features.lrec.LabelOneAfter)1 EdisonException (edu.illinois.cs.cogcomp.edison.utilities.EdisonException)1 POSBaseLineCounter (edu.illinois.cs.cogcomp.edison.utilities.POSBaseLineCounter)1 POSMikheevCounter (edu.illinois.cs.cogcomp.edison.utilities.POSMikheevCounter)1 ArrayList (java.util.ArrayList)1 Set (java.util.Set)1