Search in sources :

Example 11 with DiscretePrimitiveStringFeature

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

the class POSTaggerKnown method cachedFeatureValue.

private Feature cachedFeatureValue(Object __example) {
    Token w = (Token) __example;
    String __cachedValue = w.partOfSpeech;
    if (__cachedValue != null) {
        return new DiscretePrimitiveStringFeature(containingPackage, name, "", __cachedValue, valueIndexOf(__cachedValue), (short) allowableValues().length);
    }
    Feature __result;
    __result = valueOf(w, baselineTarget.allowableTags(wordForm.discreteValue(w)));
    w.partOfSpeech = __result.getStringValue();
    return __result;
}
Also used : DiscretePrimitiveStringFeature(edu.illinois.cs.cogcomp.lbjava.classify.DiscretePrimitiveStringFeature) Token(edu.illinois.cs.cogcomp.lbjava.nlp.seg.Token) Feature(edu.illinois.cs.cogcomp.lbjava.classify.Feature) DiscretePrimitiveStringFeature(edu.illinois.cs.cogcomp.lbjava.classify.DiscretePrimitiveStringFeature)

Example 12 with DiscretePrimitiveStringFeature

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

the class labelOrBaseline method cachedFeatureValue.

private Feature cachedFeatureValue(Object __example) {
    if (__example == __exampleCache.get())
        return (Feature) __cache.get();
    __exampleCache.set(__example);
    String __cachedValue = _discreteValue(__example);
    Feature __result = new DiscretePrimitiveStringFeature(containingPackage, name, "", __cachedValue, valueIndexOf(__cachedValue), (short) allowableValues().length);
    __cache.set(__result);
    return __result;
}
Also used : DiscretePrimitiveStringFeature(edu.illinois.cs.cogcomp.lbjava.classify.DiscretePrimitiveStringFeature) Feature(edu.illinois.cs.cogcomp.lbjava.classify.Feature) DiscretePrimitiveStringFeature(edu.illinois.cs.cogcomp.lbjava.classify.DiscretePrimitiveStringFeature)

Example 13 with DiscretePrimitiveStringFeature

use of edu.illinois.cs.cogcomp.lbjava.classify.DiscretePrimitiveStringFeature 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 14 with DiscretePrimitiveStringFeature

use of edu.illinois.cs.cogcomp.lbjava.classify.DiscretePrimitiveStringFeature 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 15 with DiscretePrimitiveStringFeature

use of edu.illinois.cs.cogcomp.lbjava.classify.DiscretePrimitiveStringFeature 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)

Aggregations

DiscretePrimitiveStringFeature (edu.illinois.cs.cogcomp.lbjava.classify.DiscretePrimitiveStringFeature)18 Feature (edu.illinois.cs.cogcomp.lbjava.classify.Feature)9 FeatureVector (edu.illinois.cs.cogcomp.lbjava.classify.FeatureVector)9 Token (edu.illinois.cs.cogcomp.lbjava.nlp.seg.Token)8