Package org.egothor.stemmer
Enum Class WordTraversalDirection
- All Implemented Interfaces:
Serializable,Comparable<WordTraversalDirection>,Constable
Defines the logical direction in which word characters are traversed.
The same direction is used consistently in two places:
- when a word key is traversed through a trie
- when patch commands are serialized and then applied back to a source word
FORWARD means that processing starts at the logical beginning of the
stored form and moves toward its end. BACKWARD means that processing
starts at the logical end of the stored form and moves toward its beginning.
For traditional suffix-oriented Egothor data, BACKWARD matches the
historical behavior. For right-to-left languages whose affix logic should
operate on the stored form as written, FORWARD can be used so that
neither trie construction nor patch application needs to reverse words
externally.
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>> -
Enum Constant Summary
Enum Constants -
Method Summary
Modifier and TypeMethodDescriptionintlogicalIndex(int length, int traversalOffset) Returns the logical character index addressed by the supplied traversal offset.intstartIndex(int length) Returns the traversal start index for a character sequence of the supplied length.char[]toTraversalCharacters(String word) Returns the characters of the supplied word in this traversal order.traversalPathToLogicalKey(CharSequence traversalPath) Converts a path represented in traversal order back to the logical key form.static WordTraversalDirectionReturns the enum constant of this class with the specified name.static WordTraversalDirection[]values()Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
FORWARD
Traverses a word from its logical beginning toward its logical end. -
BACKWARD
Traverses a word from its logical end toward its logical beginning.
-
-
Method Details
-
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)- Parameters:
name- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException- if this enum class has no constant with the specified nameNullPointerException- if the argument is null
-
startIndex
public int startIndex(int length) Returns the traversal start index for a character sequence of the supplied length.- Parameters:
length- sequence length- Returns:
- start index, or
-1when the sequence is empty and traversal should therefore not begin - Throws:
IllegalArgumentException- iflengthis negative
-
logicalIndex
public int logicalIndex(int length, int traversalOffset) Returns the logical character index addressed by the supplied traversal offset.A traversal offset of
0addresses the first character seen in this direction,1the second character, and so on.- Parameters:
length- sequence lengthtraversalOffset- zero-based offset from the traversal start- Returns:
- corresponding logical character index
- Throws:
IllegalArgumentException- if any argument is outside the valid range
-
toTraversalCharacters
Returns the characters of the supplied word in this traversal order.- Parameters:
word- source word- Returns:
- traversal-ordered characters
- Throws:
NullPointerException- ifwordisnull
-
traversalPathToLogicalKey
Converts a path represented in traversal order back to the logical key form.- Parameters:
traversalPath- key path in traversal order- Returns:
- logical key form
- Throws:
NullPointerException- iftraversalPathisnull
-