Search in sources :

Example 1 with FeatureVector

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

the class PreviousTags method classify.

public FeatureVector classify(Object __example) {
    Token word = (Token) __example;
    FeatureVector __result;
    __result = new FeatureVector();
    String __id;
    String __value;
    int i;
    Token w = word;
    for (i = 0; i > -2 && w.previous != null; --i) {
        w = (Token) w.previous;
    }
    for (; w != word; w = (Token) w.next) {
        if (Chunker.isTraining) {
            __id = "" + (i++);
            __value = w.label;
            __result.addFeature(new DiscretePrimitiveStringFeature(this.containingPackage, this.name, __id, __value, valueIndexOf(__value), (short) 0));
        } else {
            __id = "" + (i++);
            __value = __Chunker.discreteValue(w);
            __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 2 with FeatureVector

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

the class SOPrevious method classify.

public FeatureVector classify(Object __example) {
    Token word = (Token) __example;
    FeatureVector __result;
    __result = new FeatureVector();
    String __id;
    String __value;
    int i;
    Token w = word;
    for (i = 0; i > -2 && w.previous != null; --i) {
        w = (Token) w.previous;
    }
    String[] tags = new String[3];
    String[] labels = new String[2];
    i = 0;
    for (; w != word; w = (Token) w.next) {
        tags[i] = __POSTagger.discreteValue(w);
        if (Chunker.isTraining) {
            labels[i] = w.label;
        } else {
            labels[i] = __Chunker.discreteValue(w);
        }
        i++;
    }
    tags[i] = __POSTagger.discreteValue(w);
    __id = "ll";
    __value = "" + (labels[0] + "_" + labels[1]);
    __result.addFeature(new DiscretePrimitiveStringFeature(this.containingPackage, this.name, __id, __value, valueIndexOf(__value), (short) 0));
    __id = "lt1";
    __value = "" + (labels[0] + "_" + tags[1]);
    __result.addFeature(new DiscretePrimitiveStringFeature(this.containingPackage, this.name, __id, __value, valueIndexOf(__value), (short) 0));
    __id = "lt2";
    __value = "" + (labels[1] + "_" + tags[2]);
    __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 3 with FeatureVector

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

the class Chunker$$1 method classify.

public FeatureVector classify(Object __example) {
    FeatureVector __result;
    __result = new FeatureVector();
    __result.addFeatures(__Forms.classify(__example));
    __result.addFeatures(__Capitalization.classify(__example));
    __result.addFeatures(__WordTypeInformation.classify(__example));
    __result.addFeatures(__Affixes.classify(__example));
    __result.addFeatures(__PreviousTags.classify(__example));
    __result.addFeatures(__POSWindow.classify(__example));
    __result.addFeatures(__Mixed.classify(__example));
    __result.addFeatures(__POSWindowpp.classify(__example));
    __result.addFeatures(__Formpp.classify(__example));
    __result.addFeatures(__SOPrevious.classify(__example));
    return __result;
}
Also used : FeatureVector(edu.illinois.cs.cogcomp.lbjava.classify.FeatureVector)

Example 4 with FeatureVector

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

the class LBJavaFeatureExtractor method classify.

@Override
public FeatureVector classify(Object o) {
    // Make sure the object is a Constituent
    if (!(o instanceof Constituent))
        throw new IllegalArgumentException("Instance must be of type Constituent");
    Constituent instance = (Constituent) o;
    FeatureVector featureVector = new FeatureVector();
    try {
        featureVector = FeatureUtilities.getLBJFeatures(getFeatures(instance));
    } catch (Exception e) {
        logger.debug("Couldn't generate feature {} for constituent {}", getName(), instance);
    }
    return featureVector;
}
Also used : FeatureVector(edu.illinois.cs.cogcomp.lbjava.classify.FeatureVector) Constituent(edu.illinois.cs.cogcomp.core.datastructures.textannotation.Constituent) EdisonException(edu.illinois.cs.cogcomp.edison.utilities.EdisonException)

Example 5 with FeatureVector

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

the class Affixes method classify.

public FeatureVector classify(Object __example) {
    if (!(__example instanceof Word)) {
        String type = __example == null ? "null" : __example.getClass().getName();
        System.err.println("Classifier 'Affixes(Word)' defined on line 107 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 N = word.form.length();
    for (int i = 3; i <= 4; ++i) {
        if (word.form.length() > i) {
            __id = "p|";
            __value = "" + (word.form.substring(0, i));
            __result.addFeature(new DiscretePrimitiveStringFeature(this.containingPackage, this.name, __id, __value, valueIndexOf(__value), (short) 0));
        }
    }
    for (int i = 1; i <= 4; ++i) {
        if (word.form.length() > i) {
            __id = "s|";
            __value = "" + (word.form.substring(N - i));
            __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)

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