net.java.sen.dictionary
Class Sentence

java.lang.Object
  extended by net.java.sen.dictionary.Sentence

public class Sentence
extends Object

A Sentence represents a character array to be morphologically analysed. It supports breaking ignore spans, which prevent certain characters from being considered for tokenisation, and reading constraints which restrict the returned morphemes at a certain position to those with the given reading.


Constructor Summary
Sentence(char[] characters)
          Creates a sentence with the given characters
Sentence(String text)
          Creates a sentence with the given string
 
Method Summary
 char[] getCharacters()
          Returns the underlying characters of this Sentence
 Reading getReadingConstraint(int position)
          Gets the reading constraint at the given position, if any
 SentenceIterator iterator()
          Returns a SentenceIterator that obeys the defined breaking ignore spans, reading constraints, and skips space characters
 void removeReadingConstraint(int position)
          Removes the reading constraint at the given position, if any
 void setBreakingIgnoreSpan(int position, short length)
          Sets a breaking ignore span.
 void setReadingConstraint(Reading constraint)
          Sets a reading constraint on the Sentence starting at position; any existing constraints that overlap the new constraint will be removed.
 SentenceIterator unconstrainedIterator(int position)
          Returns a SentenceIterator that obeys the defined breaking ignore spans, skips space characters, but ignores reading constraints
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Sentence

public Sentence(char[] characters)
Creates a sentence with the given characters

Parameters:
characters - The sentence's characters

Sentence

public Sentence(String text)
Creates a sentence with the given string

Parameters:
text - The string containing the sentence's characters
Method Detail

setBreakingIgnoreSpan

public void setBreakingIgnoreSpan(int position,
                                  short length)
Sets a breaking ignore span. length characters starting at position will be ignored during iteration; no iterated subsequence of characters will cross the ignored span.

Parameters:
position - The position of the ignore span to set
length - The length of the ignore span to set

setReadingConstraint

public void setReadingConstraint(Reading constraint)
Sets a reading constraint on the Sentence starting at position; any existing constraints that overlap the new constraint will be removed.

Parameters:
constraint - The constraint to set

getReadingConstraint

public Reading getReadingConstraint(int position)
Gets the reading constraint at the given position, if any

Parameters:
position - The position to get the constraint at
Returns:
The constraint if present, or null

removeReadingConstraint

public void removeReadingConstraint(int position)
Removes the reading constraint at the given position, if any

Parameters:
position - The position to remove the constraint from

iterator

public SentenceIterator iterator()
Returns a SentenceIterator that obeys the defined breaking ignore spans, reading constraints, and skips space characters

Returns:
The iterator

unconstrainedIterator

public SentenceIterator unconstrainedIterator(int position)
Returns a SentenceIterator that obeys the defined breaking ignore spans, skips space characters, but ignores reading constraints

Parameters:
position - The position to start iterating from
Returns:
The iterator

getCharacters

public char[] getCharacters()
Returns the underlying characters of this Sentence

Returns:
The underlying characters


Copyright © 2012. All Rights Reserved.