|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.ObjectLBJ2.classify.Feature
LBJ2.classify.RealFeature
LBJ2.classify.RealPrimitiveFeature
public class RealPrimitiveFeature
A real feature takes on any value representable by a double.
| Field Summary | |
|---|---|
protected ByteString |
identifier
The identifier string distinguishes this
Feature from other Features. |
protected double |
value
The real value is represented as a double. |
| Fields inherited from class LBJ2.classify.Feature |
|---|
containingPackage, generatingClassifier |
| Constructor Summary | |
|---|---|
protected |
RealPrimitiveFeature()
For internal use only. |
|
RealPrimitiveFeature(java.lang.String p,
java.lang.String c,
ByteString i,
double v)
Sets both the identifier and the value. |
| Method Summary | |
|---|---|
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. |
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. |
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 RealPrimitiveFeatures are equivalent when their
containing packages and identifiers are equivalent and their values are
equal. |
ByteString |
getByteStringIdentifier()
Retrieves this feature's identifier as a byte string. |
Feature |
getFeatureKey(Lexicon lexicon,
boolean training,
int label)
Return the feature that should be used to index this feature into a lexicon. |
double |
getStrength()
Simply returns the value of value. |
java.lang.String |
getStringIdentifier()
Retrieves this feature's identifier as a string. |
boolean |
hasByteStringIdentifier()
Determines if this feature contains a byte string identifier field. |
int |
hashCode()
The hash code of a RealPrimitiveFeature is the sum of the
hash codes of the containing package, the identifier, and the value. |
boolean |
isPrimitive()
Determines if this feature is primitive. |
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. |
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. |
RealFeature |
multiply(double m)
Returns a new feature object, the same as this one in all respects except the value field has been multiplied by the specified
number. |
void |
read(ExceptionlessInputStream in)
Reads the representation of a feaeture with this object's run-time type from the given stream, overwriting the data in this object. |
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. |
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 identifier information to the specified
buffer. |
| Methods inherited from class LBJ2.classify.RealFeature |
|---|
conjunction, getByteStringValue, getStringValue, isDiscrete, makeReal, valueEquals |
| Methods inherited from class LBJ2.classify.Feature |
|---|
childLexiconLookup, clone, compareNameStrings, conjunctWith, conjunctWith, depth, fromArray, getFeatureKey, getGeneratingClassifier, getPackage, getValueIndex, hasStringIdentifier, isConjunctive, isReferrer, lexReadFeature, readFeature, removeFromChildLexicon, setArrayLength, toString, toStringNoPackage, totalValues, writeNoPackage |
| Methods inherited from class java.lang.Object |
|---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected ByteString identifier
identifier string distinguishes this
Feature from other Features.
protected double value
| Constructor Detail |
|---|
protected RealPrimitiveFeature()
Feature.readFeature(ExceptionlessInputStream)
public RealPrimitiveFeature(java.lang.String p,
java.lang.String c,
ByteString i,
double v)
p - The new real feature's package.c - The name of the classifier that produced this feature.i - The new RealPrimitiveFeature's identifier.v - The new RealPrimitiveFeature's value.| Method Detail |
|---|
public boolean hasByteStringIdentifier()
hasByteStringIdentifier in class Featuretrue iff this feature contains a byte string
identifier field.public boolean isPrimitive()
isPrimitive in class Featuretrue iff this is primitive.public java.lang.String getStringIdentifier()
getStringIdentifier in class Featurepublic ByteString getByteStringIdentifier()
getByteStringIdentifier in class Featurepublic double getStrength()
value.
getStrength in class Feature
public Feature getFeatureKey(Lexicon lexicon,
boolean training,
int label)
getFeatureKey in class Featurelexicon - 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 RealFeature multiply(double m)
value field has been multiplied by the specified
number.
multiply in class RealFeaturem - The multiplier.
public Feature withStrength(double s)
s.
withStrength in class Features - The strength of the new feature.
null if this
feature cannot take the specified strength.public Feature encode(java.lang.String e)
encode in class Featuree - The encoding to use.
public int hashCode()
RealPrimitiveFeature is the sum of the
hash codes of the containing package, the identifier, and the value.
hashCode in class Featurepublic boolean equals(java.lang.Object o)
RealPrimitiveFeatures are equivalent when their
containing packages and identifiers are equivalent and their values are
equal.
equals in class Featureo - The object with which to compare this feature.
true iff the parameter 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.
classEquivalent in class Featuref - Another feature.
public int compareTo(java.lang.Object o)
compareTo in interface java.lang.ComparablecompareTo in class Featureo - An object to compare with.
public void write(java.lang.StringBuffer buffer)
Feature to the
specified buffer.
write in class Featurebuffer - The buffer to write to.public void writeNameString(java.lang.StringBuffer buffer)
Feature's package,
generating classifier, and identifier information to the specified
buffer.
writeNameString in class Featurebuffer - The buffer to write to.public void write(ExceptionlessOutputStream out)
write in class Featureout - The output stream.public void read(ExceptionlessInputStream in)
read in class Featurein - The input stream.
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)
lexWrite in class Featureout - 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 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).
lexRead in class Featurein - 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.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||