edu.northwestern.at.wordhoard.swing.calculator.modelutils
Class WordCountUtils

java.lang.Object
  extended by edu.northwestern.at.wordhoard.swing.calculator.modelutils.WordCountUtils

public class WordCountUtils
extends java.lang.Object

Word count utilities.


Constructor Summary
protected WordCountUtils()
          Don't allow instantiation but do allow overrides.
 
Method Summary
static int getDistinctWordFormCount(WorkPart[] workParts, int wordForm)
          Get distinct word form count in a set of work parts.
static java.util.Map[] getWordCounts(WorkPart[] workParts, int wordForm)
          Get word form counts in a set of work parts.
static java.util.Map[] getWordCounts(WorkPart[] workParts, int wordForm, boolean getWorkCounts)
          Get word form counts in a set of work parts.
static java.util.Map[] getWordCounts(WorkPart[] workParts1, WorkPart[] workParts2, int wordForm)
          Get word form counts in two arrays of work parts.
static java.util.Map getWordCounts(WorkPart workPart, int wordForm)
          Get word counts in a single work part.
static int getWordFormCount(WorkPart[] workParts, int wordForm)
          Get total word form count in a set of work parts.
static java.util.Map getWordFormCount(WorkPart[] workParts, Spelling[] words, int wordForm)
          Get word count for multiple words in a set of work parts.
static int getWordFormCount(WorkPart[] workParts, Spelling word, int wordForm)
          Get word count in a set of work parts.
static int getWordFormCount(WorkPart workPart, int wordForm)
          Get total word form count in a work part.
static int getWordFormCount(WorkPart workPart, Spelling word, int wordForm)
          Get word count in a work part.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WordCountUtils

protected WordCountUtils()
Don't allow instantiation but do allow overrides.

Method Detail

getWordFormCount

public static java.util.Map getWordFormCount(WorkPart[] workParts,
                                             Spelling[] words,
                                             int wordForm)
Get word count for multiple words in a set of work parts.

Parameters:
workParts - The work parts.
words - The words.
wordForm - The word form.
Returns:
Map with words as keys and counts of each word in the work parts as values.

getWordFormCount

public static int getWordFormCount(WorkPart[] workParts,
                                   int wordForm)
Get total word form count in a set of work parts.

Parameters:
workParts - The work parts.
wordForm - The word form.
Returns:
Count of the word form in the work parts.

getDistinctWordFormCount

public static int getDistinctWordFormCount(WorkPart[] workParts,
                                           int wordForm)
Get distinct word form count in a set of work parts.

Parameters:
workParts - The work parts.
wordForm - The word form.
Returns:
Count of the distinct word forms in the work parts.

getWordFormCount

public static int getWordFormCount(WorkPart workPart,
                                   int wordForm)
Get total word form count in a work part.

Parameters:
workPart - The work part.
wordForm - The word form.
Returns:
Count of the word form in the work part.

getWordFormCount

public static int getWordFormCount(WorkPart[] workParts,
                                   Spelling word,
                                   int wordForm)
Get word count in a set of work parts.

Parameters:
workParts - The work parts.
word - The word.
wordForm - The word form.
Returns:
Count of the word form in the work parts.

getWordFormCount

public static int getWordFormCount(WorkPart workPart,
                                   Spelling word,
                                   int wordForm)
Get word count in a work part.

Parameters:
workPart - The work part.
word - The word.
wordForm - The word form.
Returns:
Count of the word form in the work part.

getWordCounts

public static java.util.Map getWordCounts(WorkPart workPart,
                                          int wordForm)
Get word counts in a single work part.

Parameters:
workPart - The work part.
wordForm - The word form to count.
Returns:
Map containing each word in the work part as a key and the count of the word as the value.

getWordCounts

public static java.util.Map[] getWordCounts(WorkPart[] workParts,
                                            int wordForm,
                                            boolean getWorkCounts)
Get word form counts in a set of work parts.

Parameters:
workParts - The work parts.
wordForm - The word form to count.
getWorkCounts - if true, work counts are returned in the second result map (see below). If false, hashsets of work IDs are returned in the second result map.
Returns:
Array of two maps. The first map contains each word of the specified word form in the work parts as a key and the count of the appearance of the word in the work parts as a value. The second map also has the word as the key. If "getWorkCounts" is true, the values for each word are the counts of the works in which the word appears. If "getWorkCounts" is false, the value is a hash set of the word IDs for each work in which the word appears.

getWordCounts

public static java.util.Map[] getWordCounts(WorkPart[] workParts,
                                            int wordForm)
Get word form counts in a set of work parts.

Parameters:
workParts - The work parts.
wordForm - The word form to count.
Returns:
Array of two maps. The first map contains each word of then specified word form in the work parts as a key and the count of the appearance of the word in the work parts as a value. The second map also has the word as the key but provides the number of parent works for the work parts in which the word appears as a value.

getWordCounts

public static java.util.Map[] getWordCounts(WorkPart[] workParts1,
                                            WorkPart[] workParts2,
                                            int wordForm)
Get word form counts in two arrays of work parts.

Parameters:
workParts1 - The first array of work parts.
workParts2 - The second array of work parts.
wordForm - The word form to count.
Returns:
Array of three maps.

The first map contains each word of the specified word form in the first set of work parts as a key and the count of the appearance of the word in the first set of work parts as a value.

The second map contains each word of the specified word form in the second set of work parts as a key and the count of the appearance of the word in the second set of work parts as a value.

The third map also has the word as the key but provides the number of works (NOT work parts) in which the word appears as a value in either of the two sets of work parts.