// Modifying this comment will cause the next execution of LBJ2 to overwrite this file.
// F1B88000000000000000D5D81CA02C030144F756C385A526A88743D874F71C3B8D80B0D62294A6509EFBBB94B854F2B03B333F6A5A073F62A9D2ECEC7F1ACB83FD264E351A198738C64092CCF68EC6DE0DD534C5482CDD97494C27FA048643E082A8932B1D0B347D928014513D69E5E59A2BAADA9754589EF82728CC491BE7873F42734859525666D8B286D4D794A8D7E64A905FB1D4389AF1C8D0604240E8CF5E25F9AC3D706E5402BE11100000
package LBJ2.nlp;
import LBJ2.classify.*;
import LBJ2.infer.*;
import LBJ2.jni.*;
import LBJ2.learn.*;
import LBJ2.parse.*;
/**
* This class implements a classifier that takes a {@link Word} as input and
* generates features representing the forms of the words in a [-2, +2]
* window around the input word. The generated features consist of the
* {@link Word#form} of the input word as well as the forms of the two words
* before the input word in the sentence and the forms of the two words after
* the input word in the sentence. If any of those words do not exist, the
* corresponding feature isn't generated.
*
* <p> This class's implementation was automatically generated by the LBJ
* compiler.
*
* @author Nick Rizzolo
**/
public class Forms extends Classifier
{
public Forms()
{
containingPackage = "LBJ2.nlp";
name = "Forms";
}
public String getInputType() { return "LBJ2.nlp.Word"; }
public String getOutputType() { return "discrete%"; }
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;
}
public FeatureVector[] classify(Object[] examples)
{
if (!(examples instanceof Word[]))
{
String type = examples == null ? "null" : examples.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);
}
return super.classify(examples);
}
public int hashCode() { return "Forms".hashCode(); }
public boolean equals(Object o) { return o instanceof Forms; }
}