Loading java/src/com/android/inputmethod/latin/Constants.java +3 −0 Original line number Diff line number Diff line Loading @@ -214,6 +214,9 @@ public final class Constants { public static final int CODE_INVERTED_QUESTION_MARK = 0xBF; // ¿ public static final int CODE_INVERTED_EXCLAMATION_MARK = 0xA1; // ¡ public static final String REGEXP_PERIOD = "\\."; public static final String STRING_SPACE = " "; /** * Special keys code. Must be negative. * These should be aligned with {@link KeyboardCodesSet#ID_TO_NAME}, Loading java/src/com/android/inputmethod/latin/spellcheck/AndroidWordLevelSpellCheckerSession.java +16 −0 Original line number Diff line number Diff line Loading @@ -282,6 +282,22 @@ public abstract class AndroidWordLevelSpellCheckerSession extends Session { return AndroidSpellCheckerService.getNotInDictEmptySuggestions( false /* reportAsTypo */); } if (CHECKABILITY_CONTAINS_PERIOD == checkability) { final String[] splitText = inText.split(Constants.REGEXP_PERIOD); boolean allWordsAreValid = true; for (final String word : splitText) { if (!dictInfo.mDictionary.isValidWord(word)) { allWordsAreValid = false; break; } } if (allWordsAreValid) { return new SuggestionsInfo(SuggestionsInfo.RESULT_ATTR_LOOKS_LIKE_TYPO | SuggestionsInfo.RESULT_ATTR_HAS_RECOMMENDED_SUGGESTIONS, new String[] { TextUtils.join(Constants.STRING_SPACE, splitText) }); } } return dictInfo.mDictionary.isValidWord(inText) ? AndroidSpellCheckerService.getInDictEmptySuggestions() : AndroidSpellCheckerService.getNotInDictEmptySuggestions( Loading tests/src/com/android/inputmethod/latin/spellcheck/AndroidSpellCheckerServiceTest.java +18 −1 Original line number Diff line number Diff line Loading @@ -39,7 +39,7 @@ public class AndroidSpellCheckerServiceTest extends InputTestsBase { // it yields 5). assertTrue(suggestions.length >= 2); // We also assume the top suggestion should be "this". assertEquals("", "this", suggestions[0]); assertEquals("Test basic spell checking", "this", suggestions[0]); } public void testRussianSpellchecker() { Loading @@ -62,4 +62,21 @@ public class AndroidSpellCheckerServiceTest extends InputTestsBase { // Russian dictionary. assertEquals("", "года", suggestions[0]); } public void testSpellcheckWithPeriods() { changeLanguage("en_US"); mEditText.setText("I'm.sure "); mEditText.setSelection(mEditText.getText().length()); mEditText.onAttachedToWindow(); sleep(1000); runMessages(); sleep(1000); final SpanGetter span = new SpanGetter(mEditText.getText(), SuggestionSpan.class); // If no span, the following will crash final String[] suggestions = span.getSuggestions(); // The first suggestion should be "I'm sure". assertEquals("Test spell checking of mistyped period for space", "I'm sure", suggestions[0]); } } Loading
java/src/com/android/inputmethod/latin/Constants.java +3 −0 Original line number Diff line number Diff line Loading @@ -214,6 +214,9 @@ public final class Constants { public static final int CODE_INVERTED_QUESTION_MARK = 0xBF; // ¿ public static final int CODE_INVERTED_EXCLAMATION_MARK = 0xA1; // ¡ public static final String REGEXP_PERIOD = "\\."; public static final String STRING_SPACE = " "; /** * Special keys code. Must be negative. * These should be aligned with {@link KeyboardCodesSet#ID_TO_NAME}, Loading
java/src/com/android/inputmethod/latin/spellcheck/AndroidWordLevelSpellCheckerSession.java +16 −0 Original line number Diff line number Diff line Loading @@ -282,6 +282,22 @@ public abstract class AndroidWordLevelSpellCheckerSession extends Session { return AndroidSpellCheckerService.getNotInDictEmptySuggestions( false /* reportAsTypo */); } if (CHECKABILITY_CONTAINS_PERIOD == checkability) { final String[] splitText = inText.split(Constants.REGEXP_PERIOD); boolean allWordsAreValid = true; for (final String word : splitText) { if (!dictInfo.mDictionary.isValidWord(word)) { allWordsAreValid = false; break; } } if (allWordsAreValid) { return new SuggestionsInfo(SuggestionsInfo.RESULT_ATTR_LOOKS_LIKE_TYPO | SuggestionsInfo.RESULT_ATTR_HAS_RECOMMENDED_SUGGESTIONS, new String[] { TextUtils.join(Constants.STRING_SPACE, splitText) }); } } return dictInfo.mDictionary.isValidWord(inText) ? AndroidSpellCheckerService.getInDictEmptySuggestions() : AndroidSpellCheckerService.getNotInDictEmptySuggestions( Loading
tests/src/com/android/inputmethod/latin/spellcheck/AndroidSpellCheckerServiceTest.java +18 −1 Original line number Diff line number Diff line Loading @@ -39,7 +39,7 @@ public class AndroidSpellCheckerServiceTest extends InputTestsBase { // it yields 5). assertTrue(suggestions.length >= 2); // We also assume the top suggestion should be "this". assertEquals("", "this", suggestions[0]); assertEquals("Test basic spell checking", "this", suggestions[0]); } public void testRussianSpellchecker() { Loading @@ -62,4 +62,21 @@ public class AndroidSpellCheckerServiceTest extends InputTestsBase { // Russian dictionary. assertEquals("", "года", suggestions[0]); } public void testSpellcheckWithPeriods() { changeLanguage("en_US"); mEditText.setText("I'm.sure "); mEditText.setSelection(mEditText.getText().length()); mEditText.onAttachedToWindow(); sleep(1000); runMessages(); sleep(1000); final SpanGetter span = new SpanGetter(mEditText.getText(), SuggestionSpan.class); // If no span, the following will crash final String[] suggestions = span.getSuggestions(); // The first suggestion should be "I'm sure". assertEquals("Test spell checking of mistyped period for space", "I'm sure", suggestions[0]); } }