Class LanguageToolUtil


  • public class LanguageToolUtil
    extends Object
    Helper methods for working with the LanguageTool API's
    Author:
    jimh
    • Constructor Detail

      • LanguageToolUtil

        public LanguageToolUtil()
    • Method Detail

      • getCachedLanguage

        public static org.languagetool.Language getCachedLanguage​(net.sf.okapi.common.LocaleId locale)
        Thread-safe cache for Language objects. These objects should be thread safe and can be reused across JLanguageTool instances.
        Parameters:
        locale -
        Returns:
        a cached Language
      • getLanguage

        public static final org.languagetool.Language getLanguage​(net.sf.okapi.common.LocaleId locale)
        Gets the LT language code for the given locale Id
        Parameters:
        locale - the locale id to map.
        Returns:
        the LT language code, or null if the locale id could not be mapped.
      • tokenize

        public static final List<org.languagetool.AnalyzedTokenReadings> tokenize​(String text,
                                                                                  org.languagetool.Language lang)
                                                                           throws IOException
        Tokenize using LanguageTool tokenizers
        Parameters:
        text - text to tokenize
        lang - The Language from which we get the WordTokenizer
        Returns:
        list of tokens with all whitespace trimmed
        Throws:
        IOException