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

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

public class SynonymFilter
extends AbstractSingleTermFilter

A term filter that uses a mapping of synonyms to replace a word with its synonym.

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

Field Summary
protected  Map<Term,Term> synonyms
          The mapping of terms to the synonym to replace them with.
 
Constructor Summary
SynonymFilter()
          Creates a new, empty SynonymFilter.
SynonymFilter(Map<Term,Term> synonyms)
          Creates a new SynonymFilter with the given synonyms.
 
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.
 Map<Term,Term> getSynonyms()
          Gets the mapping of terms to their synonyms.
 void setSynonyms(Map<Term,Term> synonyms)
          Sets the mapping of terms to their synonyms.
 
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

synonyms

protected Map<Term,Term> synonyms
The mapping of terms to the synonym to replace them with.

Constructor Detail

SynonymFilter

public SynonymFilter()
Creates a new, empty SynonymFilter.


SynonymFilter

public SynonymFilter(Map<Term,Term> synonyms)
Creates a new SynonymFilter with the given synonyms.

Parameters:
synonyms -
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.

getSynonyms

public Map<Term,Term> getSynonyms()
Gets the mapping of terms to their synonyms.

Returns:
The mapping of terms to their synonyms.

setSynonyms

public void setSynonyms(Map<Term,Term> synonyms)
Sets the mapping of terms to their synonyms.

Parameters:
synonyms - The mapping of terms to their synonyms.