Package com.gengoai.hermes.lexicon
Class LexiconEntry
- java.lang.Object
-
- com.gengoai.hermes.lexicon.LexiconEntry
-
- All Implemented Interfaces:
Serializable
,Comparable<LexiconEntry>
public class LexiconEntry extends Object implements Serializable, Comparable<LexiconEntry>
An entry in a lexicon defining the lemma, probability, tag, and any constraints on matching- Author:
- David B. Bracewell
- See Also:
- Serialized Form
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static int
calculateTokenLength(@NonNull String phrase, @NonNull Language language)
Helper method for calculating the length in tokens of a phrase for a given language.int
compareTo(LexiconEntry o)
static LexiconEntry
empty()
Empty lexicon entry.static LexiconEntry
of(@NonNull String lemma, double probability, int tokenLength)
Constructs a LexiconEntry for the given lemma which has the given probability and token length.static LexiconEntry
of(@NonNull String lemma, double probability, String tag, int tokenLength)
Constructs a LexiconEntry for the given lemma which has the given probability, tag, and token length.static LexiconEntry
of(@NonNull String lemma, double probability, String tag, LyreExpression constraint, int tokenLength)
Constructs a LexiconEntry for the given lemma which has the given probability, tag, constraint, and token length.static LexiconEntry
of(@NonNull String lemma, int tokenLength)
Constructs a LexiconEntry for the given lemma which has the given token length.static LexiconEntry
of(@NonNull String lemma, String tag, int tokenLength)
Constructs a LexiconEntry for the given lemma which has the given tag and token length.
-
-
-
Method Detail
-
calculateTokenLength
public static int calculateTokenLength(@NonNull @NonNull String phrase, @NonNull @NonNull Language language)
Helper method for calculating the length in tokens of a phrase for a given language.- Parameters:
phrase
- the phraselanguage
- the language- Returns:
- the number of tokens in the phrase.
-
empty
public static LexiconEntry empty()
Empty lexicon entry.- Returns:
- the lexicon entry
-
of
public static LexiconEntry of(@NonNull @NonNull String lemma, int tokenLength)
Constructs a LexiconEntry for the given lemma which has the given token length.- Parameters:
lemma
- the lemmatokenLength
- the token length- Returns:
- the lexicon entry
-
of
public static LexiconEntry of(@NonNull @NonNull String lemma, double probability, String tag, int tokenLength)
Constructs a LexiconEntry for the given lemma which has the given probability, tag, and token length.- Parameters:
lemma
- the lemmaprobability
- the probabilitytag
- the tagtokenLength
- the token length- Returns:
- the lexicon entry
-
of
public static LexiconEntry of(@NonNull @NonNull String lemma, double probability, String tag, LyreExpression constraint, int tokenLength)
Constructs a LexiconEntry for the given lemma which has the given probability, tag, constraint, and token length.- Parameters:
lemma
- the lemmaprobability
- the probabilitytag
- the tagconstraint
- the constrainttokenLength
- the token length- Returns:
- the lexicon entry
-
of
public static LexiconEntry of(@NonNull @NonNull String lemma, double probability, int tokenLength)
Constructs a LexiconEntry for the given lemma which has the given probability and token length.- Parameters:
lemma
- the lemmaprobability
- the probabilitytokenLength
- the token length- Returns:
- the lexicon entry
-
of
public static LexiconEntry of(@NonNull @NonNull String lemma, String tag, int tokenLength)
Constructs a LexiconEntry for the given lemma which has the given tag and token length.- Parameters:
lemma
- the lemmatag
- the tagtokenLength
- the token length- Returns:
- the lexicon entry
-
compareTo
public int compareTo(LexiconEntry o)
- Specified by:
compareTo
in interfaceComparable<LexiconEntry>
-
-