edu.northwestern.at.morphadorner.corpuslinguistics.inflector.wordrule

## Class SuffixInflectionRule

- java.lang.Object
- - edu.northwestern.at.morphadorner.corpuslinguistics.inflector.wordrule.SuffixInflectionRule

- All Implemented Interfaces:
    WordRule
  Direct Known Subclasses:
    CategoryInflectionRule

      public class SuffixInflectionRule
      extends java.lang.Object
      implements WordRule

  A rule for specifying an inflection using suffixes.

  For example, the English nouns which have the suffix -y, generally change the suffix to -ies in the plural. Such a rule would be expressed as `new SuffixInflectionRule("-y", "-ies")`.

  Original code written by Tom White under the Apache v2 license. Modified by Philip R. Burns for integration into MorphAdorner.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected java.lang.String` | `pluralSuffix`
    `protected java.lang.String` | `regex`
    `protected java.lang.String` | `singularSuffix`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `SuffixInflectionRule(java.lang.String singularSuffix, java.lang.String pluralSuffix)` Construct a rule for a suffix `singularSuffix` which becomes `pluralSuffix` in the plural.
    `SuffixInflectionRule(java.lang.String suffix, java.lang.String singularSuffix, java.lang.String pluralSuffix)` Construct a rule for words with suffix `suffix`, where `singularSuffix` becomes `pluralSuffix` in the plural.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `applies(java.lang.String word)` Tests to see if this rule applies for the given word.
    `java.lang.String` | `apply(java.lang.String word)` Applies this rule to the word, and transforming it into a new form.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### regex

          protected final java.lang.String regex

    - #### singularSuffix

          protected final java.lang.String singularSuffix

    - #### pluralSuffix

          protected final java.lang.String pluralSuffix

  - ### Constructor Detail

    - #### SuffixInflectionRule

          public SuffixInflectionRule(java.lang.String singularSuffix,
                              java.lang.String pluralSuffix)

      Construct a rule for a suffix `singularSuffix` which becomes `pluralSuffix` in the plural.
      Parameters:
        `singularSuffix` - The singular suffix, starting with a "-" character.
        `pluralSuffix` - The plural suffix, starting with a "-" character.

    - #### SuffixInflectionRule

          public SuffixInflectionRule(java.lang.String suffix,
                              java.lang.String singularSuffix,
                              java.lang.String pluralSuffix)

      Construct a rule for words with suffix `suffix`, where `singularSuffix` becomes `pluralSuffix` in the plural.
      Parameters:
        `suffix` - The suffix, starting with a "-" character, which the end of the word must match. Regular expression patterns may be used.
        `singularSuffix` - The singular suffix, starting with a "-" character. The `suffix` must end with `singularSuffix`.
        `pluralSuffix` - The plural suffix, starting with a "-" character.

  - ### Method Detail

    - #### applies

          public boolean applies(java.lang.String word)

      Tests to see if this rule applies for the given word.
      Specified by:
        `applies` in interface `WordRule`
      Parameters:
        `word` - The word that is being tested
      Returns:
        `true` if this rule should be applied, `false` otherwise

    - #### apply

          public java.lang.String apply(java.lang.String word)

      Applies this rule to the word, and transforming it into a new form.
      Specified by:
        `apply` in interface `WordRule`
      Parameters:
        `word` - The word to which to apply this rule.
      Returns:
        The transformed word.