Package org.omegat.tokenizer
Class DefaultTokenizer
java.lang.Object
org.omegat.tokenizer.DefaultTokenizer
- All Implemented Interfaces:
ITokenizer
Methods for tokenize string.
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.omegat.tokenizer.ITokenizer
ITokenizer.StemmingMode -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionString[]Return an array of language strings (xx-yy) indicating the tokenizer's supported languages.static BreakIteratorReturns an iterator to break sentences into words.static booleanisContains(Token[] tokensList, Token tokenForCheck) Check if array contains token.static booleanisContainsAll(Token[] tokensList, Token[] listForFind, boolean notExact) Check if thelistForFindtokens are present intokensList.Find and return all tokens intokensListthat match the tokens inlistForFind.Token[]tokenizeVerbatim(String strOrig) Breaks a string into tokens.String[]Breaks a string into strings.Token[]tokenizeWords(String strOrig, ITokenizer.StemmingMode stemmingMode) Breaks a string into word-only tokens.String[]tokenizeWordsToStrings(String str, ITokenizer.StemmingMode stemmingMode) Breaks a string into word-only strings.
-
Field Details
-
EMPTY_TOKENS_LIST
-
EMPTY_STRINGS_LIST
-
-
Constructor Details
-
DefaultTokenizer
public DefaultTokenizer()
-
-
Method Details
-
tokenizeWords
Breaks a string into word-only tokens. Numbers, tags, and other non-word tokens are NOT included in the result. Stemming can be used depending on the suppliedITokenizer.StemmingMode.This method is used to find fuzzy matches and glossary entries.
Results can be cached for better performance.
- Specified by:
tokenizeWordsin interfaceITokenizer
-
tokenizeWordsToStrings
Description copied from interface:ITokenizerBreaks a string into word-only strings. Numbers, tags, and other non-word tokens are NOT included in the result. Stemming can be used depending on the suppliedITokenizer.StemmingMode.When stemming is used, both the original word and its stem may be included in the results, if they differ. (The stem will come first.)
This method used for dictionary lookup.
Results are not cached.
- Specified by:
tokenizeWordsToStringsin interfaceITokenizer
-
tokenizeVerbatim
Description copied from interface:ITokenizerBreaks a string into tokens. Numbers, tags, and other non-word tokens are included in the result. Stemming is NOT used.This method is used to mark string differences in the UI and to tune similarity.
Results are not cached.
- Specified by:
tokenizeVerbatimin interfaceITokenizer
-
tokenizeVerbatimToStrings
Description copied from interface:ITokenizerBreaks a string into strings. Numbers, tags, and other non-word tokens are included in the result. Stemming is NOT used.This method is used to mark string differences in the UI and for debugging purposes.
Results are not cached.
- Specified by:
tokenizeVerbatimToStringsin interfaceITokenizer
-
getWordBreaker
Returns an iterator to break sentences into words. -
isContains
Check if array contains token. -
isContainsAll
Check if thelistForFindtokens are present intokensList.- Parameters:
tokensList- a list of tokens to be searchedlistForFind- a list of tokens to search intokensListnotExact- is true if the tokens inlistForFindcan be non-contiguous or in a different order in thetokensList. If false, tokens must be exactly the same.- Returns:
- true if the tokens in
listForFindare found intokensList
-
searchAll
Find and return all tokens intokensListthat match the tokens inlistForFind.- Parameters:
tokensList- a list of tokens to be searchedlistForFind- a list of tokens to search in tokensListnotExact- is true if the tokens in listForFind can be non-contiguous or in a different order in the tokensList. If false, tokens must be exactly the same.- Returns:
- A list containing each hit of the matched tokens. Each token array represents a different instance of
listForFindthat was found intokensList.
-
getSupportedLanguages
Description copied from interface:ITokenizerReturn an array of language strings (xx-yy) indicating the tokenizer's supported languages. Meant for tokenizers for which the supported languages can only be determined at runtime, like theHunspellTokenizer.Indicate that this should be used by setting the
Tokenizerannotation to contain onlyTokenizer.DISCOVER_AT_RUNTIME.- Specified by:
getSupportedLanguagesin interfaceITokenizer
-