|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.ObjectLBJ2.learn.Lexicon
LBJ2.learn.ChildLexicon
public class ChildLexicon
Instances of this class are intended to store features that are children
of other features and which do not correspond to their own weights in any
learner's weight vector. While a Lexicon will store an instance
of this class in its Lexicon.lexiconChildren field, an instance of
this class will never do so. Also, the lookupChild(Feature)
method behaves differently in this class, since it is assumed that
children are stored here.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class LBJ2.learn.Lexicon |
|---|
Lexicon.CountPolicy, Lexicon.PruningPolicy |
| Field Summary | |
|---|---|
private Lexicon |
parentLexicon
A reference to the lexicon that uses this lexicon as its child lexicon. |
private IVector |
parents
The elements of this vector (which correspond to the features in Lexicon.lexiconInv) serve a dual purpose; first, to indicate by
absolute value the number of other features currently stored in this
object that have the corresponding feature as a child, and second, to
indicate by sign if the corresponding feature has been marked for
removal. |
| Fields inherited from class LBJ2.learn.Lexicon |
|---|
featureCounts, lexicon, lexiconChildren, lexiconInv, perClassFeatureCounts, pruneCutoff |
| Constructor Summary | |
|---|---|
ChildLexicon()
Creates an empty lexicon. |
|
ChildLexicon(Lexicon p)
Creates an empty lexicon. |
|
ChildLexicon(Lexicon p,
java.lang.String e)
Creates an empty lexicon with the given encoding. |
|
| Method Summary | |
|---|---|
int |
childLexiconLookup(DiscreteConjunctiveFeature f,
int label)
Updates the counts in parents for the children of
f. |
int |
childLexiconLookup(DiscreteReferrer f,
int label)
Updates the counts in parents for the children of
f. |
int |
childLexiconLookup(Feature f,
int label)
Updates the counts in parents for the children of
f. |
int |
childLexiconLookup(RealConjunctiveFeature f,
int label)
Updates the counts in parents for the children of
f. |
int |
childLexiconLookup(RealReferrer f,
int label)
Updates the counts in parents for the children of
f. |
void |
clear()
Clears the data structures associated with this instance. |
void |
decrementParentCounts(Feature f)
The parent of feature f is being removed, so we decrement
f's parent counts and remove it if it's ready. |
Feature |
getChildFeature(Feature f,
int label)
This method adds the given feature to this lexicon and also recursively adds its children, if any. |
protected void |
incrementParentCounts(Feature f,
int label)
Helper method for methods like childLexiconLookup(DiscreteConjunctiveFeature,int) that
actually does the work of looking up the child feature and updating its
parent counts. |
int |
lookupChild(Feature f)
Unlike the overridden method in Lexicon, this method simply
checks Lexicon.lexicon for the feature and will throw an exception if
it can't be found. |
void |
printCountTable(boolean p)
Produces on STDOUT a table of feature counts including a
line indicating the position of Lexicon.pruneCutoff. |
void |
read(ExceptionlessInputStream in,
boolean readCounts)
Reads a binary representation of the lexicon. |
Feature |
remove(Feature f)
Removes the mapping for the given feature from this lexicon and returns the feature object representing it that was stored here. |
void |
setParent(Lexicon p)
Sets the value of parentLexicon and makes sure that any
features marked for removal in this lexicon are the identical objects
also present in the parent. |
void |
write(ExceptionlessOutputStream out)
Writes a binary representation of the lexicon. |
| Methods inherited from class LBJ2.learn.Lexicon |
|---|
clone, contains, countFeatures, discardPrunedFeatures, equals, getCountPolicy, getCutoff, getMap, hashCode, incrementCount, isPruned, isPruned, lazyMapCreation, lookup, lookup, lookup, lookupKey, main, perClassToGlobalCounts, prune, read, readLexicon, readLexicon, readLexicon, readLexicon, readLexicon, readPrunedSize, setEncoding, size, toString |
| Methods inherited from class java.lang.Object |
|---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
private IVector parents
Lexicon.lexiconInv) serve a dual purpose; first, to indicate by
absolute value the number of other features currently stored in this
object that have the corresponding feature as a child, and second, to
indicate by sign if the corresponding feature has been marked for
removal.
private Lexicon parentLexicon
| Constructor Detail |
|---|
public ChildLexicon()
public ChildLexicon(Lexicon p)
p - The lexicon that uses this lexicon as its child lexicon.
public ChildLexicon(Lexicon p,
java.lang.String e)
p - The lexicon that uses this lexicon as its child lexicon.e - The encoding to use when adding features to this lexicon.| Method Detail |
|---|
public void clear()
clear in class Lexiconpublic void setParent(Lexicon p)
parentLexicon and makes sure that any
features marked for removal in this lexicon are the identical objects
also present in the parent. This is useful in particular just after
lexicons have been read from disk.
p - The new parent lexicon.public Feature remove(Feature f)
f - The feature to remove.
f that used to be stored
here, or null if it wasn't present.public void decrementParentCounts(Feature f)
f is being removed, so we decrement
f's parent counts and remove it if it's ready.
f - The child feature whose parent counts need updating and which
may be removed as well.
public Feature getChildFeature(Feature f,
int label)
getChildFeature in class Lexiconf - The feature to look up.label - The label of the example containing this feature, or -1 if
we aren't doing per class feature counting.
f that is stored in this
lexicon.
public int childLexiconLookup(Feature f,
int label)
parents for the children of
f.
f - The feature to look up.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 childLexiconLookup(DiscreteConjunctiveFeature f,
int label)
parents for the children of
f.
f - The feature to look up.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 childLexiconLookup(RealConjunctiveFeature f,
int label)
parents for the children of
f.
f - The feature to look up.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 childLexiconLookup(DiscreteReferrer f,
int label)
parents for the children of
f.
f - The feature to look up.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 childLexiconLookup(RealReferrer f,
int label)
parents for the children of
f.
f - The feature to look up.label - The label of the example containing this feature, or -1 if
we aren't doing per class feature counting.
f in this lexicon.
protected void incrementParentCounts(Feature f,
int label)
childLexiconLookup(DiscreteConjunctiveFeature,int) that
actually does the work of looking up the child feature and updating its
parent counts.
f - The feature to look up.label - The label of the example containing this feature, or -1 if
we aren't doing per class feature counting.public int lookupChild(Feature f)
Lexicon, this method simply
checks Lexicon.lexicon for the feature and will throw an exception if
it can't be found.
lookupChild in class Lexiconf - The feature to look up.
Lexicon.lexicon, its associated
integer index is returned.
java.lang.UnsupportedOperationException - If the feature isn't found
anywhere in the lexicon.public void write(ExceptionlessOutputStream out)
write in class Lexiconout - The output stream.
public void read(ExceptionlessInputStream in,
boolean readCounts)
read in class Lexiconin - The input stream.readCounts - Whether or not to read the feature counts.public void printCountTable(boolean p)
STDOUT a table of feature counts including a
line indicating the position of Lexicon.pruneCutoff. It's probably not
a good idea to call this method unless you know your lexicon is small.
printCountTable in class Lexiconp - Whether or not to include package names in the output.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||