Search in sources :

Example 11 with FeatureVector

use of edu.illinois.cs.cogcomp.lbjava.classify.FeatureVector in project cogcomp-nlp by CogComp.

the class POSTaggerUnknown$$1 method classify.

public FeatureVector classify(Object __example) {
    FeatureVector __result;
    __result = new FeatureVector();
    __result.addFeature(__wordForm.featureValue(__example));
    __result.addFeature(__baselineTarget.featureValue(__example));
    __result.addFeature(__labelTwoBeforeU.featureValue(__example));
    __result.addFeature(__labelOneBeforeU.featureValue(__example));
    __result.addFeature(__labelOneAfterU.featureValue(__example));
    __result.addFeature(__labelTwoAfterU.featureValue(__example));
    __result.addFeature(__L2bL1bU.featureValue(__example));
    __result.addFeature(__L1bL1aU.featureValue(__example));
    __result.addFeature(__L1aL2aU.featureValue(__example));
    __result.addFeatures(__suffixFeatures.classify(__example));
    return __result;
}
Also used : FeatureVector(edu.illinois.cs.cogcomp.lbjava.classify.FeatureVector)

Example 12 with FeatureVector

use of edu.illinois.cs.cogcomp.lbjava.classify.FeatureVector in project cogcomp-nlp by CogComp.

the class Formpp method classify.

public FeatureVector classify(Object __example) {
    Token word = (Token) __example;
    FeatureVector __result;
    __result = new FeatureVector();
    String __id;
    String __value;
    int before = 2;
    int after = 2;
    int k = 2;
    int i;
    Token w = word, last = word;
    for (i = 0; i <= after && last != null; ++i) {
        last = (Token) last.next;
    }
    for (i = 0; i > -before && w.previous != null; --i) {
        w = (Token) w.previous;
    }
    String[] forms = new String[before + after + 1];
    i = 0;
    for (; w != last; w = (Token) w.next) {
        forms[i++] = word.form;
    }
    for (int j = 0; j < k; j++) {
        for (i = 0; i < forms.length; i++) {
            StringBuilder f = new StringBuilder();
            for (int context = 0; context <= j && i + context < forms.length; context++) {
                if (context != 0) {
                    f.append("_");
                }
                f.append(forms[i + context]);
            }
            __id = "" + (i + "_" + j);
            __value = "" + (f.toString());
            __result.addFeature(new DiscretePrimitiveStringFeature(this.containingPackage, this.name, __id, __value, valueIndexOf(__value), (short) 0));
        }
    }
    return __result;
}
Also used : FeatureVector(edu.illinois.cs.cogcomp.lbjava.classify.FeatureVector) DiscretePrimitiveStringFeature(edu.illinois.cs.cogcomp.lbjava.classify.DiscretePrimitiveStringFeature) Token(edu.illinois.cs.cogcomp.lbjava.nlp.seg.Token)

Example 13 with FeatureVector

use of edu.illinois.cs.cogcomp.lbjava.classify.FeatureVector in project cogcomp-nlp by CogComp.

the class Mixed method classify.

public FeatureVector classify(Object __example) {
    Token word = (Token) __example;
    FeatureVector __result;
    __result = new FeatureVector();
    String __id;
    String __value;
    int before = 2;
    int after = 2;
    int k = 2;
    int i;
    Token w = word, last = word;
    for (i = 0; i <= after && last != null; ++i) {
        last = (Token) last.next;
    }
    for (i = 0; i > -before && w.previous != null; --i) {
        w = (Token) w.previous;
    }
    String[] tags = new String[before + after + 1];
    String[] forms = new String[before + after + 1];
    i = 0;
    for (; w != last; w = (Token) w.next) {
        tags[i] = __POSTagger.discreteValue(w);
        forms[i] = w.form;
        i++;
    }
    for (int j = 1; j < k; j++) {
        for (int x = 0; x < 2; x++) {
            boolean t = true;
            for (i = 0; i < tags.length; i++) {
                StringBuilder f = new StringBuilder();
                for (int context = 0; context <= j && i + context < tags.length; context++) {
                    if (context != 0) {
                        f.append("_");
                    }
                    if (t && x == 0) {
                        f.append(tags[i + context]);
                    } else {
                        f.append(forms[i + context]);
                    }
                    t = !t;
                }
                __id = "" + (i + "_" + j);
                __value = "" + (f.toString());
                __result.addFeature(new DiscretePrimitiveStringFeature(this.containingPackage, this.name, __id, __value, valueIndexOf(__value), (short) 0));
            }
        }
    }
    return __result;
}
Also used : FeatureVector(edu.illinois.cs.cogcomp.lbjava.classify.FeatureVector) DiscretePrimitiveStringFeature(edu.illinois.cs.cogcomp.lbjava.classify.DiscretePrimitiveStringFeature) Token(edu.illinois.cs.cogcomp.lbjava.nlp.seg.Token)

Example 14 with FeatureVector

use of edu.illinois.cs.cogcomp.lbjava.classify.FeatureVector in project cogcomp-nlp by CogComp.

the class POSWindowpp method classify.

public FeatureVector classify(Object __example) {
    Token word = (Token) __example;
    FeatureVector __result;
    __result = new FeatureVector();
    String __id;
    String __value;
    int before = 3;
    int after = 3;
    int k = 3;
    int i;
    Token w = word, last = word;
    for (i = 0; i <= after && last != null; ++i) {
        last = (Token) last.next;
    }
    for (i = 0; i > -before && w.previous != null; --i) {
        w = (Token) w.previous;
    }
    String[] tags = new String[before + after + 1];
    i = 0;
    for (; w != last; w = (Token) w.next) {
        tags[i++] = __POSTagger.discreteValue(w);
    }
    for (int j = 0; j < k; j++) {
        for (i = 0; i < tags.length; i++) {
            StringBuilder f = new StringBuilder();
            for (int context = 0; context <= j && i + context < tags.length; context++) {
                if (context != 0) {
                    f.append("_");
                }
                f.append(tags[i + context]);
            }
            __id = "" + (i + "_" + j);
            __value = "" + (f.toString());
            __result.addFeature(new DiscretePrimitiveStringFeature(this.containingPackage, this.name, __id, __value, valueIndexOf(__value), (short) 0));
        }
    }
    return __result;
}
Also used : FeatureVector(edu.illinois.cs.cogcomp.lbjava.classify.FeatureVector) DiscretePrimitiveStringFeature(edu.illinois.cs.cogcomp.lbjava.classify.DiscretePrimitiveStringFeature) Token(edu.illinois.cs.cogcomp.lbjava.nlp.seg.Token)

Example 15 with FeatureVector

use of edu.illinois.cs.cogcomp.lbjava.classify.FeatureVector in project cogcomp-nlp by CogComp.

the class Capitalization method classify.

public FeatureVector classify(Object __example) {
    if (!(__example instanceof Word)) {
        String type = __example == null ? "null" : __example.getClass().getName();
        logger.error("Classifier 'Capitalization(Word)' defined on line 45 of CommonFeatures.lbj received '" + type + "' as input.");
        new Exception().printStackTrace();
        System.exit(1);
    }
    Word word = (Word) __example;
    FeatureVector __result;
    __result = new FeatureVector();
    String __id;
    String __value;
    int i;
    Word w = word, last = word;
    for (i = 0; i <= 2 && last != null; ++i) {
        last = (Word) last.next;
    }
    for (i = 0; i > -2 && w.previous != null; --i) {
        w = (Word) w.previous;
    }
    for (; w != last; w = (Word) w.next) {
        __id = "" + (i++);
        __value = "" + (w.capitalized);
        __result.addFeature(new DiscretePrimitiveStringFeature(this.containingPackage, this.name, __id, __value, valueIndexOf(__value), (short) 2));
    }
    return __result;
}
Also used : FeatureVector(edu.illinois.cs.cogcomp.lbjava.classify.FeatureVector) DiscretePrimitiveStringFeature(edu.illinois.cs.cogcomp.lbjava.classify.DiscretePrimitiveStringFeature)

Aggregations

FeatureVector (edu.illinois.cs.cogcomp.lbjava.classify.FeatureVector)17 DiscretePrimitiveStringFeature (edu.illinois.cs.cogcomp.lbjava.classify.DiscretePrimitiveStringFeature)9 Token (edu.illinois.cs.cogcomp.lbjava.nlp.seg.Token)5 Constituent (edu.illinois.cs.cogcomp.core.datastructures.textannotation.Constituent)3 EdisonException (edu.illinois.cs.cogcomp.edison.utilities.EdisonException)3 LinkedVector (edu.illinois.cs.cogcomp.lbjava.parse.LinkedVector)1 Parser (edu.illinois.cs.cogcomp.lbjava.parse.Parser)1 OutFile (edu.illinois.cs.cogcomp.ner.IO.OutFile)1 EOFException (java.io.EOFException)1 File (java.io.File)1 Vector (java.util.Vector)1 Test (org.junit.Test)1