diff --git a/java/src/org/futo/inputmethod/latin/Suggest.java b/java/src/org/futo/inputmethod/latin/Suggest.java index 123d6a1ed69e89f0af0da20c931a29b3916fb03e..f78ff4c94e2cb106f5219587f379aff04d6f3bfb 100644 --- a/java/src/org/futo/inputmethod/latin/Suggest.java +++ b/java/src/org/futo/inputmethod/latin/Suggest.java @@ -210,6 +210,8 @@ public final class Suggest { // If the word is entirely digits, never autocorrect regardless of number row // being active or not || wordComposer.isEntirelyDigits() + // If it's an ordinal (1st, 2nd, 3rd), do not autocorrect + || wordComposer.isOrdinal(locale) // If the word is mostly caps, we never auto-correct because this is almost // certainly intentional (and careful input) || wordComposer.isMostlyCaps() diff --git a/java/src/org/futo/inputmethod/latin/WordComposer.java b/java/src/org/futo/inputmethod/latin/WordComposer.java index 2aefd7e697172cc57bf54f2cf520d9f6267aa788..c0abed018bc79d21383b5cd03b6c96398e2ef680 100644 --- a/java/src/org/futo/inputmethod/latin/WordComposer.java +++ b/java/src/org/futo/inputmethod/latin/WordComposer.java @@ -30,6 +30,7 @@ import org.futo.inputmethod.latin.define.DecoderSpecificConstants; import java.util.ArrayList; import java.util.Collections; +import java.util.Locale; import javax.annotation.Nonnull; @@ -361,6 +362,16 @@ public final class WordComposer { return mDigitsCount == mCodePointSize; } + /** + * Returns true if the composing word is an ordinal + */ + public boolean isOrdinal(Locale locale) { + final String word = getTypedWord(); + + // TODO: This is English-only + return word.matches("^(\\d+)(st|nd|rd|th)$"); + } + /** * Saves the caps mode at the start of composing. *