public abstract class Language extends Object
META-INF/org/languagetool/language-module.properties. Those file(s)
need to contain a key languageClasses which specifies the fully qualified
class name(s), e.g. org.languagetool.language.English. Use commas to specify
more than one class.
Sub classes should typically use lazy init for anything that's costly to set up. This improves start up time for the LanguageTool stand-alone version.
| Constructor and Description |
|---|
Language() |
| Modifier and Type | Method and Description |
|---|---|
boolean |
equalsConsiderVariantsIfSpecified(Language otherLanguage)
Return true if this is the same language as the given one, considering country
variants only if set for both languages.
|
Chunker |
getChunker()
Get this language's chunker implementation or
null. |
abstract String[] |
getCountries()
Get this language's country options , e.g.
|
List<String> |
getDefaultDisabledRulesForVariant()
Get disabled rules different from the default ones for this language variant.
|
List<String> |
getDefaultEnabledRulesForVariant()
Get enabled rules different from the default ones for this language variant.
|
Language |
getDefaultLanguageVariant()
Languages that have country variants need to overwrite this to select their most common variant.
|
Unifier |
getDisambiguationUnifier()
Get this language's feature unifier used for disambiguation.
|
UnifierConfiguration |
getDisambiguationUnifierConfiguration() |
Disambiguator |
getDisambiguator()
Get this language's part-of-speech disambiguator implementation.
|
Pattern |
getIgnoredCharactersRegex() |
LanguageModel |
getLanguageModel(File indexDir) |
Locale |
getLocale()
Get this language's Java locale, not considering the country code.
|
Locale |
getLocaleWithCountryAndVariant()
Get this language's Java locale, considering language code and country code (if any).
|
abstract Contributor[] |
getMaintainers()
Get the name(s) of the maintainer(s) for this language or
null. |
abstract String |
getName()
Get this language's name in English, e.g.
|
protected List<PatternRule> |
getPatternRules()
Get the pattern rules as defined in the files returned by
getRuleFileNames(). |
Chunker |
getPostDisambiguationChunker()
Get this language's chunker implementation or
null. |
List<Rule> |
getRelevantLanguageModelRules(ResourceBundle messages,
LanguageModel languageModel)
Get a list of rules that require a
LanguageModel. |
abstract List<Rule> |
getRelevantRules(ResourceBundle messages)
Get the rules classes that should run for texts in this language.
|
List<String> |
getRuleFileNames()
Get the location of the rule file(s) in a form like
/org/languagetool/rules/de/grammar.xml,
i.e. a path in the classpath. |
SentenceTokenizer |
getSentenceTokenizer()
Get this language's sentence tokenizer implementation.
|
abstract String |
getShortName()
Get this language's character code, e.g.
|
String |
getShortNameWithCountryAndVariant()
Get the short name of the language with country and variant (if any), if it is
a single-country language.
|
Synthesizer |
getSynthesizer()
Get this language's part-of-speech synthesizer implementation or
null. |
Tagger |
getTagger()
Get this language's part-of-speech tagger implementation.
|
String |
getTranslatedName(ResourceBundle messages)
Get the name of the language translated to the current locale,
if available.
|
Unifier |
getUnifier()
Get this language's feature unifier.
|
UnifierConfiguration |
getUnifierConfiguration() |
String |
getVariant()
Get this language's variant, e.g.
|
Tokenizer |
getWordTokenizer()
Get this language's word tokenizer implementation.
|
boolean |
hasVariant()
Whether this class has at least one subclass that implements variants of this language.
|
boolean |
isExternal() |
boolean |
isVariant()
|
void |
makeExternal()
Deprecated.
overwrite
isExternal() instead (deprecated since 3.0) |
void |
setIgnoredCharactersRegex(String ignoredCharactersRegex)
Deprecated.
overwrite
getIgnoredCharactersRegex() instead (deprecated since 3.0) |
String |
toString() |
public abstract String getShortName()
en for English.
The country parameter (e.g. "US"), if any, is not returned.public abstract String getName()
English or
German (Germany).public abstract String[] getCountries()
US (as in en-US) or
PL (as in pl-PL).@Nullable public abstract Contributor[] getMaintainers()
null.public abstract List<Rule> getRelevantRules(ResourceBundle messages) throws IOException
IOException@Nullable public String getVariant()
valencia (as in ca-ES-valencia)
or null.
Attention: not to be confused with "country" optionnullpublic List<String> getDefaultEnabledRulesForVariant()
public List<String> getDefaultDisabledRulesForVariant()
@Nullable public LanguageModel getLanguageModel(File indexDir) throws IOException
indexDir - directory with a '3grams' sub directory which contains a Lucene index with 3gram occurrence countsnull if this language doesn't support oneIOExceptionpublic List<Rule> getRelevantLanguageModelRules(ResourceBundle messages, LanguageModel languageModel) throws IOException
LanguageModel. Returns an empty list for
languages that don't have such rules.IOExceptionpublic Locale getLocale()
public Locale getLocaleWithCountryAndVariant()
public List<String> getRuleFileNames()
/org/languagetool/rules/de/grammar.xml,
i.e. a path in the classpath.@Nullable public Language getDefaultLanguageVariant()
nullpublic Disambiguator getDisambiguator()
public Tagger getTagger()
null, but it can be a trivial pseudo-tagger that only assigns null tags.public SentenceTokenizer getSentenceTokenizer()
public Tokenizer getWordTokenizer()
@Nullable public Chunker getChunker()
null.@Nullable public Chunker getPostDisambiguationChunker()
null.@Nullable public Synthesizer getSynthesizer()
null.public Unifier getUnifier()
public Unifier getDisambiguationUnifier()
public UnifierConfiguration getUnifierConfiguration()
public UnifierConfiguration getDisambiguationUnifierConfiguration()
public final String getTranslatedName(ResourceBundle messages)
public final String getShortNameWithCountryAndVariant()
protected List<PatternRule> getPatternRules() throws IOException
getRuleFileNames().IOExceptionpublic final boolean isVariant()
Language, but a subclass of Language.public final boolean hasVariant()
public boolean isExternal()
public void makeExternal()
isExternal() instead (deprecated since 3.0)public boolean equalsConsiderVariantsIfSpecified(Language otherLanguage)
public Pattern getIgnoredCharactersRegex()
public void setIgnoredCharactersRegex(String ignoredCharactersRegex)
getIgnoredCharactersRegex() instead (deprecated since 3.0)) is ignored.