diff options
author | 2015-04-13 15:26:48 -0700 | |
---|---|---|
committer | 2015-04-13 16:28:26 -0700 | |
commit | 1bfd7be2080f97d15b57ec1cac0dba1f1f2ca23d (patch) | |
tree | 8e01cfa8f3f2e418354cc78836d1613f855e1e66 /tests/src/com | |
parent | 40f0f61bb365b5073f1d9fdb56a393c5df5ef4b0 (diff) | |
download | latinime-1bfd7be2080f97d15b57ec1cac0dba1f1f2ca23d.tar.gz latinime-1bfd7be2080f97d15b57ec1cac0dba1f1f2ca23d.tar.xz latinime-1bfd7be2080f97d15b57ec1cac0dba1f1f2ca23d.zip |
Store raw strings for personal dictionary
The raw strings would be sent to personal LM for decoding.
Earlier lowercased strings were being used with the purpose
of isValid checks (spelling does not consider casing for spell
checking calls). But for showing these in suggestion, we need the
raw strings.
Note: PersonalDictionaryLookup#getWordsForLocale is used to feed
the personal LM in PersonalLanguageModelHelper.
Bug:20152986
Change-Id: I9d796fa57bf2073036bf11d86b143ff205a6199c
Diffstat (limited to 'tests/src/com')
-rw-r--r-- | tests/src/com/android/inputmethod/latin/PersonalDictionaryLookupTest.java | 40 |
1 files changed, 39 insertions, 1 deletions
diff --git a/tests/src/com/android/inputmethod/latin/PersonalDictionaryLookupTest.java b/tests/src/com/android/inputmethod/latin/PersonalDictionaryLookupTest.java index 983957fd4..c06adedfd 100644 --- a/tests/src/com/android/inputmethod/latin/PersonalDictionaryLookupTest.java +++ b/tests/src/com/android/inputmethod/latin/PersonalDictionaryLookupTest.java @@ -289,7 +289,8 @@ public class PersonalDictionaryLookupTest extends AndroidTestCase { addWord("fOo", Locale.FRENCH, 17, null); // Create the PersonalDictionaryLookup and wait until it's loaded. - PersonalDictionaryLookup lookup = new PersonalDictionaryLookup(mContext, ExecutorUtils.SPELLING); + PersonalDictionaryLookup lookup = new PersonalDictionaryLookup(mContext, + ExecutorUtils.SPELLING); lookup.open(); // Both en_CA and en_US match. @@ -304,6 +305,43 @@ public class PersonalDictionaryLookupTest extends AndroidTestCase { lookup.close(); } + + public void testCaseMatchingForWordsAndShortcuts() { + Log.d(TAG, "testCaseMatchingForWordsAndShortcuts"); + addWord("Foo", Locale.US, 17, "f"); + addWord("bokabu", Locale.US, 17, "Bu"); + + // Create the PersonalDictionaryLookup and wait until it's loaded. + PersonalDictionaryLookup lookup = new PersonalDictionaryLookup(mContext, + ExecutorUtils.SPELLING); + lookup.open(); + + // Valid, inspite of capitalization in US but not in other + // locales. + assertTrue(lookup.isValidWord("Foo", Locale.US)); + assertTrue(lookup.isValidWord("foo", Locale.US)); + assertFalse(lookup.isValidWord("Foo", Locale.UK)); + assertFalse(lookup.isValidWord("foo", Locale.UK)); + + // Valid in all forms in US. + assertTrue(lookup.isValidWord("bokabu", Locale.US)); + assertTrue(lookup.isValidWord("BOKABU", Locale.US)); + assertTrue(lookup.isValidWord("BokaBU", Locale.US)); + + // Correct capitalization; sensitive to shortcut casing & locale. + assertEquals("Foo", lookup.expandShortcut("f", Locale.US)); + assertNull(lookup.expandShortcut("f", Locale.UK)); + + // Correct capitalization; sensitive to shortcut casing & locale. + assertEquals("bokabu", lookup.expandShortcut("Bu", Locale.US)); + assertNull(lookup.expandShortcut("Bu", Locale.UK)); + assertNull(lookup.expandShortcut("bu", Locale.US)); + + // Verify that raw strings are retained for #getWordsForLocale. + verifyWordExists(lookup.getWordsForLocale(Locale.US), "Foo"); + verifyWordDoesNotExist(lookup.getWordsForLocale(Locale.US), "foo"); + } + public void testManageListeners() { Log.d(TAG, "testManageListeners"); |