Search in sources :

Example 21 with Comma

use of edu.illinois.cs.cogcomp.comma.datastructures.Comma in project cogcomp-nlp by CogComp.

the class ParseTreeFeature method discreteValue.

public String discreteValue(Object __example) {
    if (!(__example instanceof Comma)) {
        String type = __example == null ? "null" : __example.getClass().getName();
        System.err.println("Classifier 'ParseTreeFeature(Comma)' defined on line 75 of CommaClassifier.lbj received '" + type + "' as input.");
        new Exception().printStackTrace();
        System.exit(1);
    }
    Comma c = (Comma) __example;
    String tree = "";
    int distance = 0;
    String phrase;
    do {
        phrase = c.getNotation(c.getPhraseToLeftOfParent(distance));
        tree = phrase + tree;
        distance++;
    } while (!phrase.equals("NULL"));
    String commaLevelPhrases = "";
    distance = 0;
    do {
        phrase = c.getNotation(c.getPhraseToLeftOfComma(distance));
        commaLevelPhrases = phrase + commaLevelPhrases;
        distance++;
    } while (!phrase.equals("NULL"));
    distance = 1;
    do {
        phrase = c.getNotation(c.getPhraseToRightOfComma(distance));
        commaLevelPhrases = commaLevelPhrases + phrase;
        distance++;
    } while (!phrase.equals("NULL"));
    tree += "(" + commaLevelPhrases + ")";
    distance = 1;
    do {
        phrase = c.getNotation(c.getPhraseToRightOfParent(distance));
        tree = tree + phrase;
        distance++;
    } while (!phrase.equals("NULL"));
    return "" + (tree);
}
Also used : Comma(edu.illinois.cs.cogcomp.comma.datastructures.Comma)

Example 22 with Comma

use of edu.illinois.cs.cogcomp.comma.datastructures.Comma in project cogcomp-nlp by CogComp.

the class RightToLeftDependencies method classify.

public FeatureVector classify(Object __example) {
    if (!(__example instanceof Comma)) {
        String type = __example == null ? "null" : __example.getClass().getName();
        System.err.println("Classifier 'RightToLeftDependencies(Comma)' defined on line 59 of CommaClassifier.lbj received '" + type + "' as input.");
        new Exception().printStackTrace();
        System.exit(1);
    }
    Comma c = (Comma) __example;
    FeatureVector __result;
    __result = new FeatureVector();
    String __id;
    String __value;
    String[] rtol = c.getLeftToRightDependencies();
    for (int i = 0; i < rtol.length; i++) {
        __id = "" + (rtol[i]);
        __value = "true";
        __result.addFeature(new DiscretePrimitiveStringFeature(this.containingPackage, this.name, __id, __value, valueIndexOf(__value), (short) 0));
    }
    return __result;
}
Also used : Comma(edu.illinois.cs.cogcomp.comma.datastructures.Comma)

Example 23 with Comma

use of edu.illinois.cs.cogcomp.comma.datastructures.Comma in project cogcomp-nlp by CogComp.

the class SRLFeature method classify.

public FeatureVector classify(Object __example) {
    if (!(__example instanceof Comma)) {
        String type = __example == null ? "null" : __example.getClass().getName();
        System.err.println("Classifier 'SRLFeature(Comma)' defined on line 66 of CommaClassifier.lbj received '" + type + "' as input.");
        new Exception().printStackTrace();
        System.exit(1);
    }
    Comma c = (Comma) __example;
    FeatureVector __result;
    __result = new FeatureVector();
    String __id;
    String __value;
    List SRLs = c.getContainingSRLs();
    for (int i = 0; i < SRLs.size(); i++) {
        String s = (String) SRLs.get(i);
        __id = "" + (s);
        __value = "true";
        __result.addFeature(new DiscretePrimitiveStringFeature(this.containingPackage, this.name, __id, __value, valueIndexOf(__value), (short) 0));
    }
    return __result;
}
Also used : Comma(edu.illinois.cs.cogcomp.comma.datastructures.Comma) List(java.util.List)

Example 24 with Comma

use of edu.illinois.cs.cogcomp.comma.datastructures.Comma in project cogcomp-nlp by CogComp.

the class UnigramRightFeature method discreteValue.

public String discreteValue(Object __example) {
    if (!(__example instanceof Comma)) {
        String type = __example == null ? "null" : __example.getClass().getName();
        System.err.println("Classifier 'UnigramRightFeature(Comma)' defined on line 14 of CommaClassifier.lbj received '" + type + "' as input.");
        new Exception().printStackTrace();
        System.exit(1);
    }
    Comma c = (Comma) __example;
    return "" + (c.getWordToRight(1));
}
Also used : Comma(edu.illinois.cs.cogcomp.comma.datastructures.Comma)

Example 25 with Comma

use of edu.illinois.cs.cogcomp.comma.datastructures.Comma in project cogcomp-nlp by CogComp.

the class listCommas method discreteValue.

public String discreteValue(Object __example) {
    if (!(__example instanceof CommaSRLSentence)) {
        String type = __example == null ? "null" : __example.getClass().getName();
        System.err.println("Constraint 'listCommas(CommaSRLSentence)' defined on line 244 of CommaClassifier.lbj received '" + type + "' as input.");
        new Exception().printStackTrace();
        System.exit(1);
    }
    CommaSRLSentence s = (CommaSRLSentence) __example;
    {
        boolean LBJava$constraint$result$0;
        {
            LBJava$constraint$result$0 = true;
            for (java.util.Iterator __I0 = (s.getMiddleSiblingCommas()).iterator(); __I0.hasNext() && LBJava$constraint$result$0; ) {
                Comma c = (Comma) __I0.next();
                {
                    boolean LBJava$constraint$result$1;
                    {
                        boolean LBJava$constraint$result$2;
                        LBJava$constraint$result$2 = ("" + (__LocalCommaClassifier.discreteValue(s.getPreviousSiblingComma(c)))).equals("" + ("List"));
                        if (LBJava$constraint$result$2)
                            LBJava$constraint$result$1 = ("" + (__LocalCommaClassifier.discreteValue(s.getNextSiblingComma(c)))).equals("" + ("List"));
                        else
                            LBJava$constraint$result$1 = false;
                    }
                    if (LBJava$constraint$result$1)
                        LBJava$constraint$result$0 = ("" + (__LocalCommaClassifier.discreteValue(c))).equals("" + ("List"));
                    else
                        LBJava$constraint$result$0 = true;
                }
            }
        }
        if (!LBJava$constraint$result$0)
            return "false";
    }
    return "true";
}
Also used : Comma(edu.illinois.cs.cogcomp.comma.datastructures.Comma) CommaSRLSentence(edu.illinois.cs.cogcomp.comma.datastructures.CommaSRLSentence)

Aggregations

Comma (edu.illinois.cs.cogcomp.comma.datastructures.Comma)35 CommaSRLSentence (edu.illinois.cs.cogcomp.comma.datastructures.CommaSRLSentence)18 AnnotatorException (edu.illinois.cs.cogcomp.annotation.AnnotatorException)1 EvaluateDiscrete (edu.illinois.cs.cogcomp.comma.utils.EvaluateDiscrete)1 Constituent (edu.illinois.cs.cogcomp.core.datastructures.textannotation.Constituent)1 PredicateArgumentView (edu.illinois.cs.cogcomp.core.datastructures.textannotation.PredicateArgumentView)1 Relation (edu.illinois.cs.cogcomp.core.datastructures.textannotation.Relation)1 SpanLabelView (edu.illinois.cs.cogcomp.core.datastructures.textannotation.SpanLabelView)1 TextAnnotation (edu.illinois.cs.cogcomp.core.datastructures.textannotation.TextAnnotation)1 TokenLabelView (edu.illinois.cs.cogcomp.core.datastructures.textannotation.TokenLabelView)1 TreeView (edu.illinois.cs.cogcomp.core.datastructures.textannotation.TreeView)1 ArrayList (java.util.ArrayList)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1