Class LanguageProfileBuilder


  • public class LanguageProfileBuilder
    extends java.lang.Object
    Builder for LanguageProfile.

    This class does no internal synchronization.

    • Field Detail

      • locale

        @NotNull
        private final @NotNull LdLocale locale
      • minimalFrequency

        private int minimalFrequency
      • ngrams

        private final java.util.Map<java.lang.Integer,​java.util.Map<java.lang.String,​java.lang.Integer>> ngrams
    • Constructor Detail

      • LanguageProfileBuilder

        public LanguageProfileBuilder​(@NotNull
                                      @NotNull LdLocale locale)
      • LanguageProfileBuilder

        @Deprecated
        public LanguageProfileBuilder​(@NotNull
                                      @NotNull java.lang.String locale)
        Deprecated.
    • Method Detail

      • minimalFrequency

        public LanguageProfileBuilder minimalFrequency​(int minimalFrequency)
        Parameters:
        minimalFrequency - 1-n, the default is 1. n-grams that occurred less often in the text are removed. This really should be set to something higher. Try to play with the number until you get a profile file of satisfying size, that produces good language detection results.
      • addGram

        public LanguageProfileBuilder addGram​(java.lang.String ngram,
                                              int frequency)
        If the builder already has this ngram, the given frequency is added to the current count.
      • removeNgramsWithLessFrequency

        private void removeNgramsWithLessFrequency()