edu.northwestern.at.monk.model
Class Concordance

java.lang.Object
  extended by edu.northwestern.at.monk.model.Concordance

public class Concordance
extends java.lang.Object

A concordance.

Concordances are used to construct traditional "KWIC" ("keyword in context") lists of the results of a word search.

Given a collection of word search results, call the static method Concordance.find to generate the concordance, specifying the distance for the number of words to the left and right of the matches that you want to find.

Concordance.find returns a collection of concordance objects for the words, in the same order as the words. For each of these objects, methods are provided to get the left and right context as well as the matching word in the middle.

See Also:
MONK Datastore Overview, Licensing Agreement

Constructor Summary
Concordance(java.util.Collection<Word> left, Word word, java.util.Collection<Word> right)
          Creates a new concordance.
 
Method Summary
static java.util.Collection<Concordance> find(long distance, java.util.Collection<Word> words)
          Finds concordances.
static java.util.Collection<Concordance> find(long distance, Word... words)
          Finds concordances.
 java.util.Collection<Word> getLeft()
          Gets the words to the left of the word.
 java.lang.String getLeftText()
          Gets the text to the left of the word formatted as a string.
 java.lang.String getLeftText(int trunc)
          Gets the text to the left of the word formatted as a string.
 java.util.Collection<Word> getRight()
          Gets the words to the right of the word.
 java.lang.String getRightText()
          Gets the text to the right of the word formatted as a string.
 java.lang.String getRightText(int trunc)
          Gets the text to the right of the word formatted as a string.
 Word getWord()
          Gets the word.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Concordance

public Concordance(java.util.Collection<Word> left,
                   Word word,
                   java.util.Collection<Word> right)
Creates a new concordance.

Parameters:
left - Words to left of word.
word - Word.
right - Words to right of word.
Method Detail

find

public static java.util.Collection<Concordance> find(long distance,
                                                     Word... words)
                                              throws ModelException
Finds concordances.

Parameters:
distance - The number of words to the left and the right to find for each word.
words - Words.
Returns:
A collection of concordances for the words, in the same order as the words.
Throws:
ModelException -
Could not get concordances

find

public static java.util.Collection<Concordance> find(long distance,
                                                     java.util.Collection<Word> words)
                                              throws ModelException
Finds concordances.

Parameters:
distance - The number of words to the left and the right to find for each word.
words - Collection of words.
Returns:
A collection of concordances for the words, in the same order as the words.
Throws:
ModelException -
Could not get concordances

getLeft

public java.util.Collection<Word> getLeft()
Gets the words to the left of the word.

Returns:
The words to the left of the word.

getWord

public Word getWord()
Gets the word.

Returns:
Word.

getRight

public java.util.Collection<Word> getRight()
Gets the words to the right of the word.

Returns:
The words to the right of the word.

getLeftText

public java.lang.String getLeftText(int trunc)
Gets the text to the left of the word formatted as a string.

Parameters:
trunc - Maximum number of characters to return, or 0 if no limit.
Returns:
Text to left of word as string, truncated at the beginning if necessary.

getLeftText

public java.lang.String getLeftText()
Gets the text to the left of the word formatted as a string.

Returns:
Text to left of word as string.

getRightText

public java.lang.String getRightText(int trunc)
Gets the text to the right of the word formatted as a string.

Parameters:
trunc - Maximum number of characters to return, or 0 if no limit.
Returns:
Text to right of word as string, truncated at the end if necessary.

getRightText

public java.lang.String getRightText()
Gets the text to the right of the word formatted as a string.

Returns:
Text to right of word as string.