Class LanguageDetectorBuilder


  • public class LanguageDetectorBuilder
    extends java.lang.Object
    Builder for LanguageDetector.

    This class does no internal synchronization.

    • Field Detail

      • ngramExtractor

        @NotNull
        private final @NotNull NgramExtractor ngramExtractor
      • alpha

        private double alpha
      • seed

        private com.google.common.base.Optional<java.lang.Long> seed
      • shortTextAlgorithm

        private int shortTextAlgorithm
      • prefixFactor

        private double prefixFactor
      • suffixFactor

        private double suffixFactor
      • probabilityThreshold

        private double probabilityThreshold
      • minimalConfidence

        private double minimalConfidence
      • langWeightingMap

        @Nullable
        private @Nullable java.util.Map<LdLocale,​java.lang.Double> langWeightingMap
      • languageProfiles

        @NotNull
        private final @NotNull java.util.Set<LanguageProfile> languageProfiles
      • langsAdded

        @NotNull
        private final @NotNull java.util.Set<LdLocale> langsAdded
    • Constructor Detail

      • LanguageDetectorBuilder

        private LanguageDetectorBuilder​(@NotNull
                                        @NotNull NgramExtractor ngramExtractor)
    • Method Detail

      • seed

        public LanguageDetectorBuilder seed​(@NotNull
                                            @NotNull com.google.common.base.Optional<java.lang.Long> seed)
      • shortTextAlgorithm

        public LanguageDetectorBuilder shortTextAlgorithm​(int shortTextAlgorithm)
        Defaults to 0, which means don't use this feature. That's the old behavior.
      • prefixFactor

        public LanguageDetectorBuilder prefixFactor​(double prefixFactor)
        To weight n-grams that are on the left border of a word differently from n-grams in the middle of words, assign a value here. Affixes (prefixes and suffixes) often distinguish the specific features of languages. Giving a value greater than 1.0 weights these n-grams higher. A 2.0 weights them double. Defaults to 1.0, which means don't use this feature.
        Parameters:
        prefixFactor - 0.0 to 10.0, a suggested value is 1.5
      • suffixFactor

        public LanguageDetectorBuilder suffixFactor​(double suffixFactor)
        Defaults to 1.0, which means don't use this feature.
        Parameters:
        suffixFactor - 0.0 to 10.0, a suggested value is 2.0
        See Also:
        prefixFactor(double)
      • languagePriorities

        public LanguageDetectorBuilder languagePriorities​(@Nullable
                                                          @Nullable java.util.Map<LdLocale,​java.lang.Double> langWeightingMap)
        TODO document exactly. Also explain how it influences the results. Maybe check for unsupported languages at some point, or not, but document whether it does throw or ignore. String key = language, Double value = priority (probably 0-1).
      • withProfile

        public LanguageDetectorBuilder withProfile​(LanguageProfile languageProfile)
                                            throws java.lang.IllegalStateException
        Throws:
        java.lang.IllegalStateException - if a profile for the same language was added already (must be a userland bug).
      • withProfiles

        public LanguageDetectorBuilder withProfiles​(java.lang.Iterable<LanguageProfile> languageProfiles)
                                             throws java.lang.IllegalStateException
        Throws:
        java.lang.IllegalStateException - if a profile for the same language was added already (must be a userland bug).
      • build

        public LanguageDetector build()
                               throws java.lang.IllegalStateException
        Throws:
        java.lang.IllegalStateException - if no LanguageProfile was added.