edu.mit.jwi.morph
Class StemmingRule

java.lang.Object
  extended by edu.mit.jwi.morph.StemmingRule
All Implemented Interfaces:
IHasPOS, IStemmingRule

public class StemmingRule
extends java.lang.Object
implements IStemmingRule

Default implementation of the IStemmingRule interface.

Since:
JWI 2.3.1
Version:
2.4.0
Author:
Mark A. Finlayson

Constructor Summary
StemmingRule(java.lang.String suffix, java.lang.String ending, POS pos, java.lang.String... ignore)
          Creates a new stemming rule with the specified suffix, ending, and avoid set
 
Method Summary
 java.lang.String apply(java.lang.String word)
          Applies this rule to the given word.
 java.lang.String apply(java.lang.String word, java.lang.String suffix)
          Applies this rule to the given word, adding the specified suffix to the end of the returned string.
 java.lang.String getEnding()
          Returns the ending for this rule.
 POS getPOS()
          Returns the associated part of speech for this object.
 java.lang.String getSuffix()
          Returns the suffix for this rule.
 java.util.Set<java.lang.String> getSuffixIgnoreSet()
          Returns the set of suffixes that should be ignored when applying this stemming rule.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StemmingRule

public StemmingRule(java.lang.String suffix,
                    java.lang.String ending,
                    POS pos,
                    java.lang.String... ignore)
Creates a new stemming rule with the specified suffix, ending, and avoid set

Parameters:
suffix - the suffix that should be stripped from a word; should not be null, empty, or all whitespace.
ending - the ending that should be stripped from a word; should not be null, but may be empty or all whitespace.
pos - the part of speech to which this rule applies, may not be null
ignore - the set of suffixes that, when present, indicate this rule should not be applied. May be null or empty, but not contain nulls or empties.
Throws:
java.lang.NullPointerException - if the suffix, ending, or pos are null, or the ignore set contains null
java.lang.NullPointerException - if the suffix is empty or all whitespace, or the ignore set contains a string which is empty or all whitespace
Since:
JWI 2.3.1
Method Detail

getSuffix

public java.lang.String getSuffix()
Description copied from interface: IStemmingRule
Returns the suffix for this rule. Will never return null, empty, or all whitespace.

Specified by:
getSuffix in interface IStemmingRule
Returns:
the suffix for this rule.

getEnding

public java.lang.String getEnding()
Description copied from interface: IStemmingRule
Returns the ending for this rule. Will never return null , empty, or all whitespace.

Specified by:
getEnding in interface IStemmingRule
Returns:
the ending for this rule.

getSuffixIgnoreSet

public java.util.Set<java.lang.String> getSuffixIgnoreSet()
Description copied from interface: IStemmingRule
Returns the set of suffixes that should be ignored when applying this stemming rule. This method will never return null, but it may return an empty set. The ignore set will not include the string returned by IStemmingRule.getSuffix().

Specified by:
getSuffixIgnoreSet in interface IStemmingRule
Returns:
a non-null but possibly empty set of suffixes to be ignored

getPOS

public POS getPOS()
Description copied from interface: IHasPOS
Returns the associated part of speech for this object. If this object is not associated with any particular part of speech, this method may return null.

Specified by:
getPOS in interface IHasPOS
Returns:
The associated part of speech, or null if none.

apply

public java.lang.String apply(java.lang.String word)
Description copied from interface: IStemmingRule
Applies this rule to the given word. The word should not be null, but may be empty. If the rule cannot be applied to the word, this method returns null. This call is equivalent to calling IStemmingRule.apply(String, String) with null as the second argument

Specified by:
apply in interface IStemmingRule
Parameters:
word - the word to which the stemming rule should be applied.
Returns:
the root of the word, or null if the rule cannot be applied to this word

apply

public java.lang.String apply(java.lang.String word,
                              java.lang.String suffix)
Description copied from interface: IStemmingRule
Applies this rule to the given word, adding the specified suffix to the end of the returned string. If the rule cannot be applied to the word, this method returns null.

Specified by:
apply in interface IStemmingRule
Parameters:
word - the word to which the stemming rule should be applied.
suffix - a suffix that should be appended to the root once it has been derived; may be null.
Returns:
the root of the word, or null if the rule cannot be applied to this word


Copyright © 2007-2013 Massachusetts Institute of Technology. All Rights Reserved.