Package opennlp.tools.langdetect

# Class LanguageDetectorFactory

java.lang.Object
opennlp.tools.util.BaseToolFactory
opennlp.tools.langdetect.LanguageDetectorFactory

public class LanguageDetectorFactory extends BaseToolFactory
Default factory used by `LanguageDetector`.

Extend this class to change the Language Detector behaviour, such as the `LanguageDetectorContextGenerator`. The default `DefaultLanguageDetectorContextGenerator` will use char n-grams of size 1 to 3 and the `EmojiCharSequenceNormalizer`, `UrlCharSequenceNormalizer`, `SocialMediaCharSequenceNormalizer`, `NumberCharSequenceNormalizer`, and `ShrinkCharSequenceNormalizer`.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `LanguageDetectorFactory()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static LanguageDetectorFactory`
  `create(String subclassName)`
  Instantiates a `LanguageDetectorFactory` via a given `subclassName`.
  `opennlp.tools.langdetect.LanguageDetectorContextGenerator`
  `getContextGenerator()`
  `void`
  `init()`
  `void`
  `validateArtifactMap()`
  Validates the parsed artifacts.

  ### Methods inherited from class opennlp.tools.util.BaseToolFactory

  `create, create, createArtifactMap, createArtifactSerializersMap, createManifestEntries`

  ### Methods inherited from class java.lang.Object

  `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### LanguageDetectorFactory

    public LanguageDetectorFactory()

- ## Method Details

  - ### getContextGenerator

    public opennlp.tools.langdetect.LanguageDetectorContextGenerator getContextGenerator()
    Returns:
      Retrieves a `LanguageDetectorContextGenerator`. The deprecated emoji normalizer stays in this chain because existing models were trained with it.

  - ### create

    public static LanguageDetectorFactory create(String subclassName) throws opennlp.tools.util.InvalidFormatException
    Instantiates a `LanguageDetectorFactory` via a given `subclassName`.
    Parameters:
      `subclassName` - The class name used for instantiation. If `null`, an instance of `LanguageDetectorFactory` will be returned per default. Otherwise, the `ExtensionLoader` mechanism is applied to load the requested `subclassName`.
    Returns:
      A valid `LanguageDetectorFactory` instance.
    Throws:
      `opennlp.tools.util.InvalidFormatException` - Thrown if the `ExtensionLoader` mechanism failed to create the factory associated with `subclassName`.

  - ### init

    public void init()

  - ### validateArtifactMap

    public void validateArtifactMap() throws opennlp.tools.util.InvalidFormatException
    Description copied from class: `BaseToolFactory`
    Validates the parsed artifacts.

    Note: Subclasses should generally invoke `super.validateArtifactMap` at the beginning of this method.

    Specified by:
      `validateArtifactMap` in class `BaseToolFactory`
    Throws:
      `opennlp.tools.util.InvalidFormatException` - Thrown if validation found invalid states.