public abstract class DiscreteReferrer extends DiscreteFeature
Modifier and Type | Field and Description |
---|---|
protected DiscreteFeature |
referent
The feature being referred to.
|
BooleanValues, totalValues, valueIndex
containingPackage, generatingClassifier
Modifier | Constructor and Description |
---|---|
protected |
DiscreteReferrer()
For internal use only.
|
|
DiscreteReferrer(Classifier c,
DiscreteFeature r)
Sets both the identifier and the referent.
|
|
DiscreteReferrer(Classifier c,
DiscreteFeature r,
String[] av)
Sets both the identifier and the referent.
|
|
DiscreteReferrer(String p,
String c,
DiscreteFeature r,
short vi,
short t)
Constructs a new referring 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.
|
ByteString |
getByteStringValue()
Gives a string representation of the value of this feature.
|
DiscreteFeature |
getReferent()
Returns the value of
referent . |
String |
getStringValue()
Gives a string representation of the value of this feature.
|
int |
hashCode()
The hash code of a
DiscreteReferrer is the sum of the hash codes of its
containing package, identifier, and the referent feature. |
boolean |
isReferrer()
Determines if this feature is a referring feature.
|
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.
|
void |
read(edu.illinois.cs.cogcomp.core.datastructures.vectors.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.
|
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. |
boolean |
valueEquals(String v)
Determines whether or not the parameter is equivalent to the string representation of the
value of this feature.
|
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, conjunctWith, getStrength, getValueIndex, isDiscrete, totalValues
classEquivalent, clone, compareNameStrings, conjunctWith, encode, equals, fromArray, getByteStringIdentifier, getFeatureKey, getFeatureKey, getGeneratingClassifier, getPackage, getStringIdentifier, hasByteStringIdentifier, hasStringIdentifier, isConjunctive, isPrimitive, lexReadFeature, makeReal, readFeature, setArrayLength, toString, toStringNoPackage, withStrength, writeNameString
protected DiscreteFeature referent
protected DiscreteReferrer()
public DiscreteReferrer(Classifier c, DiscreteFeature r)
c
- The classifier that produced this feature.r
- The discrete feature referred to by this new feature.public DiscreteReferrer(Classifier c, DiscreteFeature r, String[] av)
c
- The classifier that produced this feature.r
- The discrete feature referred to by this new feature.av
- The allowable values of the classifier that produced r
.public DiscreteReferrer(String p, String c, DiscreteFeature r, short vi, short t)
p
- The new discrete feature's package.c
- The name of the classifier that produced this feature.r
- The discrete feature referred to by this new feature.vi
- The index corresponding to the value.t
- The total allowable values for this feature.public boolean isReferrer()
isReferrer
in class Feature
true
iff this feature is a referring feature.public DiscreteFeature getReferent()
referent
.public int depth()
public String getStringValue()
getStringValue
in class Feature
referent
.public ByteString getByteStringValue()
getByteStringValue
in class Feature
referent
.public boolean valueEquals(String v)
valueEquals
in class Feature
v
- The string to compare against.true
iff v
is equivalent to the string representation of
the value of this feature.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()
DiscreteReferrer
is the sum of the hash codes of its
containing package, identifier, and the referent feature.public int compareTo(Object o)
compareTo
in interface Comparable
compareTo
in class Feature
o
- An object to compare with.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)
write
in class DiscreteFeature
out
- The output stream.public void read(edu.illinois.cs.cogcomp.core.datastructures.vectors.ExceptionlessInputStream in)
read
in class DiscreteFeature
in
- The input stream.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 DiscreteFeature
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 DiscreteFeature
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.