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

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.DictionaryFilter
All Implemented Interfaces:
SingleTermFilter, TermFilter, CloneableSerializable, Serializable, Cloneable

public class DictionaryFilter
extends AbstractSingleTermFilter

A term filter that only allows terms in its dictionary.

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

Field Summary
protected  Set<Term> allowedTerms
          The set of terms allowed by the filter.
 
Constructor Summary
DictionaryFilter()
          Creates a new DictionaryFilter with an empty set of allowed terms.
DictionaryFilter(Set<Term> allowedTerms)
          Creates a new DictionaryFilter with a given set of allowed terms.
 
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.
 Set<Term> getAllowedTerms()
          Gets the set of allowed terms.
 void setAllowedTerms(Set<Term> allowedTerms)
          Sets the set of allowed terms.
 
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

allowedTerms

protected Set<Term> allowedTerms
The set of terms allowed by the filter. All other terms are discarded.

Constructor Detail

DictionaryFilter

public DictionaryFilter()
Creates a new DictionaryFilter with an empty set of allowed terms.


DictionaryFilter

public DictionaryFilter(Set<Term> allowedTerms)
Creates a new DictionaryFilter with a given set of allowed terms.

Parameters:
allowedTerms - The set of allowed terms.
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.

getAllowedTerms

public Set<Term> getAllowedTerms()
Gets the set of allowed terms.

Returns:
The set of allowed terms.

setAllowedTerms

public void setAllowedTerms(Set<Term> allowedTerms)
Sets the set of allowed terms.

Parameters:
allowedTerms - The set of allowed terms.