Search in sources :

Example 16 with ITokenizer

use of org.omegat.tokenizer.ITokenizer in project omegat by omegat-org.

the class EditorUtils method doChangeCase.

/**
 * Change the case of the input string to the indicated case. When toWhat is
 * {@link CHANGE_CASE_TO#CYCLE} the result will be UPPER > LOWER > SENTENCE
 * > TITLE > UPPER.
 * <p>
 * This is a convenience method for
 * {@link #doChangeCase(String, CHANGE_CASE_TO, Locale, ITokenizer)}. The
 * locale and tokenizer will be taken from the current project's target
 * language values.
 *
 * @param input
 *            The string to change
 * @param toWhat
 *            The case to change to, or {@link CHANGE_CASE_TO#CYCLE}
 * @return The modified string
 */
public static String doChangeCase(String input, CHANGE_CASE_TO toWhat) {
    Locale locale = Core.getProject().getProjectProperties().getTargetLanguage().getLocale();
    ITokenizer tokenizer = Core.getProject().getTargetTokenizer();
    return doChangeCase(input, toWhat, locale, tokenizer);
}
Also used : Locale(java.util.Locale) ITokenizer(org.omegat.tokenizer.ITokenizer)

Example 17 with ITokenizer

use of org.omegat.tokenizer.ITokenizer in project omegat by omegat-org.

the class AutoCompleterListView method getLastToken.

protected String getLastToken(String text) {
    String token = "";
    ITokenizer tokenizer = getTokenizer();
    Token[] tokens = tokenizer.tokenizeVerbatim(text);
    if (tokens.length != 0) {
        Token lastToken = tokens[tokens.length - 1];
        String lastString = text.substring(lastToken.getOffset()).trim();
        if (!lastString.isEmpty()) {
            token = lastString;
        }
    }
    return token;
}
Also used : ITokenizer(org.omegat.tokenizer.ITokenizer) Token(org.omegat.util.Token)

Aggregations

ITokenizer (org.omegat.tokenizer.ITokenizer)17 Locale (java.util.Locale)4 ArrayList (java.util.ArrayList)3 List (java.util.List)3 Test (org.junit.Test)3 DefaultTokenizer (org.omegat.tokenizer.DefaultTokenizer)3 Before (org.junit.Before)2 EntryKey (org.omegat.core.data.EntryKey)2 ProjectProperties (org.omegat.core.data.ProjectProperties)2 SourceTextEntry (org.omegat.core.data.SourceTextEntry)2 LuceneEnglishTokenizer (org.omegat.tokenizer.LuceneEnglishTokenizer)2 Language (org.omegat.util.Language)2 Token (org.omegat.util.Token)2 Diff (bmsi.util.Diff)1 Frame (java.awt.Frame)1 Point (java.awt.Point)1 Map (java.util.Map)1 StyledDocument (javax.swing.text.StyledDocument)1 IProject (org.omegat.core.data.IProject)1 NotLoadedProject (org.omegat.core.data.NotLoadedProject)1