use of edu.illinois.cs.cogcomp.lbjava.classify.FeatureVector in project cogcomp-nlp by CogComp.
the class AffixesTest method testClassify.
@Test
public void testClassify() {
FeatureVector result = affixesClassifier.classify(testWord);
assertTrue(result != null);
String[] resultArray = result.discreteValueArray();
assertEquals("tion", resultArray[5]);
}
use of edu.illinois.cs.cogcomp.lbjava.classify.FeatureVector in project cogcomp-nlp by CogComp.
the class WordTypeInformation method classify.
public FeatureVector classify(Object __example) {
if (!(__example instanceof Word)) {
String type = __example == null ? "null" : __example.getClass().getName();
logger.error("Classifier 'WordTypeInformation(Word)' defined on line 71 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, ++i) {
boolean allCapitalized = true, allDigits = true, allNonLetters = true;
for (int j = 0; j < w.form.length(); ++j) {
allCapitalized &= Character.isUpperCase(w.form.charAt(j));
allDigits &= Character.isDigit(w.form.charAt(j));
allNonLetters &= !Character.isLetter(w.form.charAt(j));
}
__id = "" + ("c" + i);
__value = "" + (allCapitalized);
__result.addFeature(new DiscretePrimitiveStringFeature(this.containingPackage, this.name, __id, __value, valueIndexOf(__value), (short) 2));
__id = "" + ("d" + i);
__value = "" + (allDigits);
__result.addFeature(new DiscretePrimitiveStringFeature(this.containingPackage, this.name, __id, __value, valueIndexOf(__value), (short) 2));
__id = "" + ("p" + i);
__value = "" + (allNonLetters);
__result.addFeature(new DiscretePrimitiveStringFeature(this.containingPackage, this.name, __id, __value, valueIndexOf(__value), (short) 2));
}
return __result;
}
Aggregations