edu.northwestern.at.morphadorner.corpuslinguistics.stemmer

## Class PorterStemmer

- java.lang.Object
- - edu.northwestern.at.morphadorner.corpuslinguistics.stemmer.PorterStemmer

- All Implemented Interfaces:
    Stemmer

      public class PorterStemmer
      extends java.lang.Object
      implements Stemmer

  Stemmer, implementing the Porter Stemming Algorithm The Stemmer class transforms a word into its root form. The input word can be provided a character at time (by calling add()), or at once by calling one of the various stem(something) methods.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected char[]` | `b`
    `protected int` | `i`
    `protected int` | `i_end`
    `protected static int` | `INC`
    `protected int` | `j`
    `protected int` | `k`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `PorterStemmer()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `add(char ch)` Add a character to the word being stemmed.
    `void` | `add(char[] w, int wLen)` Adds wLen characters to the word being stemmed contained in a portion of a char[] array.
    `protected boolean` | `cons(int i)`
    `protected boolean` | `cvc(int i)`
    `protected boolean` | `doublec(int j)`
    `protected boolean` | `ends(java.lang.String s)`
    `char[]` | `getResultBuffer()` Returns a reference to a character buffer containing the results of the stemming process.
    `int` | `getResultLength()` Returns the length of the word resulting from the stemming process.
    `protected int` | `m()`
    `protected void` | `r(java.lang.String s)`
    `protected void` | `setto(java.lang.String s)`
    `void` | `stem()` Stem the word placed into the Stemmer buffer through calls to add().
    `java.lang.String` | `stem(java.lang.String word)` Find stem of a single word.
    `protected void` | `step1()`
    `protected void` | `step2()`
    `protected void` | `step3()`
    `protected void` | `step4()`
    `protected void` | `step5()`
    `protected void` | `step6()`
    `java.lang.String` | `toString()` After a word has been stemmed, it can be retrieved by toString(), or a reference to the internal buffer can be retrieved by getResultBuffer and getResultLength (which is generally more efficient.)
    `protected boolean` | `vowelinstem()`

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

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

- - ### Field Detail

    - #### b

          protected char[] b

    - #### i

          protected int i

    - #### i_end

          protected int i_end

    - #### j

          protected int j

    - #### k

          protected int k

    - #### INC

          protected static final int INC

      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### PorterStemmer

          public PorterStemmer()

  - ### Method Detail

    - #### add

          public void add(char ch)

      Add a character to the word being stemmed. When you are finished adding characters, you can call stem(void) to stem the word.

    - #### add

          public void add(char[] w,
                 int wLen)

      Adds wLen characters to the word being stemmed contained in a portion of a char[] array. This is like repeated calls of add(char ch), but faster.

    - #### toString

          public java.lang.String toString()

      After a word has been stemmed, it can be retrieved by toString(), or a reference to the internal buffer can be retrieved by getResultBuffer and getResultLength (which is generally more efficient.)
      Overrides:
        `toString` in class `java.lang.Object`

    - #### getResultLength

          public int getResultLength()

      Returns the length of the word resulting from the stemming process.

    - #### getResultBuffer

          public char[] getResultBuffer()

      Returns a reference to a character buffer containing the results of the stemming process. You also need to consult getResultLength() to determine the length of the result.

    - #### cons

          protected final boolean cons(int i)

    - #### m

          protected final int m()

    - #### vowelinstem

          protected final boolean vowelinstem()

    - #### doublec

          protected final boolean doublec(int j)

    - #### cvc

          protected final boolean cvc(int i)

    - #### ends

          protected final boolean ends(java.lang.String s)

    - #### setto

          protected final void setto(java.lang.String s)

    - #### r

          protected final void r(java.lang.String s)

    - #### step1

          protected final void step1()

    - #### step2

          protected final void step2()

    - #### step3

          protected final void step3()

    - #### step4

          protected final void step4()

    - #### step5

          protected final void step5()

    - #### step6

          protected final void step6()

    - #### stem

          public void stem()

      Stem the word placed into the Stemmer buffer through calls to add(). Returns true if the stemming process resulted in a word different from the input. You can retrieve the result with getResultLength()/getResultBuffer() or toString().

    - #### stem

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

      Description copied from interface: `Stemmer`
      Find stem of a single word.
      Specified by:
        `stem` in interface `Stemmer`
      Parameters:
        `word` - The word whose stem is desired.
      Returns:
        The word stem.