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

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

public class CountableWordDataCounter
extends java.lang.Object

Countable word data counter.

Counts the data in one or more CountableWordData objects. These are most often the results of a WordHoard CQL query.


Field Summary
protected static int batchSize
          Batch size for counting word data entries.
protected  java.util.Map countableWordDataMap
          Countable word data map.
protected  java.util.Map posMap
          Word class/word class map for spellings.
protected  java.util.Map[] totalWordCountMaps
          The word total count maps.
protected  java.util.Map[] wordCountMaps
          The word count maps.
protected  java.util.Collection wordDataList
          The list of countable word data items to count.
protected  java.util.Set wordIDsForPhrasesSet
          Set of unique word ID lists for phrases.
protected  java.util.Set wordTagsSet
          Set of word tags encountered.
protected  java.util.Set workIDsSet
          Set of work IDs encountered.
protected  java.util.Set workPartIDsSet
          Set of work part IDs encountered.
 
Constructor Summary
CountableWordDataCounter()
          Create countable word data counter.
CountableWordDataCounter(java.util.Collection wordDataList)
          Create countable word data counter.
CountableWordDataCounter(java.util.Iterator iterator)
          Create countable word data counter.
 
Method Summary
protected static void countOneWordForm(java.util.Map wordCountMap, java.util.Map totalWordCountMap, Spelling[] values, java.lang.Long workId)
          Update a count map for several word form values for a word.
protected static void countOneWordForm(java.util.Map wordCountMap, java.util.Map totalWordCountMap, Spelling value, java.lang.Long workId)
          Update a count map for a specific word and word form.
 void countPhrases()
          Count phrases.
 void countSpellings()
          Count spellings.
 void countSpellings(java.util.Map countableWordDataMap, java.util.Map[] wordCountMaps, java.util.Map[] totalWordCountMaps)
          Count spellings.
 void countWordParts(java.util.Collection words, boolean lastWords, ProgressReporter progressReporter)
          Count words from a list of Word objects.
 void countWordParts(java.util.Collection wordDataList, java.util.Map[] wordCountMaps, java.util.Map[] totalWordCountMaps)
          Get word counts for a set of words.
 void countWordParts(java.util.Iterator iterator, boolean lastIterator, ProgressReporter progressReporter)
          Count words from an iterator over CountWordData objects.
 void countWordParts(Word[] words, boolean lastWords, ProgressReporter progressReporter)
          Count words from a list of Word objects.
 void createPhrases()
          Create phrases.
 java.util.Map getCountableWordDataMap()
          Get the countable word data map.
 java.util.Map[] getTotalWordCountMaps()
          Get the total count maps.
 java.util.Map[] getWordCountMaps()
          Get the word count maps.
 int getWordPartsCounted()
          Get number of word parts counted.
 int getWordsCounted()
          Get number of words counted.
 int getWorkPartsCounted()
          Get number of work parts counted.
 int getWorksCounted()
          Get number of works counted.
protected  void initMaps()
          Initializes the maps and sets used to hold the word data and counts.
protected  void mergeWordDataIntoPhraseData(CountableWordData wordData, CountableWordData phraseData)
          Merge word data into phrase data.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

wordDataList

protected java.util.Collection wordDataList
The list of countable word data items to count.


wordCountMaps

protected java.util.Map[] wordCountMaps
The word count maps.


totalWordCountMaps

protected java.util.Map[] totalWordCountMaps
The word total count maps.


countableWordDataMap

protected java.util.Map countableWordDataMap
Countable word data map.


posMap

protected java.util.Map posMap
Word class/word class map for spellings.


wordIDsForPhrasesSet

protected java.util.Set wordIDsForPhrasesSet
Set of unique word ID lists for phrases.


workPartIDsSet

protected java.util.Set workPartIDsSet
Set of work part IDs encountered.


workIDsSet

protected java.util.Set workIDsSet
Set of work IDs encountered.


wordTagsSet

protected java.util.Set wordTagsSet
Set of word tags encountered.


batchSize

protected static final int batchSize
Batch size for counting word data entries.

See Also:
Constant Field Values
Constructor Detail

CountableWordDataCounter

public CountableWordDataCounter()
Create countable word data counter.


CountableWordDataCounter

public CountableWordDataCounter(java.util.Collection wordDataList)
Create countable word data counter.

Parameters:
wordDataList - A collection of countable word data items to count.

Use this constructor when all the words to be counted are present in the collection passed as an argument.


CountableWordDataCounter

public CountableWordDataCounter(java.util.Iterator iterator)
Create countable word data counter.

Parameters:
iterator - Iterator over countable word data objects.

Use this constructor when the objects to count come from a scrollable query result. The word data is counted in batches to reduce memory requirements.

Method Detail

initMaps

protected void initMaps()
Initializes the maps and sets used to hold the word data and counts.


getWordCountMaps

public java.util.Map[] getWordCountMaps()
Get the word count maps.

Returns:
The word count maps.

getTotalWordCountMaps

public java.util.Map[] getTotalWordCountMaps()
Get the total count maps.

Returns:
The total count maps.

countOneWordForm

protected static void countOneWordForm(java.util.Map wordCountMap,
                                       java.util.Map totalWordCountMap,
                                       Spelling value,
                                       java.lang.Long workId)
Update a count map for a specific word and word form.

Parameters:
wordCountMap - The word counts.
totalWordCountMap - The total counts.
value - The word value.
workId - The work ID for this word.

countOneWordForm

protected static void countOneWordForm(java.util.Map wordCountMap,
                                       java.util.Map totalWordCountMap,
                                       Spelling[] values,
                                       java.lang.Long workId)
Update a count map for several word form values for a word.

Parameters:
wordCountMap - The word counts.
totalWordCountMap - The total counts.
values - The word values.
workId - The work ID for this word.

countWordParts

public void countWordParts(java.util.Collection wordDataList,
                           java.util.Map[] wordCountMaps,
                           java.util.Map[] totalWordCountMaps)
Get word counts for a set of words.

Parameters:
wordDataList - The countable word data for the words.
wordCountMaps - The output word count maps.
totalWordCountMaps - The output total word count maps.

The indices of the count maps and total counts match those of of the word forms as given in WordForms.


countSpellings

public void countSpellings(java.util.Map countableWordDataMap,
                           java.util.Map[] wordCountMaps,
                           java.util.Map[] totalWordCountMaps)
Count spellings.

Parameters:
countableWordDataMap - The countable word data.
wordCountMaps - The word count maps.
totalWordCountMaps - The total word count maps.

The word count and total word count maps are updated with the spelling counts.


countSpellings

public void countSpellings()
Count spellings.

The word count and total word count maps are updated with the spelling counts.


countWordParts

public void countWordParts(java.util.Iterator iterator,
                           boolean lastIterator,
                           ProgressReporter progressReporter)
Count words from an iterator over CountWordData objects.

Parameters:
iterator - Iterator over CountableWordData objects.
lastIterator - True if this iterator is for the last batch of words to count.
progressReporter - Progress reporter. Can be null.

countWordParts

public void countWordParts(Word[] words,
                           boolean lastWords,
                           ProgressReporter progressReporter)
Count words from a list of Word objects.

Parameters:
words - Array of Word objects.
lastWords - True if this is the last batch of words to count.
progressReporter - Progress reporter. Can be null.

countWordParts

public void countWordParts(java.util.Collection words,
                           boolean lastWords,
                           ProgressReporter progressReporter)
Count words from a list of Word objects.

Parameters:
words - Collection of Word objects.
lastWords - True if this is the last batch of words to count.
progressReporter - Progress reporter. Can be null.

mergeWordDataIntoPhraseData

protected void mergeWordDataIntoPhraseData(CountableWordData wordData,
                                           CountableWordData phraseData)
Merge word data into phrase data.

Parameters:
wordData - The data for a word.
phraseData - The data for a phrase.

createPhrases

public void createPhrases()
Create phrases.


countPhrases

public void countPhrases()
Count phrases.


getCountableWordDataMap

public java.util.Map getCountableWordDataMap()
Get the countable word data map.

Returns:
The spelling map.

getWordPartsCounted

public int getWordPartsCounted()
Get number of word parts counted.

Returns:
Number of word parts counted.

getWordsCounted

public int getWordsCounted()
Get number of words counted.

Returns:
Number of words counted.

getWorksCounted

public int getWorksCounted()
Get number of works counted.

Returns:
Number of works counted.

getWorkPartsCounted

public int getWorkPartsCounted()
Get number of work parts counted.

Returns:
Number of work parts counted.