Class NgramFrequencyData
java.lang.Object
com.optimaize.langdetect.NgramFrequencyData
Contains frequency information for n-grams coming from multiple
LanguageProfiles.
For each n-gram string it knows the locales (languages) in which it occurs, and how frequent it occurs in those languages in relation to other n-grams of the same length in those same languages.
Immutable by definition (can't make Arrays unmodifiable).
- Author:
- Fabian Kessler
-
Method Summary
Modifier and TypeMethodDescriptionstatic @NotNull NgramFrequencyDatacreate(@NotNull Collection<LanguageProfile> languageProfiles, @NotNull Collection<Integer> gramLengths) @NotNull LdLocalegetLanguage(int pos) @Nullable double[]getProbabilities(String ngram) Don't modify this data structure!
-
Method Details
-
create
@NotNull public static @NotNull NgramFrequencyData create(@NotNull @NotNull Collection<LanguageProfile> languageProfiles, @NotNull @NotNull Collection<Integer> gramLengths) throws IllegalArgumentException - Parameters:
gramLengths- for example [1,2,3]- Throws:
IllegalArgumentException- if languageProfiles or gramLengths is empty, or if one of the languageProfiles does not have the grams of the required sizes.
-
getLanguageList
-
getLanguage
-
getProbabilities
Don't modify this data structure! (Can't make array immutable...)- Returns:
- null if no language profile knows that ngram.
entries are 0 for languages that don't know that ngram at all.
The array is in the order of the
getLanguageList()language list, and has exactly that size. impl note: this way the caller can handle it more efficient than returning an empty array.
-