public final class NgramFrequencyData
extends java.lang.Object
Immutable by definition (can't make Arrays unmodifiable).
| Modifier and Type | Field and Description |
|---|---|
private @NotNull java.util.List<LdLocale> |
langlist
All the loaded languages, order is important.
|
private @NotNull java.util.Map<java.lang.String,double[]> |
wordLangProbMap
Key=ngram
Value = array with probabilities per loaded language, in the same order as
langlist. |
| Modifier | Constructor and Description |
|---|---|
private |
NgramFrequencyData(@NotNull java.util.Map<java.lang.String,double[]> wordLangProbMap,
@NotNull java.util.List<LdLocale> langlist) |
| Modifier and Type | Method and Description |
|---|---|
static @NotNull NgramFrequencyData |
create(@NotNull java.util.Collection<LanguageProfile> languageProfiles,
@NotNull java.util.Collection<java.lang.Integer> gramLengths) |
@NotNull LdLocale |
getLanguage(int pos) |
@NotNull java.util.List<LdLocale> |
getLanguageList() |
@Nullable double[] |
getProbabilities(java.lang.String ngram)
Don't modify this data structure! (Can't make array immutable...)
|
@NotNull private final @NotNull java.util.Map<java.lang.String,double[]> wordLangProbMap
langlist.@NotNull private final @NotNull java.util.List<LdLocale> langlist
private NgramFrequencyData(@NotNull
@NotNull java.util.Map<java.lang.String,double[]> wordLangProbMap,
@NotNull
@NotNull java.util.List<LdLocale> langlist)
@NotNull public static @NotNull NgramFrequencyData create(@NotNull @NotNull java.util.Collection<LanguageProfile> languageProfiles, @NotNull @NotNull java.util.Collection<java.lang.Integer> gramLengths) throws java.lang.IllegalArgumentException
gramLengths - for example [1,2,3]java.lang.IllegalArgumentException - if languageProfiles or gramLengths is empty, or if one of the
languageProfiles does not have the grams of the required sizes.@NotNull public @NotNull java.util.List<LdLocale> getLanguageList()
@NotNull public @NotNull LdLocale getLanguage(int pos)
@Nullable public @Nullable double[] getProbabilities(java.lang.String ngram)
getLanguageList() language list, and has exactly that size.
impl note: this way the caller can handle it more efficient than returning an empty array.