public final class LanguageProfileImpl extends java.lang.Object implements LanguageProfile
This class is immutable.
| Modifier and Type | Field and Description |
|---|---|
private @NotNull LdLocale |
locale |
private @NotNull java.util.Map<java.lang.Integer,java.util.Map<java.lang.String,java.lang.Integer>> |
ngrams |
private @NotNull java.util.Map<java.lang.Integer,java.lang.Long> |
numOccurrences
Key = gram length (1-3 or so).
|
| Constructor and Description |
|---|
LanguageProfileImpl(@NotNull LdLocale locale,
@NotNull java.util.Map<java.lang.Integer,java.util.Map<java.lang.String,java.lang.Integer>> ngrams)
Use the builder.
|
| Modifier and Type | Method and Description |
|---|---|
private static java.util.Map<java.lang.Integer,java.lang.Long> |
computeNumOccurrences(java.util.Map<java.lang.Integer,java.util.Map<java.lang.String,java.lang.Integer>> ngrams) |
boolean |
equals(java.lang.Object o) |
int |
getFrequency(java.lang.String gram) |
@NotNull java.util.List<java.lang.Integer> |
getGramLengths()
Tells what the n in n-grams are used here.
|
@NotNull LdLocale |
getLocale() |
long |
getMaxGramCount(int gramLength)
Tells how often the n-gram with the highest amount of occurrences used in this profile occurred.
|
long |
getMinGramCount(int gramLength)
Tells how often the n-gram with the lowest amount of occurrences used in this profile occurred.
|
long |
getNumGramOccurrences(int gramLength)
Tells how often all n-grams of a certain length occurred, combined.
|
int |
getNumGrams()
Tells how many n-grams there are for all n-gram sizes combined.
|
int |
getNumGrams(int gramLength)
Tells how many different n-grams there are for a certain n-gram size.
|
int |
hashCode() |
@NotNull java.lang.Iterable<java.util.Map.Entry<java.lang.String,java.lang.Integer>> |
iterateGrams()
Iterates all ngram strings with frequency.
|
@NotNull java.lang.Iterable<java.util.Map.Entry<java.lang.String,java.lang.Integer>> |
iterateGrams(int gramLength)
Iterates all gramLength-gram strings with frequency.
|
java.lang.String |
toString() |
@NotNull private final @NotNull LdLocale locale
@NotNull private final @NotNull java.util.Map<java.lang.Integer,java.util.Map<java.lang.String,java.lang.Integer>> ngrams
@NotNull private final @NotNull java.util.Map<java.lang.Integer,java.lang.Long> numOccurrences
LanguageProfileImpl(@NotNull
@NotNull LdLocale locale,
@NotNull
@NotNull java.util.Map<java.lang.Integer,java.util.Map<java.lang.String,java.lang.Integer>> ngrams)
private static java.util.Map<java.lang.Integer,java.lang.Long> computeNumOccurrences(java.util.Map<java.lang.Integer,java.util.Map<java.lang.String,java.lang.Integer>> ngrams)
@NotNull public @NotNull LdLocale getLocale()
getLocale in interface LanguageProfile@NotNull public @NotNull java.util.List<java.lang.Integer> getGramLengths()
LanguageProfilegetGramLengths in interface LanguageProfilepublic int getFrequency(java.lang.String gram)
getFrequency in interface LanguageProfilegram - for example "a" or "foo".public int getNumGrams(int gramLength)
LanguageProfilegetNumGrams in interface LanguageProfilegramLength - 1-npublic int getNumGrams()
LanguageProfilegetNumGrams in interface LanguageProfilepublic long getNumGramOccurrences(int gramLength)
LanguageProfileLanguageProfile.getNumGrams(int).getNumGramOccurrences in interface LanguageProfilegramLength - 1-npublic long getMinGramCount(int gramLength)
LanguageProfilegetMinGramCount in interface LanguageProfilegramLength - 1-npublic long getMaxGramCount(int gramLength)
LanguageProfilegetMaxGramCount in interface LanguageProfilegramLength - 1-n@NotNull public @NotNull java.lang.Iterable<java.util.Map.Entry<java.lang.String,java.lang.Integer>> iterateGrams()
LanguageProfileiterateGrams in interface LanguageProfile@NotNull public @NotNull java.lang.Iterable<java.util.Map.Entry<java.lang.String,java.lang.Integer>> iterateGrams(int gramLength)
LanguageProfileiterateGrams in interface LanguageProfilepublic java.lang.String toString()
toString in class java.lang.Objectpublic boolean equals(java.lang.Object o)
equals in class java.lang.Objectpublic int hashCode()
hashCode in class java.lang.Object