Skip to content

Commit

Permalink
Do not autocorrect ordinals
Browse files Browse the repository at this point in the history
  • Loading branch information
abb128 committed Oct 31, 2024
1 parent a739d60 commit 545facf
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
2 changes: 2 additions & 0 deletions java/src/org/futo/inputmethod/latin/Suggest.java
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,8 @@ public static SuggestedWords obtainNonBatchedInputSuggestedWords(
// 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()
Expand Down
11 changes: 11 additions & 0 deletions java/src/org/futo/inputmethod/latin/WordComposer.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

import java.util.ArrayList;
import java.util.Collections;
import java.util.Locale;

import javax.annotation.Nonnull;

Expand Down Expand Up @@ -361,6 +362,16 @@ public boolean isEntirelyDigits() {
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.
*
Expand Down

0 comments on commit 545facf

Please sign in to comment.