LBJ2.learn
Class Lexicon.PruningPolicy

java.lang.Object
  extended by LBJ2.learn.Lexicon.PruningPolicy
Enclosing class:
Lexicon

public static class Lexicon.PruningPolicy
extends java.lang.Object

Represents the feature counting policy of a lexicon. Objects of this type are used to identify and describe a desired pruning policy. In particular, the description of a pruning policy includes feature count thresholds which sometimes need to be computed in terms of data. Space is allocated within objects of this type for storing these thresholds whenever they are computed.

The three pruning policies are described below.

None
No pruning is performed.
Absolute
Features whose counts within a given dataset fall below an absolute threshold are pruned from that dataset.
Percentage
Features whose counts within a given dataset are lower than a given percentage of the most common feature's count are pruned from that dataset.


Field Summary
static int ABSOLUTE
          Represents pruning with an absolute threshold.
private  int index
          Can be used to index the names array.
private static java.lang.String[] names
          The names of the different counting policies as strings.
static int NONE
          Represents no pruning.
private  double percentage
          The percentage associated with the "Percentage" policy described above.
static int PERCENTAGE
          Represents pruning with a percentage threshold.
private  int[] thresholds
          Feature count thresholds which may either be specified by the policy explicitly or computed in terms of data.
 
Constructor Summary
Lexicon.PruningPolicy()
          Creates a new pruning policy in which no features will be pruned.
Lexicon.PruningPolicy(double p)
          Creates a new "Percentage" policy with the given percentage.
Lexicon.PruningPolicy(int t)
          Creates a new "Absolute" policy with the given threshold.
 
Method Summary
 double getPercentage()
          Returns the value of percentage.
 int getThreshold(int i)
          Returns the value of the ith threshold in thresholds when in "Percentage" mode, but ignores the parameter i and returns the first element of thresholds when in "Absolute" mode.
 boolean isAbsolute()
          true iff the policy is absolute thresholding.
 boolean isNone()
          true iff the policy is no pruning.
 boolean isPercentage()
          true iff the policy is percentage thresholding.
 void setThresholds(int[] t)
          Use this method to establish feature count thresholds in the "Percentage" policy.
 java.lang.String toString()
          Retrieves the name of the policy represented by this object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

NONE

public static final int NONE
Represents no pruning.

See Also:
Constant Field Values

ABSOLUTE

public static final int ABSOLUTE
Represents pruning with an absolute threshold.

See Also:
Constant Field Values

PERCENTAGE

public static final int PERCENTAGE
Represents pruning with a percentage threshold.

See Also:
Constant Field Values

names

private static final java.lang.String[] names
The names of the different counting policies as strings.


index

private int index
Can be used to index the names array.


percentage

private double percentage
The percentage associated with the "Percentage" policy described above.


thresholds

private int[] thresholds
Feature count thresholds which may either be specified by the policy explicitly or computed in terms of data.

Constructor Detail

Lexicon.PruningPolicy

public Lexicon.PruningPolicy()
Creates a new pruning policy in which no features will be pruned.


Lexicon.PruningPolicy

public Lexicon.PruningPolicy(double p)
Creates a new "Percentage" policy with the given percentage.

Parameters:
p - The percentage.

Lexicon.PruningPolicy

public Lexicon.PruningPolicy(int t)
Creates a new "Absolute" policy with the given threshold.

Parameters:
t - The threshold.
Method Detail

isNone

public boolean isNone()
true iff the policy is no pruning.


isAbsolute

public boolean isAbsolute()
true iff the policy is absolute thresholding.


isPercentage

public boolean isPercentage()
true iff the policy is percentage thresholding.


setThresholds

public void setThresholds(int[] t)
Use this method to establish feature count thresholds in the "Percentage" policy.

Parameters:
t - The new feature count thresholds.

getThreshold

public int getThreshold(int i)
Returns the value of the ith threshold in thresholds when in "Percentage" mode, but ignores the parameter i and returns the first element of thresholds when in "Absolute" mode.

Parameters:
i - An index.
Returns:
A feature count threshold.

getPercentage

public double getPercentage()
Returns the value of percentage.


toString

public java.lang.String toString()
Retrieves the name of the policy represented by this object.

Overrides:
toString in class java.lang.Object