Class WordFrequencyList

java.lang.Object
  extended by WordFrequencyList

public class WordFrequencyList
extends java.lang.Object


Constructor Summary
WordFrequencyList()
          Constructs a new WordFrequencyList object, with an empty list of WordCounts
 
Method Summary
 void add(java.lang.String word)
          Adds the specified word into the list.
 WordCount get(int index)
          Returns Word at the specified position in the list.
 WordCount mostFrequent()
          Returns the most frequent word in the list.
 int numberOfWords()
          Returns the number of unique words in the list.
 WordFrequencyList occursMoreThan(int n)
          Returns a list of all words that occur more than N times.
 int totalWords()
          Returns the total number of words in the list.
 int wordCount(java.lang.String word)
          Returns the number of times the specified word occurs
 
Methods inherited from class
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WordFrequencyList

public WordFrequencyList()
Constructs a new WordFrequencyList object, with an empty list of WordCounts

Method Detail

add

public void add(java.lang.String word)
Adds the specified word into the list.

Parameters:
word - The word to be added.

get

public WordCount get(int index)
Returns Word at the specified position in the list.

Parameters:
index - the index of the element to return.
Returns:
the Word at the specified position.

mostFrequent

public WordCount mostFrequent()
Returns the most frequent word in the list.

Returns:
the most frequent word in the list

numberOfWords

public int numberOfWords()
Returns the number of unique words in the list.

Returns:
number of unique words in the list

occursMoreThan

public WordFrequencyList occursMoreThan(int n)
Returns a list of all words that occur more than N times.

Parameters:
n - Threshold; all words that occur more than n times will be returned.
Returns:
a list of all words that occur more than N times.

totalWords

public int totalWords()
Returns the total number of words in the list. This is the sum of all word counts.

Returns:
total number of words in the list

wordCount

public int wordCount(java.lang.String word)
Returns the number of times the specified word occurs

Parameters:
word - the word whose count is desired
Returns:
the number of times the specified word occurs