edu.northwestern.at.wordhoard.model
Class Corpus

java.lang.Object
  extended by edu.northwestern.at.wordhoard.model.Corpus
All Implemented Interfaces:
CanCountWords, CanGetRelFreq, GroupingObject, HasTag, PersistentObject, SearchCriterion, SearchDefaults, java.io.Serializable

public class Corpus
extends java.lang.Object
implements PersistentObject, CanCountWords, GroupingObject, SearchDefaults, SearchCriterion, CanGetRelFreq, java.io.Serializable, HasTag

A corpus.

Each corpus has the following attributes:

See Also:
Serialized Form

Constructor Summary
Corpus()
          Creates a new corpus.
 
Method Summary
 void addTconView(TconView tconView)
          Adds a table of contents view.
 void addWork(Work work)
          Adds a work.
 void appendDescription(TextLine line, FontInfo romanFontInfo, FontInfo[] fontInfo)
          Appends a description to a text line.
 boolean equals(java.lang.Object obj)
          Returns true if some other object is equal to this one.
 byte getCharset()
          Gets the character set used by the corpus.
 Spelling getGroupingSpelling(int numHits)
          Gets the spelling of the grouping object.
 java.lang.Long getId()
          Gets the unique id.
 java.lang.Class getJoinClass()
          Gets the join class.
 int getMaxWordPathLength()
          Gets the maximum word path length.
 int getNumLines()
          Gets the number of lines in the corpus.
 int getNumWords()
          Gets the number of words in the corpus.
 int getNumWorkParts()
          Gets the number of work parts in the corpus.
 int getNumWorks()
          Gets the number of works in the corpus.
 int getOrdinal()
          Gets the ordinal.
 byte getPosType()
          Gets the part of speech taxonomy used by the corpus.
 float getRelFreq(int count)
          Gets the relative frequency of a word count in the corpus.
 java.lang.String getReportPhrase()
          Gets the report phrase.
 SearchCriterion getSearchDefault(java.lang.Class cls)
          Gets a search criterion default value.
 java.lang.String getTag()
          Gets the tag.
 TaggingData getTaggingData()
          Gets the tagging data flags.
 java.util.List getTconViews()
          Gets the list of table of contents views.
 java.lang.String getTitle()
          Gets the title.
 java.lang.String getTranDescription()
          Gets the translations description.
 java.lang.String getTranslations()
          Gets the translations.
 java.util.List getTranslationsAsList()
          Gets the translations as a list.
 java.lang.String getWhereClause()
          Gets the Hibernate where clause.
 Work getWorkByTag(java.lang.String tag)
          Gets a work by tag.
 java.util.Map getWorkMap()
          Gets a map from work tags to works.
 java.util.Set getWorks()
          Gets the works.
 int hashCode()
          Returns a hash code for the object.
 boolean hasTranslations()
          Returns true if the corpus has available translations.
 void removeWork(Work work)
          Removes a work.
 void setArg(org.hibernate.Query q, org.hibernate.Session session)
          Sets the Hibernate query argument.
 void setCharset(byte charset)
          Sets the character set used by the corpus.
 void setMaxWordPathLength(int maxWordPathLength)
          Sets the maximum word path length.
 void setNumLines(int numLines)
          Sets the number of lines in the corpus.
 void setNumWords(int numWords)
          Sets the number of words in the corpus.
 void setNumWorkParts(int numWorkParts)
          Sets the number of work parts in the corpus.
 void setPosType(byte posType)
          Sets the part of speech taxonomy used by the corpus.
 void setTag(java.lang.String tag)
          Sets the tag.
 void setTaggingData(TaggingData taggingData)
          Sets the tagging data flags.
 void setTitle(java.lang.String title)
          Sets the title.
 void setTranDescription(java.lang.String tranDescription)
          Sets the translations description.
 void setTranslations(java.lang.String translations)
          Sets the translations.
 java.lang.String toString()
          Gets a string representation of the corpus.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Corpus

public Corpus()
Creates a new corpus.

Method Detail

getId

public java.lang.Long getId()
Gets the unique id.

Specified by:
getId in interface PersistentObject
Returns:
The unique id.

getTag

public java.lang.String getTag()
Gets the tag.

Specified by:
getTag in interface HasTag
Returns:
The tag.

setTag

public void setTag(java.lang.String tag)
Sets the tag.

Parameters:
tag - The tag.

getTitle

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

Returns:
The title.

setTitle

public void setTitle(java.lang.String title)
Sets the title.

Parameters:
title - The title.

getCharset

public byte getCharset()
Gets the character set used by the corpus.

Returns:
TextParams.ROMAN or TextParams.GREEK.

setCharset

public void setCharset(byte charset)
Sets the character set used by the corpus.

Parameters:
charset - TextParams.ROMAN or TextParams.GREEK.

getPosType

public byte getPosType()
Gets the part of speech taxonomy used by the corpus.

Returns:
Pos.ENGLISH or Pos.GREEK.

setPosType

public void setPosType(byte posType)
Sets the part of speech taxonomy used by the corpus.

Parameters:
posType - Pos.ENGLISH or Pos.GREEK.

getTaggingData

public TaggingData getTaggingData()
Gets the tagging data flags.

Returns:
Tagging data flags.

setTaggingData

public void setTaggingData(TaggingData taggingData)
Sets the tagging data flags.

Parameters:
taggingData - Tagging data flags.

getWorks

public java.util.Set getWorks()
Gets the works.

Returns:
The works as an unmodifiable set.

addWork

public void addWork(Work work)
Adds a work.

Parameters:
work - The new work.

removeWork

public void removeWork(Work work)
Removes a work.

Parameters:
work - The work.

getNumWorks

public int getNumWorks()
Gets the number of works in the corpus.

Returns:
Number of works.

getNumWorkParts

public int getNumWorkParts()
Gets the number of work parts in the corpus.

Returns:
Number of work parts.

setNumWorkParts

public void setNumWorkParts(int numWorkParts)
Sets the number of work parts in the corpus.

Parameters:
numWorkParts - Number of work parts.

getNumLines

public int getNumLines()
Gets the number of lines in the corpus.

Returns:
Number of lines.

setNumLines

public void setNumLines(int numLines)
Sets the number of lines in the corpus.

Parameters:
numLines - Number of lines.

getNumWords

public int getNumWords()
Gets the number of words in the corpus.

Returns:
Number of words.

setNumWords

public void setNumWords(int numWords)
Sets the number of words in the corpus.

Parameters:
numWords - Number of words.

getMaxWordPathLength

public int getMaxWordPathLength()
Gets the maximum word path length.

Returns:
Maximum word path length.

setMaxWordPathLength

public void setMaxWordPathLength(int maxWordPathLength)
Sets the maximum word path length.

Parameters:
maxWordPathLength - Maximum word path length.

getTranslations

public java.lang.String getTranslations()
Gets the translations.

Returns a comma-delimited string listing all the available translations for the corpus. E.g., "English,German". If no translations are available, returns null.

Returns:
Available translations, or null if none.

hasTranslations

public boolean hasTranslations()
Returns true if the corpus has available translations.

Returns:
True if corpus has available translations.

getTranslationsAsList

public java.util.List getTranslationsAsList()
Gets the translations as a list.

Returns:
Available translations as a list of strings.

setTranslations

public void setTranslations(java.lang.String translations)
Sets the translations.

Parameters:
translations - Available translations as a comma- delimited string, or null if none.

getTranDescription

public java.lang.String getTranDescription()
Gets the translations description.

Returns:
The translations description, or null if none.

setTranDescription

public void setTranDescription(java.lang.String tranDescription)
Sets the translations description.

Parameters:
tranDescription - Translations description, or null if none.

getTconViews

public java.util.List getTconViews()
Gets the list of table of contents views.

Returns:
The list of table of contents view as an unmodifiable list.

addTconView

public void addTconView(TconView tconView)
Adds a table of contents view.

The new view is added to the end of the ordered list of views.

Parameters:
tconView - Table of contents view.

getOrdinal

public int getOrdinal()
Gets the ordinal.

Returns:
Ordinal.

getWorkMap

public java.util.Map getWorkMap()
Gets a map from work tags to works.

Returns:
A map from work tags to works.

getRelFreq

public float getRelFreq(int count)
Gets the relative frequency of a word count in the corpus.

Specified by:
getRelFreq in interface CanGetRelFreq
Parameters:
count - Word count.
Returns:
10,000 times count / number of words in corpus.

getWorkByTag

public Work getWorkByTag(java.lang.String tag)
Gets a work by tag.

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

getSearchDefault

public SearchCriterion getSearchDefault(java.lang.Class cls)
Gets a search criterion default value.

Specified by:
getSearchDefault in interface SearchDefaults
Parameters:
cls - Model class of search criterion.
Returns:
Default value for search criterion.

getJoinClass

public java.lang.Class getJoinClass()
Gets the join class.

Specified by:
getJoinClass in interface SearchCriterion
Returns:
The join class, or null if none.

getWhereClause

public java.lang.String getWhereClause()
Gets the Hibernate where clause.

Specified by:
getWhereClause in interface SearchCriterion
Returns:
The Hibernate where clause.

setArg

public void setArg(org.hibernate.Query q,
                   org.hibernate.Session session)
Sets the Hibernate query argument.

Specified by:
setArg in interface SearchCriterion
Parameters:
q - Hibernate query.
session - Hibernate session.

appendDescription

public void appendDescription(TextLine line,
                              FontInfo romanFontInfo,
                              FontInfo[] fontInfo)
Appends a description to a text line.

Specified by:
appendDescription in interface SearchCriterion
Parameters:
line - Text line.
romanFontInfo - Roman font info.
fontInfo - Array of font info indexed by character set.

getReportPhrase

public java.lang.String getReportPhrase()
Gets the report phrase.

Specified by:
getReportPhrase in interface GroupingObject
Returns:
The report phrase "in".

getGroupingSpelling

public Spelling getGroupingSpelling(int numHits)
Gets the spelling of the grouping object.

Specified by:
getGroupingSpelling in interface GroupingObject
Parameters:
numHits - Number of hits.
Returns:
The spelling of the grouping object.

toString

public java.lang.String toString()
Gets a string representation of the corpus.

Overrides:
toString in class java.lang.Object
Returns:
The title.

equals

public boolean equals(java.lang.Object obj)
Returns true if some other object is equal to this one.

The two corpora are equal if their tags are equal.

Specified by:
equals in interface GroupingObject
Overrides:
equals in class java.lang.Object
Parameters:
obj - The other object.
Returns:
True if this object equals the other object.

hashCode

public int hashCode()
Returns a hash code for the object.

Specified by:
hashCode in interface GroupingObject
Overrides:
hashCode in class java.lang.Object
Returns:
The hash code.