public class ChildLexicon extends Lexicon
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.Lexicon.CountPolicy, Lexicon.PruningPolicy
featureCounts, lexicon, lexiconChildren, lexiconInv, perClassFeatureCounts, pruneCutoff
Constructor and Description |
---|
ChildLexicon()
Creates an empty lexicon.
|
ChildLexicon(Lexicon p)
Creates an empty lexicon.
|
ChildLexicon(Lexicon p,
String e)
Creates an empty lexicon with the given encoding.
|
Modifier and Type | Method and Description |
---|---|
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(edu.illinois.cs.cogcomp.core.datastructures.vectors.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(edu.illinois.cs.cogcomp.core.datastructures.vectors.ExceptionlessOutputStream out)
Writes a binary representation of the 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
public ChildLexicon()
public ChildLexicon(Lexicon p)
p
- The lexicon that uses this lexicon as its child lexicon.public void clear()
public 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 Lexicon
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
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 Lexicon
f
- The feature to look up.Lexicon.lexicon
, its associated integer index is
returned.UnsupportedOperationException
- If the feature isn't found anywhere in the lexicon.public void write(edu.illinois.cs.cogcomp.core.datastructures.vectors.ExceptionlessOutputStream out)
public void read(edu.illinois.cs.cogcomp.core.datastructures.vectors.ExceptionlessInputStream in, boolean readCounts)
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 Lexicon
p
- Whether or not to include package names in the output.Copyright © 2016. All rights reserved.