|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.commons.codec.language.bm.Lang
public class Lang
Language guessing utility.
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.
org/apache/commons/codec/language/bm/lang.txtThe format of these resources is the following:
Nested Class Summary | |
---|---|
private static class |
Lang.LangRule
|
Field Summary | |
---|---|
private static Map<NameType,Lang> |
Langs
|
private static String |
LANGUAGE_RULES_RN
|
private Languages |
languages
|
private List<Lang.LangRule> |
rules
|
Constructor Summary | |
---|---|
private |
Lang(List<Lang.LangRule> rules,
Languages languages)
|
Method Summary | |
---|---|
String |
guessLanguage(String text)
Guesses the language of a word. |
Languages.LanguageSet |
guessLanguages(String input)
Guesses the languages of a word. |
static Lang |
instance(NameType nameType)
Gets a Lang instance for one of the supported NameTypes. |
static Lang |
loadFromResource(String languageRulesResourceName,
Languages languages)
Loads language rules from a resource. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private static final Map<NameType,Lang> Langs
private static final String LANGUAGE_RULES_RN
private final Languages languages
private final List<Lang.LangRule> rules
Constructor Detail |
---|
private Lang(List<Lang.LangRule> rules, Languages languages)
Method Detail |
---|
public static Lang instance(NameType nameType)
nameType
- the NameType to look up
public static Lang loadFromResource(String languageRulesResourceName, Languages languages)
Loads language rules from a resource.
In normal use, you will obtain instances of Lang through the instance(NameType)
method. You will only need to call this
yourself if you are developing custom language mapping rules.
languageRulesResourceName
- the fully-qualified resource name to loadlanguages
- the languages that these rules will support
public String guessLanguage(String text)
text
- the word
Languages.ANY
if there was no unique matchpublic Languages.LanguageSet guessLanguages(String input)
input
- the word
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |