public class RealConjunctiveFeature extends RealFeature
Modifier and Type | Field and Description |
---|---|
protected Feature |
left
One feature argument.
|
protected Feature |
right
The other feature argument.
|
containingPackage, generatingClassifier
Constructor and Description |
---|
RealConjunctiveFeature()
For internal use only.
|
RealConjunctiveFeature(Classifier c,
Feature l,
Feature r)
Creates a new conjunctive feature taking the package and name of the given classifier.
|
RealConjunctiveFeature(String p,
String c,
Feature l,
Feature r)
Creates a new conjunctive feature.
|
Modifier and Type | Method and Description |
---|---|
int |
childLexiconLookup(ChildLexicon lex,
int label)
Does a feature-type-specific lookup of this feature in the given
ChildLexicon . |
int |
compareTo(Object o)
Used to sort features into an order that is convenient both to page through and for the
lexicon to read off disk.
|
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.
|
Feature |
encode(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(Object o)
Two conjunctions are equivalent when their arguments are equivalent.
|
protected Feature |
getArgumentKey(Feature f,
Lexicon lexicon,
boolean training,
int label)
A helper method for
getFeatureKey(Lexicon,boolean,int) , this method computes the
feature keys corresponding to the arguments of the conjunction. |
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.
|
Feature |
getLeft()
Returns the value of
left . |
Feature |
getRight()
Returns the value of
right . |
double |
getStrength()
Returns the strength of this feature if it were to be placed in a mathematical vector space.
|
String |
getStringIdentifier()
Retrieves this feature's identifier as a string.
|
int |
hashCode()
|
boolean |
isConjunctive()
Determines if this feature is conjunctive.
|
void |
lexRead(edu.illinois.cs.cogcomp.core.datastructures.vectors.ExceptionlessInputStream in,
Lexicon lex,
String p,
String g,
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.
|
String |
lexWrite(edu.illinois.cs.cogcomp.core.datastructures.vectors.ExceptionlessOutputStream out,
Lexicon lex,
String c,
String p,
String g,
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 has been
multiplied by the specified number.
|
void |
read(edu.illinois.cs.cogcomp.core.datastructures.vectors.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.
|
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. |
Feature |
withStrength(double s)
Returns a new feature object that's identical to this feature except its strength is given by
s . |
void |
write(edu.illinois.cs.cogcomp.core.datastructures.vectors.ExceptionlessOutputStream out)
Writes a complete binary representation of the feature.
|
void |
write(StringBuffer buffer)
Writes a string representation of this
Feature to the specified buffer. |
void |
writeNoPackage(StringBuffer buffer)
Writes a string representation of this
Feature to the specified buffer, omitting
the package name. |
conjunction, getByteStringValue, getStringValue, isDiscrete, makeReal, valueEquals
classEquivalent, clone, compareNameStrings, conjunctWith, conjunctWith, fromArray, getFeatureKey, getGeneratingClassifier, getPackage, getValueIndex, hasByteStringIdentifier, hasStringIdentifier, isPrimitive, isReferrer, lexReadFeature, readFeature, setArrayLength, toString, toStringNoPackage, totalValues, writeNameString
protected Feature left
protected Feature right
public RealConjunctiveFeature()
public RealConjunctiveFeature(Classifier c, Feature l, Feature r)
c
- The classifier from which package and name information is taken.l
- One feature argument.r
- The other feature argument.public boolean isConjunctive()
isConjunctive
in class Feature
true
iff this feature is conjunctive.public String getStringIdentifier()
getStringIdentifier
in class Feature
public ByteString getByteStringIdentifier()
getByteStringIdentifier
in class Feature
ByteString.emptyString
, since conjunctive features don't have identifiers.public int depth()
public double getStrength()
getStrength
in class Feature
public Feature getFeatureKey(Lexicon lexicon, boolean training, int label)
getFeatureKey
in class Feature
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.protected Feature getArgumentKey(Feature f, Lexicon lexicon, boolean training, int label)
getFeatureKey(Lexicon,boolean,int)
, this method computes the
feature keys corresponding to the arguments of the conjunction. Here, we lookup the arguments
to the conjunction in the lexicon so that their counts are never less than the conjunction's,
and we return the actual feature object that's already a key in the lexicon.f
- The argument feature for which a key will be computed.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 RealFeature multiply(double m)
multiply
in class RealFeature
m
- The multiplier.public Feature withStrength(double s)
s
.withStrength
in class Feature
s
- The strength of the new feature.null
if this feature cannot take the
specified strength.public Feature encode(String e)
public void removeFromChildLexicon(ChildLexicon lex)
ChildLexicon
, in particular updating parent counts and
removing children of this feature if necessary.removeFromChildLexicon
in class Feature
lex
- The child lexicon this feature is being removed from.public int childLexiconLookup(ChildLexicon lex, int label)
ChildLexicon
.childLexiconLookup
in class Feature
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()
public boolean equals(Object o)
public int compareTo(Object o)
public void write(StringBuffer buffer)
Feature
to the specified buffer.public void writeNoPackage(StringBuffer buffer)
Feature
to the specified buffer, omitting
the package name.writeNoPackage
in class Feature
buffer
- The buffer to write to.public void write(edu.illinois.cs.cogcomp.core.datastructures.vectors.ExceptionlessOutputStream out)
public void read(edu.illinois.cs.cogcomp.core.datastructures.vectors.ExceptionlessInputStream in)
This method is appropriate for reading features as written by
write(ExceptionlessOutputStream)
.
public String lexWrite(edu.illinois.cs.cogcomp.core.datastructures.vectors.ExceptionlessOutputStream out, Lexicon lex, String c, String p, String g, String si, ByteString bi)
lexWrite
in class Feature
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 void lexRead(edu.illinois.cs.cogcomp.core.datastructures.vectors.ExceptionlessInputStream in, Lexicon lex, String p, String g, 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 Feature
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.Copyright © 2016. All rights reserved.