use of edu.illinois.cs.cogcomp.lbjava.classify.DiscretePrimitiveStringFeature 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;
}
use of edu.illinois.cs.cogcomp.lbjava.classify.DiscretePrimitiveStringFeature 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;
}
use of edu.illinois.cs.cogcomp.lbjava.classify.DiscretePrimitiveStringFeature 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;
}
use of edu.illinois.cs.cogcomp.lbjava.classify.DiscretePrimitiveStringFeature in project cogcomp-nlp by CogComp.
the class Forms method classify.
public FeatureVector classify(Object __example) {
if (!(__example instanceof Word)) {
String type = __example == null ? "null" : __example.getClass().getName();
System.err.println("Classifier 'Forms(Word)' defined on line 20 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.form);
__result.addFeature(new DiscretePrimitiveStringFeature(this.containingPackage, this.name, __id, __value, valueIndexOf(__value), (short) 0));
}
return __result;
}
use of edu.illinois.cs.cogcomp.lbjava.classify.DiscretePrimitiveStringFeature in project cogcomp-nlp by CogComp.
the class POSTaggerUnknown 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, __MikheevTable.allowableTags(w));
w.partOfSpeech = __result.getStringValue();
return __result;
}
Aggregations