This class encapsulates rules used to guess the possible languages that a word originates from. This is done by reference to a whole series of rules distributed in resource files.
Instances of this class are typically managed through the static factory method instance(). Unless you are developing your own language guessing rules, you will not need to interact with this class directly.
This class is intended to be immutable and thread-safe.
Language guessing rules are typically loaded from resource files. These are UTF-8 encoded text files. They are systematically named following the pattern:
org/apache/commons/codec/language/bm/lang.txtThe format of these resources is the following:
Port of lang.php
|Modifier and Type||Method and Description|
Guesses the language of a word.
Guesses the languages of a word.
Gets a Lang instance for one of the supported NameTypes.
Loads language rules from a resource.
nameType- the NameType to look up
public static Lang loadFromResource(String languageRulesResourceName, Languages languages)
In normal use, you will obtain instances of Lang through the
You will only need to call this yourself if you are developing custom language mapping rules.
languageRulesResourceName- the fully-qualified resource name to load
languages- the languages that these rules will support
public String guessLanguage(String text)
text- the word
Languages.ANYif there was no unique match
Copyright © 2002–2014 The Apache Software Foundation. All rights reserved.