edu.northwestern.at.morphadorner.corpuslinguistics.ngram

## Class WordCountExtractor

- java.lang.Object
- - edu.northwestern.at.morphadorner.corpuslinguistics.ngram.WordCountExtractor

-     public class WordCountExtractor
      extends java.lang.Object

  Counts words in a text.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected java.lang.String[]` | `uniqueWords` String array of unique words.
    `protected java.util.Map<java.lang.String,java.lang.Integer>` | `wordCounts` The list of words and word counts in the text.
    `(package private) java.lang.String[]` | `words` The text parsed into a string array of words.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `WordCountExtractor()` Create word count extractor.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected void` | `computeWordCounts()` Compute word counts from a string array of words.
    `void` | `countWords(java.util.List<java.lang.String> wordList)` Extract word counts from an arraylist of words.
    `void` | `countWords(java.lang.String[] words)` Extract word counts from a string array of words.
    `int` | `getNumberOfUniqueWords()` Return the number of unique words.
    `int` | `getNumberOfWords()` Return the total number of words.
    `java.lang.String[]` | `getUniqueWords()` Return unique words as a string array.
    `int` | `getWordCount(java.lang.String word)` Return count for a specific word.
    `java.util.Map` | `getWordCounts()` Return word count map.
    `java.lang.String[]` | `getWords()` Return tokenized text words as a string array.
    `void` | `reset()` Reset counter.

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

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

- - ### Field Detail

    - #### wordCounts

          protected java.util.Map<java.lang.String,java.lang.Integer> wordCounts

      The list of words and word counts in the text.

      Key=word
      Value=Integer(count)

    - #### words

          java.lang.String[] words

      The text parsed into a string array of words. Package scope for the benefit of NGramExtractor.

    - #### uniqueWords

          protected java.lang.String[] uniqueWords

      String array of unique words.

  - ### Constructor Detail

    - #### WordCountExtractor

          public WordCountExtractor()

      Create word count extractor.

  - ### Method Detail

    - #### countWords

          public void countWords(java.lang.String[] words)

      Extract word counts from a string array of words.
      Parameters:
        `words` - The string array with the words.

    - #### countWords

          public void countWords(java.util.List<java.lang.String> wordList)

      Extract word counts from an arraylist of words.
      Parameters:
        `wordList` - The list with the words.

    - #### computeWordCounts

          protected void computeWordCounts()

      Compute word counts from a string array of words.

    - #### getWords

          public java.lang.String[] getWords()

      Return tokenized text words as a string array.
      Returns:
        The string array of words.

    - #### getNumberOfWords

          public int getNumberOfWords()

      Return the total number of words.
      Returns:
        The number of words.

    - #### getUniqueWords

          public java.lang.String[] getUniqueWords()

      Return unique words as a string array.
      Returns:
        The string array of unique words.

    - #### getNumberOfUniqueWords

          public int getNumberOfUniqueWords()

      Return the number of unique words.
      Returns:
        The number of unique words.

    - #### getWordCount

          public int getWordCount(java.lang.String word)

      Return count for a specific word.
      Parameters:
        `word` - The word whose count is desired.
      Returns:
        The count of the word in the text.

    - #### getWordCounts

          public java.util.Map getWordCounts()

      Return word count map.
      Returns:
        Word count map.

    - #### reset

          public void reset()

      Reset counter.