Class LanguageProfileBuilder

java.lang.Object
com.optimaize.langdetect.profiles.LanguageProfileBuilder

public class LanguageProfileBuilder extends Object
Builder for LanguageProfile.

This class does no internal synchronization.

  • Field Details

  • Constructor Details

    • LanguageProfileBuilder

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

      @Deprecated public LanguageProfileBuilder(@NotNull @NotNull String locale)
      Deprecated.
  • Method Details

    • ngramExtractor

      public LanguageProfileBuilder ngramExtractor(@NotNull @NotNull NgramExtractor ngramExtractor)
    • 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.
    • addText

      public LanguageProfileBuilder addText(CharSequence text)
      In order to use this you must set the ngramExtractor first.
    • addGram

      public LanguageProfileBuilder addGram(String ngram)
      Shortcut for addGram(ngram, 1).
    • addGram

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

      public LanguageProfile build()
    • removeNgramsWithLessFrequency

      private void removeNgramsWithLessFrequency()