|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object edu.northwestern.at.wordhoard.swing.calculator.modelutils.WordUtils
public class WordUtils
Word occurrence utilities.
Field Summary | |
---|---|
protected static java.util.TreeMap |
punctuationMap
Punctuation map. |
protected static java.util.HashMap |
wordClassToMajorWordClassMap
Word class to major word class map. |
Constructor Summary | |
---|---|
protected |
WordUtils()
Don't allow instantiation but do allow overrides. |
Method Summary | |
---|---|
static java.lang.String |
createCompoundWordClassQueryString(java.lang.String compoundWordClass)
Create query string portion for looking up a compound word class. |
protected static void |
createPunctuationMap()
Create punctuation map. |
static java.lang.String[] |
extractLemmata(java.lang.String compoundLemma)
Extract lemmata from a compound lemma string. |
static java.lang.String[] |
extractSpellingAndCompoundWordClass(java.lang.String spellingAndCompoundWordClass)
Parse spelling and compound word class string. |
static java.lang.String[] |
extractWordClassTags(java.lang.String spellingAndCompoundWordClass)
Extract word class tags from a spelling/compound word class. |
static java.lang.String |
getCompoundLemma(Word word)
Gets the compound lemma. |
static java.lang.String |
getCompoundWordClass(Word word)
Gets the compound word class. |
static java.lang.String |
getDisplayableText(Word[] wordOccurrences,
boolean displayLemmaForms,
java.lang.String eolChars)
Get displayable text for an array of adjacent WordOccurrences. |
static java.lang.String |
getDisplayableText(Word[] words,
boolean displayLemmaForms,
java.lang.String eolChars,
java.lang.String[] highlightWords,
int[] highlightBracket,
boolean highlightsAreLemmata,
WordSet wordSet)
Get displayable html text for an array of adjacent Words. |
static java.lang.String |
getDisplayableText(Word[] wordOccurrences,
java.lang.String eolChars)
Get displayable text for an array of adjacent WordOccurrences. |
static java.lang.String |
getDisplayableWordText(Spelling word,
int wordForm)
Get displayable word text. |
static java.lang.String |
getIsVerse(Word word)
Gets the "is verse" flag. |
static java.lang.String[] |
getIsVerseValues()
Get list of distinct isVerse values. |
static java.util.List |
getLeftSpan(Word word,
int leftSpan)
Get span of words to left of a specified word. |
static Word[] |
getLemmaOccurrences(Spelling lemma,
WorkPart[] workParts)
Perform a lemma query. |
static java.lang.String[] |
getLemmaTags(Word word)
Gets the lemma tags for a word. |
static java.lang.String |
getMajorWordClassForWordClass(java.lang.String wordClass)
Get major word class for a word class. |
static java.lang.String |
getMetricalShape(Word word)
Gets the metrical shape. |
static java.lang.String[] |
getMetricalShapeValues()
Get list of distinct metrical shape values. |
static java.lang.String |
getPrintablePunctuation(java.lang.String punctuation)
Convert punctuation string into printable string. |
static java.util.List |
getRightSpan(Word word,
int rightSpan)
Get span of words to right of a specified word. |
static Word[] |
getSpan(Word word,
int leftSpan,
int rightSpan)
Get surrounding words of a specified word. |
static Word[] |
getSpanFromCache(Word word,
int leftSpan,
int rightSpan)
Get surrounding words of a specified word. |
static java.lang.String |
getSpeakerGender(Word word)
Gets the speaker gender. |
static java.lang.String[] |
getSpeakerGenders()
Get list of speaker gender values. |
static java.lang.String[] |
getSpeakerMortalities()
Get list of speaker mortality values. |
static java.lang.String |
getSpeakerMortality(Word word)
Gets the speaker mortality. |
static java.lang.String |
getSpellingAndCompoundWordClass(Word word)
Gets the lower case word with the trailing compound word class. |
static Spelling |
getSpellingForString(java.lang.String wordText)
Get Spelling from string. |
static Word[] |
getSpellingOccurrences(Spelling spelling,
WorkPart[] workParts)
Perform a spelling query. |
static Spelling[] |
getSpellingsByInitialString(java.lang.String initialString)
Finds spellings by matching an initial string of characters. |
static Word[] |
getWordOccurrences(Corpus corpus,
int wordForm,
Spelling word)
Get word occurrences for a word in a specified corpus. |
static Word[] |
getWordOccurrences(WorkPart[] workParts,
int wordForm,
Spelling word)
Get word occurrences for a word in specified work parts. |
static Word[] |
getWordOccurrences(WorkPart workPart,
int wordForm,
Spelling word)
Get word occurrences for a word in a specified work part. |
static Word[] |
getWordOccurrences(WorkSet workSet,
int wordForm,
Spelling word)
Get word occurrences for a word in a specified work set. |
static int[] |
getWordPartCounts(Word[] words)
Get word part counts for a batch of words. |
static WordPartData[] |
getWordPartData(Word[] words)
Get word parts for a batch of words. |
static Word[] |
getWordsByTags(java.util.Collection tags)
Gets word occurrences by tag. |
static boolean |
isVerseExists(java.lang.String isVerseText)
See if specified "isVerse" value exists. |
protected static void |
makeWordClassToMajorWordClassMap()
Construct word class to major word class map. |
static boolean |
metricalShapeExists(java.lang.String metricalShape)
See if specified metrical shape value exists. |
static Word[] |
performWordQuery(java.lang.String queryString,
java.lang.String[] paramNames,
java.lang.Object[] paramValues)
Perform word query. |
static boolean |
speakerGenderExists(java.lang.String speakerGenderText)
See if specified speaker gender exists. |
static boolean |
speakerMortalityExists(java.lang.String speakerMortalityText)
See if specified speaker mortality exists. |
static boolean |
spellingExists(java.lang.String spellingText)
See if specified spelling exists. |
static java.lang.String |
stripSpelling(java.lang.String s)
Removes spelling from a tagged word. |
static java.lang.String |
stripWordClass(java.lang.String s)
Removes word class tagging from a word or phrase. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static java.util.TreeMap punctuationMap
protected static java.util.HashMap wordClassToMajorWordClassMap
Constructor Detail |
---|
protected WordUtils()
Method Detail |
---|
public static Word[] performWordQuery(java.lang.String queryString, java.lang.String[] paramNames, java.lang.Object[] paramValues)
queryString
- The query string.paramNames
- Parameter names used in the query.paramValues
- Parameter values for each paramName.
public static Word[] getWordsByTags(java.util.Collection tags)
tags
- Collection of word tags.
PersistenceException
public static Word[] getSpan(Word word, int leftSpan, int rightSpan)
word
- Word for which to get span.leftSpan
- # of words to left of
specified word to retrieve.rightSpan
- # of words to right of
specified word to retrieve.
public static Word[] getSpanFromCache(Word word, int leftSpan, int rightSpan)
word
- Word for which to get span,
i.e., the anchor word.leftSpan
- # of words to left of
specified word to retrieve.rightSpan
- # of words to right of
specified word to retrieve.
This operates like getSpan above, but uses object model traversal instead of a database lookup. The assumption is that the relevant word objects have already been loaded into the cache.
public static java.util.List getLeftSpan(Word word, int leftSpan)
word
- Word for which to get left span,
i.e., the anchor word.leftSpan
- # of words to left of
specified word to retrieve.
public static java.util.List getRightSpan(Word word, int rightSpan)
word
- Word for which to get right span,
i.e., the anchor word.rightSpan
- # of words to right of
specified word to retrieve.
public static java.lang.String[] extractSpellingAndCompoundWordClass(java.lang.String spellingAndCompoundWordClass)
spellingAndCompoundWordClass
- The spelling and compound
word class to look up.
Must be in the form
"spelling (wordclass)" .
public static java.lang.String createCompoundWordClassQueryString(java.lang.String compoundWordClass)
compoundWordClass
- The compound word class.
public static Word[] getSpellingOccurrences(Spelling spelling, WorkPart[] workParts)
spelling
- Spelling to look up.workParts
- The work/work parts to search. public static Word[] getLemmaOccurrences(Spelling lemma, WorkPart[] workParts)
lemma
- Lemma to look up.workParts
- The work/work parts to search. public static Word[] getWordOccurrences(WorkPart[] workParts, int wordForm, Spelling word)
workParts
- The work parts.wordForm
- The word form.word
- The word to look up.
public static Word[] getWordOccurrences(WorkPart workPart, int wordForm, Spelling word)
workPart
- The work part.wordForm
- The word form.word
- The word to look up.
public static Word[] getWordOccurrences(Corpus corpus, int wordForm, Spelling word)
corpus
- The corpus.wordForm
- The word form.word
- The word to look up.
public static Word[] getWordOccurrences(WorkSet workSet, int wordForm, Spelling word)
workSet
- The work set.wordForm
- The word form.word
- The word to look up.
public static java.lang.String getDisplayableText(Word[] words, boolean displayLemmaForms, java.lang.String eolChars, java.lang.String[] highlightWords, int[] highlightBracket, boolean highlightsAreLemmata, WordSet wordSet)
words
- Array of Words to display.displayLemmaForms
- Display lemma forms instead of spellings.eolChars
- String for end of line.highlightWords
- Highlight words in this list.highlightBracket
- Interval in which to highlight words.highlightsAreLemmata
- True if highlight words are lemma forms.wordSet
- Word set containing collection of words
which are actually part of the context.
Context words not in the word set will
display with strike-through marking.
May be null.
public static java.lang.String getDisplayableText(Word[] wordOccurrences, java.lang.String eolChars)
wordOccurrences
- Array of word occurrences.eolChars
- String for end of line.
public static java.lang.String getDisplayableText(Word[] wordOccurrences, boolean displayLemmaForms, java.lang.String eolChars)
wordOccurrences
- Array of word occurrences.displayLemmaForms
- True to display lemma form of text.eolChars
- String for end of line.
public static java.lang.String getPrintablePunctuation(java.lang.String punctuation)
punctuation
- The original punctuation string.
public static boolean speakerGenderExists(java.lang.String speakerGenderText)
speakerGenderText
- The speaker gender text.
public static boolean speakerMortalityExists(java.lang.String speakerMortalityText)
speakerMortalityText
- The speaker mortality text.
public static java.lang.String[] getSpeakerGenders()
public static java.lang.String[] getSpeakerMortalities()
public static boolean isVerseExists(java.lang.String isVerseText)
isVerseText
- The "isVerse" text.
public static java.lang.String[] getIsVerseValues()
public static boolean metricalShapeExists(java.lang.String metricalShape)
metricalShape
- The metrical shape to check.
public static java.lang.String[] getMetricalShapeValues()
public static java.lang.String[] extractWordClassTags(java.lang.String spellingAndCompoundWordClass)
spellingAndCompoundWordClass
- The combined spelling
and word class(es).
public static java.lang.String[] extractLemmata(java.lang.String compoundLemma)
compoundLemma
- The compound lemma string.
public static boolean spellingExists(java.lang.String spellingText)
spellingText
- The spelling text.
public static Spelling[] getSpellingsByInitialString(java.lang.String initialString)
initialString
- The initial spelling text string.
public static Spelling getSpellingForString(java.lang.String wordText)
wordText
- The word text.
public static java.lang.String stripWordClass(java.lang.String s)
s
- The string from which to remove any word class tags.
Example:
String wc = stripWordClass( "think (v)" );
returns think in wc.
public static java.lang.String stripSpelling(java.lang.String s)
s
- The string from which to remove the spelling.
Form is "spelling (wordclass)".
Example:
String wc = stripSpelling( "think (v)" );
returns v in wc.
public static java.lang.String getCompoundWordClass(Word word)
word
- The word for which to return the
compound word class.
public static java.lang.String getSpellingAndCompoundWordClass(Word word)
word
- The word for which to return the
spelling and compound word class.
public static java.lang.String getCompoundLemma(Word word)
word
- The word for which to return the compound lemma.
public static java.lang.String[] getLemmaTags(Word word)
word
- The word for which to return the lemma tags.
public static java.lang.String getSpeakerGender(Word word)
word
- The word for which to return the speaker gender.
If a word has mixed gender speakers, "U" is returned.
public static java.lang.String getSpeakerMortality(Word word)
word
- The word for which to return the speaker mortality.
If a word has mixed speaker mortalities, "U" is returned.
public static java.lang.String getIsVerse(Word word)
word
- The word for which to return the is verse flag.
public static java.lang.String getMetricalShape(Word word)
word
- The word for which to return the metrical shape.
public static java.lang.String getDisplayableWordText(Spelling word, int wordForm)
word
- The word text.wordForm
- The word form type.
protected static void makeWordClassToMajorWordClassMap()
public static java.lang.String getMajorWordClassForWordClass(java.lang.String wordClass)
wordClass
- The word class.
public static int[] getWordPartCounts(Word[] words)
words
- Array of Word.
The word part counts are returned in the same order as the entries in the words array.
public static WordPartData[] getWordPartData(Word[] words)
words
- Array of Word.
The word part counts are returned in the same order as the entries in the words array.
protected static void createPunctuationMap()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |