gov.sandia.cognition.text.term.filter
Class TermLengthFilter

java.lang.Object
  extended by gov.sandia.cognition.util.AbstractCloneableSerializable
      extended by gov.sandia.cognition.text.term.filter.AbstractSingleTermFilter
          extended by gov.sandia.cognition.text.term.filter.TermLengthFilter
All Implemented Interfaces:
SingleTermFilter, TermFilter, CloneableSerializable, Serializable, Cloneable

public class TermLengthFilter
extends AbstractSingleTermFilter

Implements a filter based on the length of a term. The length is computed from the name of the term.

Since:
3.0
Author:
Justin Basilico
See Also:
Serialized Form

Field Summary
static int DEFAULT_MAXIMUM_LENGTH
          The default maximum length is 28.
static int DEFAULT_MINIMUM_LENGTH
          The default minimum length is 3.
protected  Integer maximumLength
          The maximum allowed length.
protected  Integer minimumLength
          The minimum allowed length.
 
Constructor Summary
TermLengthFilter()
          Creates a new TermLengthFilter with default minimum and maximum values.
TermLengthFilter(Integer minimumLength, Integer maximumLength)
          Creates a new TermLengthFilter with given minimum and maximum values.
 
Method Summary
 TermOccurrence filterTerm(TermOccurrence occurrence)
          Takes a single term occurrence and filters that occurrence into a new occurrence or returns null, indicating that the filter rejects that term.
 Integer getMaximumLength()
          Gets the maximum length allowed for a term (inclusive).
 Integer getMinimumLength()
          Gets the minimum length allowed for a term (inclusive).
 void setMaximumLength(Integer maximumLength)
          Gets the maximum length allowed for a term (inclusive).
 void setMinimumLength(Integer minimumLength)
          Gets the minimum length allowed for a term (inclusive).
 
Methods inherited from class gov.sandia.cognition.text.term.filter.AbstractSingleTermFilter
filterTerms
 
Methods inherited from class gov.sandia.cognition.util.AbstractCloneableSerializable
clone
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface gov.sandia.cognition.util.CloneableSerializable
clone
 

Field Detail

DEFAULT_MINIMUM_LENGTH

public static final int DEFAULT_MINIMUM_LENGTH
The default minimum length is 3.

See Also:
Constant Field Values

DEFAULT_MAXIMUM_LENGTH

@PublicationReference(author="Wikipedia",
                      title="Longest word in English",
                      year=2009,
                      type=WebPage,
                      url="http://en.wikipedia.org/wiki/Longest_word_in_English")
public static final int DEFAULT_MAXIMUM_LENGTH
The default maximum length is 28. Based on the maximum known length of non-technical and non-coined English words.

See Also:
Constant Field Values

minimumLength

protected Integer minimumLength
The minimum allowed length. Inclusive. A null value indicates no minimum. Must be non-negative.


maximumLength

protected Integer maximumLength
The maximum allowed length. Inclusive. A null value indicates no maximum. Must be non-negative.

Constructor Detail

TermLengthFilter

public TermLengthFilter()
Creates a new TermLengthFilter with default minimum and maximum values.


TermLengthFilter

public TermLengthFilter(Integer minimumLength,
                        Integer maximumLength)
Creates a new TermLengthFilter with given minimum and maximum values.

Parameters:
minimumLength - The minimum allowed term length.
maximumLength - The maximum allowed term length.
Method Detail

filterTerm

public TermOccurrence filterTerm(TermOccurrence occurrence)
Description copied from interface: SingleTermFilter
Takes a single term occurrence and filters that occurrence into a new occurrence or returns null, indicating that the filter rejects that term.

Parameters:
occurrence - The term occurrence to filter.
Returns:
A term occurrence (may be a new instance or the same as the given one) of the term to replace the given one or null to indicate that the filter has rejected the given term.

getMinimumLength

public Integer getMinimumLength()
Gets the minimum length allowed for a term (inclusive). A null value means no minimum.

Returns:
The minimum length allowed for a term.

setMinimumLength

public void setMinimumLength(Integer minimumLength)
Gets the minimum length allowed for a term (inclusive). A null value means no minimum.

Parameters:
minimumLength - The minimum length allowed for a term. Must be non-negative.

getMaximumLength

public Integer getMaximumLength()
Gets the maximum length allowed for a term (inclusive). A null value means no maximum.

Returns:
The maximum length allowed for a term.

setMaximumLength

public void setMaximumLength(Integer maximumLength)
Gets the maximum length allowed for a term (inclusive). A null value means no maximum.

Parameters:
maximumLength - The maximum length allowed for a term. Must be positive.