edu.northwestern.at.monk.model
Class WorkPart

java.lang.Object
  extended by edu.northwestern.at.monk.model.TaggedObject
      extended by edu.northwestern.at.monk.model.CoreObject
          extended by edu.northwestern.at.monk.model.WorkPart
All Implemented Interfaces:
Container, java.lang.Comparable<WorkPart>
Direct Known Subclasses:
Work

public class WorkPart
extends CoreObject
implements Container, java.lang.Comparable<WorkPart>

A work part.

See Also:
MONK Datastore Overview, Licensing Agreement

Nested Class Summary
static class WorkPart.Comparator
          A multi-column work part comparator.
static class WorkPart.SortOption
          Work part sorting options.
 
Method Summary
 int compareTo(WorkPart other)
          Compares this instance with another.
static
<T extends WorkPart>
java.util.Collection<T>
find(java.util.Collection<SearchCriterion> criteria)
          Finds work parts.
static
<T extends WorkPart>
java.util.Collection<T>
find(SearchCriteria criteria)
          Finds work parts.
static
<T extends WorkPart>
java.util.Collection<T>
find(SearchCriterion... criteria)
          Finds work parts.
static WorkPart get(java.lang.String tag)
          Gets a work part by tag.
 java.lang.String getAdornedXml()
          Gets the XML for the work part.
static
<T extends WorkPart>
java.util.Collection<T>
getAll()
          Gets all the work parts.
 java.util.List<WorkPart> getChildren()
          Gets the children.
 java.util.Collection<WorkPart> getDescendants()
          Gets the descendants.
 java.lang.String getHtmlText()
          Gets the HTML text for the work part.
 int getLevel()
          Gets the level.
 WorkPart getNextWorkPartWithText()
          Gets the next work part with text.
 int getNumChildren()
          Gets the number of children.
 long getNumSentences(CumKind cumKind)
          Gets the number of sentences.
 long getNumSentencesMain(CumKind cumKind)
          Gets the number of sentences in main text.
 long getNumWordBigrams(CumKind cumKind)
          Gets the number of word bigrams.
 long getNumWordBigramsMain(CumKind cumKind)
          Gets the number of word bigrams in main text.
 long getNumWordPartBigrams(CumKind cumKind)
          Gets the number of word part bigrams.
 long getNumWordPartBigramsMain(CumKind cumKind)
          Gets the number of word part bigrams in main text.
 long getNumWordParts(CumKind cumKind)
          Gets the number of word parts.
 long getNumWordPartsMain(CumKind cumKind)
          Gets the number of word parts in main text.
 long getNumWordPartTrigrams(CumKind cumKind)
          Gets the number of word part trigrams.
 long getNumWordPartTrigramsMain(CumKind cumKind)
          Gets the number of word part trigrams in main text.
 long getNumWords(CumKind cumKind)
          Gets the number of words.
 long getNumWordsMain(CumKind cumKind)
          Gets the number of words in main text.
 long getNumWordTrigrams(CumKind cumKind)
          Gets the number of word trigrams.
 long getNumWordTrigramsMain(CumKind cumKind)
          Gets the number of word trigrams in main text.
 WorkPart getParent()
          Gets the parent.
 WorkPart getPrevWorkPartWithText()
          Gets the previous work part with text.
 long getSummaryCount(CumKind cumKind, FeatureKind featureKind, Arity arity, MainKind mainKind)
          Gets a summary count.
 SummaryCounts getSummaryCounts(CumKind cumKind)
          Gets the summary counts.
 SummaryCounts getSummaryCountsCum()
          Gets the cumulative summary counts.
 SummaryCounts getSummaryCountsNonCum()
          Gets the non-cumulative summary counts.
 java.lang.String getTitle()
          Gets the title.
 java.lang.String getType()
          Gets the type.
 java.lang.String getUnadornedXml()
          Gets the unadorned XML for the work part.
 WordPart[] getWordParts()
          Gets the word parts in the work part.
 Word[] getWords()
          Gets the words in the work part.
 Work getWork()
          Gets the work.
 int getWorkOrdinal()
          Gets the work ordinal.
 boolean hasChildren()
          Returns true if the work part has children.
 boolean hasText()
          Returns true if the work part has text.
 boolean hasWords()
          Returns true if the work part has tagged words.
static WorkPart[] sort(java.util.Collection<WorkPart> collection, WorkPart.SortOption... options)
          Sorts a collection of work parts.
static void sort(WorkPart[] array, WorkPart.SortOption... options)
          Sorts an array of work parts.
 
Methods inherited from class edu.northwestern.at.monk.model.TaggedObject
getTag
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

get

public static WorkPart get(java.lang.String tag)
Gets a work part by tag.

Parameters:
tag - Tag.
Returns:
Work part, or null if none.

getAll

public static <T extends WorkPart> java.util.Collection<T> getAll()
Gets all the work parts.

Returns:
Unmodificable collection of all the work parts in case and diacritical-insensitive alphabetical order first by stripped corpus title, then by stripeed work title, then by work part ordinal.

find

public static <T extends WorkPart> java.util.Collection<T> find(SearchCriterion... criteria)
                                                     throws ModelException
Finds work parts.

Parameters:
criteria - Search criteria.
Returns:
Collection of work parts, in an undefined order. If you want the result to be ordered, you must call a sort method.
Throws:
ModelException -
Unable to execute search

find

public static <T extends WorkPart> java.util.Collection<T> find(java.util.Collection<SearchCriterion> criteria)
                                                     throws ModelException
Finds work parts.

Parameters:
criteria - Collection of search criteria.
Returns:
Collection of work parts, in an undefined order. If you want the result to be ordered, you must call a sort method.
Throws:
ModelException -
Unable to execute search

find

public static <T extends WorkPart> java.util.Collection<T> find(SearchCriteria criteria)
                                                     throws ModelException
Finds work parts.

Parameters:
criteria - Search criteria.
Returns:
Collection of work parts, in an undefined order. If you want the result to be ordered, you must call a sort method.
Throws:
ModelException -
Unable to execute search

sort

public static void sort(WorkPart[] array,
                        WorkPart.SortOption... options)
Sorts an array of work parts.

Parameters:
array - Array of work parts.
options - Sort options, or null to use the natural ordering.

sort

public static WorkPart[] sort(java.util.Collection<WorkPart> collection,
                              WorkPart.SortOption... options)
Sorts a collection of work parts.

Parameters:
collection - Collection of work parts.
options - Sort options, or null to use the natural ordering.
Returns:
Sorted array of work parts.

getTitle

public java.lang.String getTitle()
Gets the title.

Returns:
The title of the work part.

getType

public java.lang.String getType()
Gets the type.

Returns:
The type of the work part.

getParent

public WorkPart getParent()
Gets the parent.

Returns:
The parent of the work part in the work part tree. Null for the root of a tree (a work).

getNumChildren

public int getNumChildren()
Gets the number of children.

Returns:
The number of children of the work part in the work part tree.

getChildren

public java.util.List<WorkPart> getChildren()
Gets the children.

Returns:
An unmodifiable list of the children of the work part in the work part tree.

getWork

public Work getWork()
Gets the work.

Returns:
The work to which the work part belongs.

getWorkOrdinal

public int getWorkOrdinal()
Gets the work ordinal.

Returns:
The ordinal of the work part within its work, in preorder traversal of the work part tree, with the root of the tree (the work) having ordinal 0.

getLevel

public int getLevel()
Gets the level.

Returns:
The level of the work part in the work part tree, with the root of the tree (the work) having level 0.

hasChildren

public boolean hasChildren()
Returns true if the work part has children.

This condition is the same as numChildren > 0.

Returns:
True if the work part has child parts, false if it is a leaf note of the work part tree.

hasText

public boolean hasText()
Returns true if the work part has text.

This condition is the same as getHtmlText() != null.

Returns:
True if the work part has text.

hasWords

public boolean hasWords()
Returns true if the work part has tagged words.

This condition is the same as numWordsNonCum > 0.

Returns:
True if the work part has tagged words.

getSummaryCountsCum

public SummaryCounts getSummaryCountsCum()
Gets the cumulative summary counts.

Returns:
The cumulative summary counts.

getSummaryCountsNonCum

public SummaryCounts getSummaryCountsNonCum()
Gets the non-cumulative summary counts.

Returns:
The non-cumulative summary counts.

getSummaryCounts

public SummaryCounts getSummaryCounts(CumKind cumKind)
Gets the summary counts.

Specified by:
getSummaryCounts in interface Container
Parameters:
cumKind - Kind of count: CumKind.CUM or CumKind.NON_CUM.
Returns:
The summary counts.

getSummaryCount

public long getSummaryCount(CumKind cumKind,
                            FeatureKind featureKind,
                            Arity arity,
                            MainKind mainKind)
Gets a summary count.

Specified by:
getSummaryCount in interface Container
Parameters:
cumKind - Kind of count: CumKind.CUM or CumKind.NON_CUM. (Ignored.)
featureKind - Feature kind: FeatureKind.WORD or FeatureKind.WORD_PART.
arity - Arity: Arity.UNIGRAM, Arity.BIGRAM or Arity.TRIGRAM.
mainKind - Main kind: MainKind.ALL_TEXT or MainKind.MAIN_TEXT.
Returns:
Summary count.

getNumWords

public long getNumWords(CumKind cumKind)
Gets the number of words.

Parameters:
cumKind - Kind of count: CumKind.CUM or CumKind.NON_CUM.
Returns:
The number of words.

getNumWordsMain

public long getNumWordsMain(CumKind cumKind)
Gets the number of words in main text.

Parameters:
cumKind - Kind of count: CumKind.CUM or CumKind.NON_CUM.
Returns:
The number of words in main text.

getNumWordBigrams

public long getNumWordBigrams(CumKind cumKind)
Gets the number of word bigrams.

Parameters:
cumKind - Kind of count: CumKind.CUM or CumKind.NON_CUM.
Returns:
The number of word bigrams.

getNumWordBigramsMain

public long getNumWordBigramsMain(CumKind cumKind)
Gets the number of word bigrams in main text.

Parameters:
cumKind - Kind of count: CumKind.CUM or CumKind.NON_CUM.
Returns:
The number of word bigrams in main text.

getNumWordTrigrams

public long getNumWordTrigrams(CumKind cumKind)
Gets the number of word trigrams.

Parameters:
cumKind - Kind of count: CumKind.CUM or CumKind.NON_CUM.
Returns:
The number of word trigrams.

getNumWordTrigramsMain

public long getNumWordTrigramsMain(CumKind cumKind)
Gets the number of word trigrams in main text.

Parameters:
cumKind - Kind of count: CumKind.CUM or CumKind.NON_CUM.
Returns:
The number of word trigrams in main text.

getNumWordParts

public long getNumWordParts(CumKind cumKind)
Gets the number of word parts.

Parameters:
cumKind - Kind of count: CumKind.CUM or CumKind.NON_CUM.
Returns:
The number of word parts.

getNumWordPartsMain

public long getNumWordPartsMain(CumKind cumKind)
Gets the number of word parts in main text.

Parameters:
cumKind - Kind of count: CumKind.CUM or CumKind.NON_CUM.
Returns:
The number of word parts in main text.

getNumWordPartBigrams

public long getNumWordPartBigrams(CumKind cumKind)
Gets the number of word part bigrams.

Parameters:
cumKind - Kind of count: CumKind.CUM or CumKind.NON_CUM.
Returns:
The number of word part bigrams.

getNumWordPartBigramsMain

public long getNumWordPartBigramsMain(CumKind cumKind)
Gets the number of word part bigrams in main text.

Parameters:
cumKind - Kind of count: CumKind.CUM or CumKind.NON_CUM.
Returns:
The number of word part bigrams in main text.

getNumWordPartTrigrams

public long getNumWordPartTrigrams(CumKind cumKind)
Gets the number of word part trigrams.

Parameters:
cumKind - Kind of count: CumKind.CUM or CumKind.NON_CUM.
Returns:
The number of word part trigrams.

getNumWordPartTrigramsMain

public long getNumWordPartTrigramsMain(CumKind cumKind)
Gets the number of word part trigrams in main text.

Parameters:
cumKind - Kind of count: CumKind.CUM or CumKind.NON_CUM.
Returns:
The number of word part trigrams in main text.

getNumSentences

public long getNumSentences(CumKind cumKind)
Gets the number of sentences.

Parameters:
cumKind - Kind of count: CumKind.CUM or CumKind.NON_CUM.
Returns:
The number of sentences.

getNumSentencesMain

public long getNumSentencesMain(CumKind cumKind)
Gets the number of sentences in main text.

Parameters:
cumKind - Kind of count: CumKind.CUM or CumKind.NON_CUM.
Returns:
The number of sentences in main text.

getHtmlText

public java.lang.String getHtmlText()
                             throws ModelException
Gets the HTML text for the work part.

Returns:
The text for the work part formatted as HTML, or null if none.
Throws:
ModelException -
Unable to get HTML text.

getAdornedXml

public java.lang.String getAdornedXml()
                               throws ModelException
Gets the XML for the work part.

Returns:
The MorphAdorned XML for the work part, or null if none.
Throws:
ModelException -
Unable to get XML.

getUnadornedXml

public java.lang.String getUnadornedXml()
                                 throws ModelException
Gets the unadorned XML for the work part.

Returns:
The unadorned XML for the work part, or null if none.
Throws:
ModelException -
Unable to get XML.

getDescendants

public java.util.Collection<WorkPart> getDescendants()
Gets the descendants.

Returns:
Collection of descendants, including the work part itself, in order by work ordinal.

getNextWorkPartWithText

public WorkPart getNextWorkPartWithText()
Gets the next work part with text.

Returns:
Next work part with text, or null if none.

getPrevWorkPartWithText

public WorkPart getPrevWorkPartWithText()
Gets the previous work part with text.

Returns:
Previous work part with text, or null if none.

getWords

public Word[] getWords()
                throws ModelException
Gets the words in the work part.

Returns:
Array of words in the work part, in order.
Throws:
ModelException -
Could not get word list

getWordParts

public WordPart[] getWordParts()
                        throws ModelException
Gets the word parts in the work part.

Returns:
Array of word parts in the work part, in order.
Throws:
ModelException -
Count not get word part list.

compareTo

public int compareTo(WorkPart other)
Compares this instance with another.

Work parts are ordered fist in case and diacritical-insensitve alphabetical order by stripped corpus title, then in case and diacritical-insensitive alphabetical order by stripped work title, then by work part ordinal within works.

Specified by:
compareTo in interface java.lang.Comparable<WorkPart>
Parameters:
other - The other instance to be compared.
Returns:
A negative integer, zero, or a positive integer as this instance is less than, equal to, or greater than the specified instance.