Class LanguageCodeValidator
java.lang.Object
opennlp.tools.util.LanguageCodeValidator
Validates language codes against ISO 639 standards.
Accepts:
- ISO 639-1 two-letter language codes
(e.g.,
"en","de") - ISO 639-2/3 three-letter language codes
(e.g.,
"eng","deu") - The special code
"x-unspecified"used internally by OpenNLP
Valid codes are derived from Locale.availableLocales()
plus additional ISO 639-2 bibliographic codes and
"und" (undetermined).
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionstatic booleanChecks whether the given language code is a valid ISO 639 code.static voidvalidateLanguageCode(String languageCode) Validates the given language code and throws anIllegalArgumentExceptionif it is not a recognized ISO 639 language code.
-
Method Details
-
isValid
Checks whether the given language code is a valid ISO 639 code.- Parameters:
languageCode- The language code to check. Must not benull.- Returns:
trueif the code is valid,falseotherwise.- Throws:
IllegalArgumentException- iflanguageCodeisnull.
-
validateLanguageCode
Validates the given language code and throws anIllegalArgumentExceptionif it is not a recognized ISO 639 language code.- Parameters:
languageCode- The language code to validate. Must not benull.- Throws:
IllegalArgumentException- if the code is not a valid ISO 639 language code or isnull.
-