Package net.sf.okapi.lib.languagetool
Class LanguageToolUtil
- java.lang.Object
-
- net.sf.okapi.lib.languagetool.LanguageToolUtil
-
public class LanguageToolUtil extends Object
Helper methods for working with the LanguageTool API's- Author:
- jimh
-
-
Constructor Summary
Constructors Constructor Description LanguageToolUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static org.languagetool.LanguagegetCachedLanguage(net.sf.okapi.common.LocaleId locale)Thread-safe cache forLanguageobjects.static org.languagetool.LanguagegetLanguage(net.sf.okapi.common.LocaleId locale)Gets the LT language code for the given locale Idstatic List<org.languagetool.AnalyzedTokenReadings>tokenize(String text, org.languagetool.Language lang)Tokenize using LanguageTool tokenizers
-
-
-
Method Detail
-
getCachedLanguage
public static org.languagetool.Language getCachedLanguage(net.sf.okapi.common.LocaleId locale)
Thread-safe cache forLanguageobjects. These objects should be thread safe and can be reused acrossJLanguageToolinstances.- 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 tokenizelang- TheLanguagefrom which we get theWordTokenizer- Returns:
- list of tokens with all whitespace trimmed
- Throws:
IOException
-
-