edu.northwestern.at.morphadorner.corpuslinguistics.languagerecognizer

## Class AbstractLanguageRecognizer

- java.lang.Object
- - edu.northwestern.at.utils.IsCloseableObject
  - - edu.northwestern.at.morphadorner.corpuslinguistics.languagerecognizer.AbstractLanguageRecognizer

- All Implemented Interfaces:
    LanguageRecognizer, UsesLogger
  Direct Known Subclasses:
    CybozuLabsLanguageRecognizer

      public abstract class AbstractLanguageRecognizer
      extends IsCloseableObject
      implements LanguageRecognizer, UsesLogger

  Abstract Language Recognizer.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected Logger` | `logger` Logger used for output.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `AbstractLanguageRecognizer()` Create a language recognizer with the default language profiles.
    `AbstractLanguageRecognizer(java.util.List<java.lang.String> languages)` Create a language recognizer with list of languages to recognize.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `close()` Close the language recognizer.
    `Logger` | `getLogger()` Get the logger.
    `abstract ScoredString[]` | `recognizeLanguage(java.lang.String text)` Returns a scored list of possible languages for a text string.
    `void` | `setLogger(Logger logger)` Set the logger.

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

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

- - ### Field Detail

    - #### logger

          protected Logger logger

      Logger used for output.

  - ### Constructor Detail

    - #### AbstractLanguageRecognizer

          public AbstractLanguageRecognizer()
                                     throws LangDetectException

      Create a language recognizer with the default language profiles.
      Throws:
        `LangDetectException`

    - #### AbstractLanguageRecognizer

          public AbstractLanguageRecognizer(java.util.List<java.lang.String> languages)
                                     throws LangDetectException

      Create a language recognizer with list of languages to recognize.
      Parameters:
        `languages` - List of names of languages to recognize.

        The list of languages references the profile names. These are usually two or three character ISO 696 language codes, e.g., "en" for English and "sco" for Scots dialect.

      Throws:
        `LangDetectException`

  - ### Method Detail

    - #### recognizeLanguage

          public abstract ScoredString[] recognizeLanguage(java.lang.String text)

      Returns a scored list of possible languages for a text string.
      Specified by:
        `recognizeLanguage` in interface `LanguageRecognizer`
      Parameters:
        `text` - The text for which to determine the language.
      Returns:
        Array of ScoredList entries of language names and scores sorted in descending order by score.

    - #### getLogger

          public Logger getLogger()

      Get the logger.
      Specified by:
        `getLogger` in interface `UsesLogger`
      Returns:
        The logger.

    - #### setLogger

          public void setLogger(Logger logger)

      Set the logger.
      Specified by:
        `setLogger` in interface `UsesLogger`
      Parameters:
        `logger` - The logger.

    - #### close

          public void close()

      Close the language recognizer.
      Overrides:
        `close` in class `IsCloseableObject`