Package opennlp.tools.tokenize.lang
Class Factory
java.lang.Object
opennlp.tools.tokenize.lang.Factory
Provides the language dependent tokenizer resources: the
TokenizerCharacterPolicy
that decides which tokens the alphanumeric optimization accepts without further splitting,
and the TokenContextGenerator.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final Stringprivate static final TokenizerCharacterPolicystatic final PatternDeprecated, for removal: This API element is subject to removal in a future version.static final TokenizerCharacterPolicyThe policy for languages without a dedicated one: ASCII letters and digits, no marks.private static final TokenizerCharacterPolicyprivate static final TokenizerCharacterPolicyprivate static final TokenizerCharacterPolicyprivate static final TokenizerCharacterPolicyprivate static final Map<TokenizerCharacterPolicy, String> The alphanumeric expressions of releases before 3.0, keyed by the policy that accepts the same characters.private static final Map<TokenizerCharacterPolicy, Pattern> The compiledLEGACY_EXPRESSIONS, keyed by the same policies.private static final CodePointSetprivate static final TokenizerCharacterPolicyprivate static final TokenizerCharacterPolicyprivate static final TokenizerCharacterPolicy -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static PatternReturns the compiled alphanumeric expression of an earlier release.private static Map<TokenizerCharacterPolicy, Pattern> Returns theLEGACY_EXPRESSIONScompiled once, withDEFAULT_ALPHANUMERICfor the default policy.createTokenContextGenerator(String languageCode, Set<String> abbreviations) Initializes a customizedTokenContextGeneratorvia a set ofabbreviations.getAlphanumeric(String languageCode) Deprecated, for removal: This API element is subject to removal in a future version.getCharacterPolicy(String languageCode) Gets the character policy for a language.private static TokenizerCharacterPolicylatinPolicy(String extraLetters) Builds a policy of the ASCII letters plusextraLetters, the ASCII digits, and no marks.static StringDeprecated, for removal: This API element is subject to removal in a future version.Serves only the deprecatedPatternAPI and will be removed with it in 4.0.static PatternDeprecated, for removal: This API element is subject to removal in a future version.Serves only the deprecatedPatternAPI and will be removed with it in 4.0.static TokenizerCharacterPolicypolicyOfLegacyExpression(String expression) Deprecated, for removal: This API element is subject to removal in a future version.Serves only the deprecatedPatternAPI and will be removed with it in 4.0.
-
Field Details
-
DEFAULT_CHARACTER_POLICY
The policy for languages without a dedicated one: ASCII letters and digits, no marks. -
ASCII_EXPRESSION
- See Also:
-
DEFAULT_ALPHANUMERIC
@Deprecated(since="3.0.0", forRemoval=true) @SuppressForbidden("alphanumeric pattern of earlier releases, kept for the deprecated API") public static final Pattern DEFAULT_ALPHANUMERICDeprecated, for removal: This API element is subject to removal in a future version.UseDEFAULT_CHARACTER_POLICY, which accepts the same characters. This constant will be removed in 4.0.The alphanumeric pattern of earlier releases for languages without a dedicated one. -
NO_MARKS
-
PORTUGUESE
-
FRENCH
-
DUTCH
-
GERMAN
-
POLISH
-
ITALIAN
-
SPANISH
-
CATALAN
-
LEGACY_EXPRESSIONS
The alphanumeric expressions of releases before 3.0, keyed by the policy that accepts the same characters. -
LEGACY_PATTERNS
@SuppressForbidden("alphanumeric pattern of earlier releases, kept for the deprecated API") private static final Map<TokenizerCharacterPolicy,Pattern> LEGACY_PATTERNSThe compiledLEGACY_EXPRESSIONS, keyed by the same policies. The default policy maps toDEFAULT_ALPHANUMERIC.
-
-
Constructor Details
-
Factory
public Factory()
-
-
Method Details
-
getCharacterPolicy
Gets the character policy for a language.- Parameters:
languageCode- An ISO 639-1 code, or an ISO 639-2 code in its terminology or bibliographic form (deuorger). Ifnull, or unknown, theDEFAULT_CHARACTER_POLICYwill be returned.- Returns:
- The
TokenizerCharacterPolicyfor the language, or the default policy.
-
getAlphanumeric
@Deprecated(since="3.0.0", forRemoval=true) @SuppressForbidden("alphanumeric pattern of earlier releases, kept for the deprecated API") public Pattern getAlphanumeric(String languageCode) Deprecated, for removal: This API element is subject to removal in a future version.UsegetCharacterPolicy(String). This method will be removed in 4.0.Gets the alphanumeric pattern that releases before 3.0 used for a language.- Parameters:
languageCode- An ISO 639-1 code, or an ISO 639-2 code in its terminology or bibliographic form. Ifnull, or unknown, theDEFAULT_ALPHANUMERICpattern will be returned.- Returns:
- The
Patternthat accepts the same characters asgetCharacterPolicy(String)for the language.
-
policyOfLegacyExpression
@Internal @Deprecated(since="3.0.0", forRemoval=true) public static TokenizerCharacterPolicy policyOfLegacyExpression(String expression) Deprecated, for removal: This API element is subject to removal in a future version.Serves only the deprecatedPatternAPI and will be removed with it in 4.0.Returns the policy of the language whose alphanumeric expression of an earlier release isexpression, ornullif there is none.Note: Internal use only, for the deprecated
PatternAPI.- Parameters:
expression- An alphanumeric expression of an earlier release.- Returns:
- the policy of the language whose alphanumeric expression of an earlier release is
expression, ornullif there is none
-
legacyExpressionOf
@Internal @Deprecated(since="3.0.0", forRemoval=true) public static String legacyExpressionOf(TokenizerCharacterPolicy policy) Deprecated, for removal: This API element is subject to removal in a future version.Serves only the deprecatedPatternAPI and will be removed with it in 4.0.Returns the alphanumeric expression of an earlier release that accepts the same characters aspolicy, ornullif there is none.Note: Internal use only, for the deprecated
PatternAPI.- Parameters:
policy- A character policy, ornull.- Returns:
- the alphanumeric expression of an earlier release that accepts the same characters
as
policy, ornullif there is none
-
legacyPatternOf
@Internal @Deprecated(since="3.0.0", forRemoval=true) @SuppressForbidden("alphanumeric pattern of earlier releases, kept for the deprecated API") public static Pattern legacyPatternOf(TokenizerCharacterPolicy policy) Deprecated, for removal: This API element is subject to removal in a future version.Serves only the deprecatedPatternAPI and will be removed with it in 4.0.Returns the alphanumeric pattern of an earlier release that accepts the same characters aspolicy, ornullif there is none.Note: Internal use only, for the deprecated
PatternAPI.- Parameters:
policy- A character policy, ornull.- Returns:
- the alphanumeric pattern of an earlier release that accepts the same characters as
policy, ornullif there is none
-
compileAll
@SuppressForbidden("alphanumeric pattern of earlier releases, kept for the deprecated API") private static Map<TokenizerCharacterPolicy,Pattern> compileAll()Returns theLEGACY_EXPRESSIONScompiled once, withDEFAULT_ALPHANUMERICfor the default policy.- Returns:
- the
LEGACY_EXPRESSIONScompiled once, withDEFAULT_ALPHANUMERICfor the default policy
-
compile
@SuppressForbidden("alphanumeric pattern of earlier releases, kept for the deprecated API") private static Pattern compile(String expression) Returns the compiled alphanumeric expression of an earlier release.- Parameters:
expression- The expression.- Returns:
- the compiled alphanumeric expression of an earlier release
-
createTokenContextGenerator
public TokenContextGenerator createTokenContextGenerator(String languageCode, Set<String> abbreviations) Initializes a customizedTokenContextGeneratorvia a set ofabbreviations.- Parameters:
languageCode- The ISO_639-1 code to be used.abbreviations- The abbreviations to be used for new instance.
-
latinPolicy
Builds a policy of the ASCII letters plusextraLetters, the ASCII digits, and no marks.- Parameters:
extraLetters- The letters of a Latin script language beyond ASCII.- Returns:
- The policy.
-
DEFAULT_CHARACTER_POLICY, which accepts the same characters.