|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.ObjectLBJ2.classify.Feature
public abstract class Feature
Objects of this class represent the value of a Classifier's
decision.
| Field Summary | |
|---|---|
protected java.lang.String |
containingPackage
The Java package containing the classifier that produced
this feature. |
protected java.lang.String |
generatingClassifier
The name of the LBJ classifier that produced this feature. |
| Constructor Summary | |
|---|---|
protected |
Feature()
For internal use only. |
|
Feature(java.lang.String p,
java.lang.String c)
Initializing constructor. |
| Method Summary | |
|---|---|
int |
childLexiconLookup(ChildLexicon lex,
int label)
Does a feature-type-specific lookup of this feature in the given ChildLexicon. |
boolean |
classEquivalent(Feature f)
Some features are functionally equivalent, differing only in the encoding of their values; this method will return true iff
the class of this feature and f are different, but they
differ only because they encode their values differently. |
java.lang.Object |
clone()
Returns a shallow clone of this Feature. |
int |
compareNameStrings(java.lang.Object o)
Compares only the run-time types, packages, classifier names, and identifiers of the features. |
abstract int |
compareTo(java.lang.Object o)
Used to sort features into an order that is convenient both to page through and for the lexicon to read off disk. |
private int |
compareTypes(java.lang.Object o)
Compares only the run-time types of the features. |
abstract Feature |
conjunction(Feature f,
Classifier c)
Create a feature representing the conjunction of this feature with the given argument feature. |
protected Feature |
conjunctWith(DiscreteFeature f,
Classifier c)
Create a feature representing the conjunction of this feature with the given argument feature. |
protected Feature |
conjunctWith(RealFeature f,
Classifier c)
Create a feature representing the conjunction of this feature with the given argument feature. |
int |
depth()
The depth of a feature is one more than the maximum depth of any of its children, or 0 if it has no children. |
abstract Feature |
encode(java.lang.String e)
Returns a feature object in which any strings that are being used to represent an identifier or value have been encoded in byte strings. |
boolean |
equals(java.lang.Object o)
Two Features are equal when their packages and generating
classifiers are equivalent. |
boolean |
fromArray()
Determines if this feature comes from an array. |
abstract ByteString |
getByteStringIdentifier()
Retrieves this feature's identifier as a byte string. |
abstract ByteString |
getByteStringValue()
Gives a string representation of the value of this feature. |
Feature |
getFeatureKey(Lexicon lexicon)
Return the feature that should be used to index this feature into a lexicon. |
abstract Feature |
getFeatureKey(Lexicon lexicon,
boolean training,
int label)
Return the feature that should be used to index this feature into a lexicon. |
java.lang.String |
getGeneratingClassifier()
Retrieves the name of the classifier that produced this feature. |
java.lang.String |
getPackage()
Retrieves this feature's package. |
abstract double |
getStrength()
Returns the strength of this feature if it were to be placed in a mathematical vector space. |
abstract java.lang.String |
getStringIdentifier()
Retrieves this feature's identifier as a string. |
abstract java.lang.String |
getStringValue()
Gives a string representation of the value of this feature. |
short |
getValueIndex()
Returns the index in the generating classifier's value list of this feature's value. |
boolean |
hasByteStringIdentifier()
Determines if this feature contains a byte string identifier field. |
int |
hashCode()
The hash code of a Feature is a function of the hash codes
of containingPackage and generatingClassifier. |
boolean |
hasStringIdentifier()
Determines if this feature contains a string identifier field. |
boolean |
isConjunctive()
Determines if this feature is conjunctive. |
abstract boolean |
isDiscrete()
Determines if this feature is discrete. |
boolean |
isPrimitive()
Determines if this feature is primitive. |
boolean |
isReferrer()
Determines if this feature is a referring feature. |
void |
lexRead(ExceptionlessInputStream in,
Lexicon lex,
java.lang.String p,
java.lang.String g,
java.lang.String si,
ByteString bi)
Reads the representation of a feature with this object's run-time type as stored by a lexicon, overwriting the data in this object. |
static Feature |
lexReadFeature(ExceptionlessInputStream in,
Lexicon lex,
java.lang.Class c,
java.lang.String p,
java.lang.String g,
java.lang.String si,
ByteString bi)
Reads the representation of a feature of any type as stored by a lexicon, omitting redundant information. |
java.lang.String |
lexWrite(ExceptionlessOutputStream out,
Lexicon lex,
java.lang.String c,
java.lang.String p,
java.lang.String g,
java.lang.String si,
ByteString bi)
Writes a binary representation of the feature intended for use by a lexicon, omitting redundant information when possible. |
abstract RealFeature |
makeReal()
Returns a RealFeature whose value is the strength of the current
feature, and whose identifier field contains all the
information necessary to distinguish this feature from other features. |
void |
read(ExceptionlessInputStream in)
Reads the representation of a feature with this object's run-time type from the given stream, overwriting the data in this object. |
static Feature |
readFeature(ExceptionlessInputStream in)
Reads the binary representation of a feature of any type from the given stream. |
private void |
readObject(java.io.ObjectInputStream in)
Special handling during deserialization to ensure that Strings are intern()ed. |
void |
removeFromChildLexicon(ChildLexicon lex)
Takes care of any feature-type-specific tasks that need to be taken care of when removing a feature of this type from a ChildLexicon, in
particular updating parent counts and removing children of this feature
if necessary. |
void |
setArrayLength(int l)
If this feature is an array feature, call this method to set its array length; otherwise, this method has no effect. |
java.lang.String |
toString()
Returns a string representation of this Feature. |
java.lang.String |
toStringNoPackage()
Returns a string representation of this Feature omitting
the package. |
short |
totalValues()
Returns the total number of values this feature might possibly be set to. |
abstract boolean |
valueEquals(java.lang.String v)
Determines whether or not the parameter is equivalent to the string representation of the value of this feature. |
abstract Feature |
withStrength(double s)
Returns a new feature object that's identical to this feature except its strength is given by s. |
void |
write(ExceptionlessOutputStream out)
Writes a complete binary representation of the feature. |
abstract void |
write(java.lang.StringBuffer buffer)
Writes a string representation of this Feature to the
specified buffer. |
void |
writeNameString(java.lang.StringBuffer buffer)
Writes a string representation of this Feature's package,
generating classifier, and sometimes identifier information to the
specified buffer. |
void |
writeNoPackage(java.lang.StringBuffer buffer)
Writes a string representation of this Feature to the
specified buffer, omitting the package name. |
| Methods inherited from class java.lang.Object |
|---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected java.lang.String containingPackage
package containing the classifier that produced
this feature.
protected java.lang.String generatingClassifier
| Constructor Detail |
|---|
protected Feature()
readFeature(ExceptionlessInputStream)
public Feature(java.lang.String p,
java.lang.String c)
p - The package containing the classifier that produced this
feature.c - The name of the classifier that produced this feature.| Method Detail |
|---|
public java.lang.String getPackage()
public java.lang.String getGeneratingClassifier()
public abstract java.lang.String getStringIdentifier()
public abstract ByteString getByteStringIdentifier()
public abstract java.lang.String getStringValue()
public abstract ByteString getByteStringValue()
public abstract boolean valueEquals(java.lang.String v)
v - The string to compare against.
true iff the parameter is equivalent to the string
representation of the value of this feature.public abstract boolean isDiscrete()
true iff this is discrete.public boolean hasByteStringIdentifier()
true iff this feature contains a byte string
identifier field.public boolean hasStringIdentifier()
true iff this feature contains a string identifier
field.public boolean isPrimitive()
true iff this is primitive.public boolean isConjunctive()
true iff this feature is conjunctive.public boolean isReferrer()
true iff this feature is a referring feature.public boolean fromArray()
true iff this feature comes from an array.public int depth()
public short getValueIndex()
public short totalValues()
public void setArrayLength(int l)
l - The new length.public abstract double getStrength()
public Feature getFeatureKey(Lexicon lexicon)
getFeatureKey(lexicon, true,
-1).
lexicon - The lexicon into which this feature will be indexed.
getFeatureKey(Lexicon,boolean,int)
public abstract Feature getFeatureKey(Lexicon lexicon,
boolean training,
int label)
lexicon - The lexicon into which this feature will be indexed.training - Whether or not the learner is currently training.label - The label of the example containing this feature, or -1
if we aren't doing per class feature counting.
public abstract RealFeature makeReal()
RealFeature whose value is the strength of the current
feature, and whose identifier field contains all the
information necessary to distinguish this feature from other features.
When defining this method, RealFeatures may simply return
themselves.
public abstract Feature conjunction(Feature f,
Classifier c)
f - The feature to conjunct with.c - The classifier producing the resulting feature.
f.
protected Feature conjunctWith(DiscreteFeature f,
Classifier c)
f - The feature to conjunct with.c - The classifier producing the resulting feature.
f.
protected Feature conjunctWith(RealFeature f,
Classifier c)
f - The feature to conjunct with.c - The classifier producing the resulting feature.
f.public abstract Feature withStrength(double s)
s.
s - The strength of the new feature.
null if this
feature cannot take the specified strength.public abstract Feature encode(java.lang.String e)
e - The encoding to use.
public void removeFromChildLexicon(ChildLexicon lex)
ChildLexicon, in
particular updating parent counts and removing children of this feature
if necessary.
lex - The child lexicon this feature is being removed from.
public int childLexiconLookup(ChildLexicon lex,
int label)
ChildLexicon.
lex - The child lexicon this feature is being looked up in.label - The label of the example containing this feature, or -1 if
we aren't doing per class feature counting.
f in this lexicon.public int hashCode()
Feature is a function of the hash codes
of containingPackage and generatingClassifier.
hashCode in class java.lang.ObjectFeature.public boolean equals(java.lang.Object o)
Features are equal when their packages and generating
classifiers are equivalent.
equals in class java.lang.Objecttrue iff the argument is an equivalent
Feature.public boolean classEquivalent(Feature f)
true iff
the class of this feature and f are different, but they
differ only because they encode their values differently. This method
does not compare the values themselves, however.
f - Another feature.
public abstract int compareTo(java.lang.Object o)
compareTo in interface java.lang.Comparableo - An object to compare with.
public int compareNameStrings(java.lang.Object o)
o - An object to compare with.
private int compareTypes(java.lang.Object o)
o - An object to compare with.
public abstract void write(java.lang.StringBuffer buffer)
Feature to the
specified buffer.
buffer - The buffer to write to.public void writeNameString(java.lang.StringBuffer buffer)
Feature's package,
generating classifier, and sometimes identifier information to the
specified buffer. This method will need to be overridden to write the
identifier information, but at least the overriding method will have the
convenience of calling this method to accomplish most of the work first.
buffer - The buffer to write to.public void write(ExceptionlessOutputStream out)
out - The output stream.public void writeNoPackage(java.lang.StringBuffer buffer)
Feature to the
specified buffer, omitting the package name.
buffer - The buffer to write to.
public java.lang.String lexWrite(ExceptionlessOutputStream out,
Lexicon lex,
java.lang.String c,
java.lang.String p,
java.lang.String g,
java.lang.String si,
ByteString bi)
out - The output stream.lex - The lexicon out of which this feature is being written.c - The fully qualified name of the assumed class. The runtime
class of this feature won't be written if it's equivalent to
c.p - The assumed package string. This feature's package string
won't be written if it's equivalent to p.g - The assumed classifier name string. This feature's
classifier name string won't be written if it's equivalent
to g.si - The assumed identifier as a string. If this feature has a
string identifier, it won't be written if it's equivalent to
si.bi - The assumed identifier as a byte string. If this feature
has a byte string identifier, it won't be written if it's
equivalent to bi.
public static Feature readFeature(ExceptionlessInputStream in)
-1 appears instead, this method returns null.
This method is appropriate for reading features as written by
write(ExceptionlessOutputStream).
in - The input stream.
public void read(ExceptionlessInputStream in)
This method is appropriate for reading features as written by
write(ExceptionlessOutputStream).
in - The input stream.
public static Feature lexReadFeature(ExceptionlessInputStream in,
Lexicon lex,
java.lang.Class c,
java.lang.String p,
java.lang.String g,
java.lang.String si,
ByteString bi)
This method is appropriate for reading features as written by
lexWrite(ExceptionlessOutputStream,Lexicon,String,String,String,String,ByteString).
in - The input stream.lex - The lexicon we are reading in to.c - The assumed class. If no class name is given in the input
stream, a feature of this type is instantiated.p - The assumed package string. If no package name is given in
the input stream, the instantiated feature is given this
package.g - The assumed classifier name string. If no classifier name
is given in the input stream, the instantiated feature is
given this classifier name.si - The assumed identifier as a string. If the feature being
read has a string identifier field and no identifier is
given in the input stream, the feature is given this
identifier.bi - The assumed identifier as a byte string. If the feature
being read has a byte string identifier field and no
identifier is given in the input stream, the feature is
given this identifier.
public void lexRead(ExceptionlessInputStream in,
Lexicon lex,
java.lang.String p,
java.lang.String g,
java.lang.String si,
ByteString bi)
This method is appropriate for reading features as written by
lexWrite(ExceptionlessOutputStream,Lexicon,String,String,String,String,ByteString).
in - The input stream.lex - The lexicon we are reading in to.p - The assumed package string. If no package name is given in
the input stream, the instantiated feature is given this
package.g - The assumed classifier name string. If no classifier name
is given in the input stream, the instantiated feature is
given this classifier name.si - The assumed identifier as a string. If the feature being
read has a string identifier field and no identifier is
given in the input stream, the feature is given this
identifier.bi - The assumed identifier as a byte string. If the feature
being read has a byte string identifier field and no
identifier is given in the input stream, the feature is
given this identifier.public java.lang.String toString()
Feature.
toString in class java.lang.Objectpublic java.lang.String toStringNoPackage()
Feature omitting
the package.
public java.lang.Object clone()
Feature.
clone in class java.lang.Object
private void readObject(java.io.ObjectInputStream in)
throws java.io.IOException,
java.lang.ClassNotFoundException
Strings are intern()ed.
in - The stream to deserialize from.
java.io.IOException
java.lang.ClassNotFoundException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||