mirror of
https://gitlab.futo.org/keyboard/latinime.git
synced 2024-09-28 14:54:30 +01:00
Merge "Update language to comply with Android’s inclusive language guidance"
This commit is contained in:
commit
b01f678ca8
@ -65,13 +65,15 @@ bool ProbabilityDictContent::setProbabilityEntry(const int terminalId,
|
|||||||
}
|
}
|
||||||
const int entryPos = getEntryPos(terminalId);
|
const int entryPos = getEntryPos(terminalId);
|
||||||
if (terminalId >= mSize) {
|
if (terminalId >= mSize) {
|
||||||
ProbabilityEntry dummyEntry;
|
ProbabilityEntry placeholderEntry;
|
||||||
// Write new entry.
|
// Write new entry.
|
||||||
int writingPos = getBuffer()->getTailPosition();
|
int writingPos = getBuffer()->getTailPosition();
|
||||||
while (writingPos <= entryPos) {
|
while (writingPos <= entryPos) {
|
||||||
// Fulfilling with placeholder entries until writingPos.
|
// Fulfilling with placeholder entries until writingPos.
|
||||||
if (!writeEntry(&dummyEntry, writingPos)) {
|
if (!writeEntry(&placeholderEntry, writingPos)) {
|
||||||
AKLOGE("Cannot write dummy entry. pos: %d, mSize: %d", writingPos, mSize);
|
AKLOGE("Cannot write placeholder entry. pos: %d, mSize: %d",
|
||||||
|
writingPos,
|
||||||
|
mSize);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
writingPos += getEntrySize();
|
writingPos += getEntrySize();
|
||||||
|
@ -41,12 +41,12 @@ class BinaryDictionaryShortcutIterator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Gets the shortcut target itself as an int string and put it to outTarget, put its length
|
// Gets the shortcut target itself as an int string and put it to outTarget, put its length
|
||||||
// to outTargetLength, put whether it is allowlist to outIsWhitelist.
|
// to outTargetLength, put whether it is allowlist to outIsAllowed.
|
||||||
AK_FORCE_INLINE void nextShortcutTarget(
|
AK_FORCE_INLINE void nextShortcutTarget(
|
||||||
const int maxDepth, int *const outTarget, int *const outTargetLength,
|
const int maxDepth, int *const outTarget, int *const outTargetLength,
|
||||||
bool *const outIsWhitelist) {
|
bool *const outIsAllowed) {
|
||||||
mShortcutStructurePolicy->getNextShortcut(maxDepth, outTarget, outTargetLength,
|
mShortcutStructurePolicy->getNextShortcut(maxDepth, outTarget, outTargetLength,
|
||||||
outIsWhitelist, &mHasNextShortcutTarget, &mPos);
|
outIsAllowed, &mHasNextShortcutTarget, &mPos);
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -118,15 +118,15 @@ public class UserHistoryDictionaryTests {
|
|||||||
private void doTestRandomWords(final String testAccount) {
|
private void doTestRandomWords(final String testAccount) {
|
||||||
Log.d(TAG, "This test can be used for profiling.");
|
Log.d(TAG, "This test can be used for profiling.");
|
||||||
Log.d(TAG, "Usage: please set UserHistoryDictionary.PROFILE_SAVE_RESTORE to true.");
|
Log.d(TAG, "Usage: please set UserHistoryDictionary.PROFILE_SAVE_RESTORE to true.");
|
||||||
final Locale dummyLocale = UserHistoryDictionaryTestsHelper.getDummyLocale("random_words");
|
final Locale fakeLocale = UserHistoryDictionaryTestsHelper.getFakeLocale("random_words");
|
||||||
final String dictName = UserHistoryDictionary.getUserHistoryDictName(
|
final String dictName = UserHistoryDictionary.getUserHistoryDictName(
|
||||||
UserHistoryDictionary.NAME, dummyLocale,
|
UserHistoryDictionary.NAME, fakeLocale,
|
||||||
null /* dictFile */,
|
null /* dictFile */,
|
||||||
testAccount /* account */);
|
testAccount /* account */);
|
||||||
final File dictFile = ExpandableBinaryDictionary.getDictFile(
|
final File dictFile = ExpandableBinaryDictionary.getDictFile(
|
||||||
getContext(), dictName, null /* dictFile */);
|
getContext(), dictName, null /* dictFile */);
|
||||||
final UserHistoryDictionary dict = PersonalizationHelper.getUserHistoryDictionary(
|
final UserHistoryDictionary dict = PersonalizationHelper.getUserHistoryDictionary(
|
||||||
getContext(), dummyLocale, testAccount);
|
getContext(), fakeLocale, testAccount);
|
||||||
clearHistory(dict);
|
clearHistory(dict);
|
||||||
|
|
||||||
final int numberOfWords = 1000;
|
final int numberOfWords = 1000;
|
||||||
@ -169,15 +169,15 @@ public class UserHistoryDictionaryTests {
|
|||||||
|
|
||||||
// Create filename suffixes for this test.
|
// Create filename suffixes for this test.
|
||||||
for (int i = 0; i < numberOfLanguages; i++) {
|
for (int i = 0; i < numberOfLanguages; i++) {
|
||||||
final Locale dummyLocale =
|
final Locale fakeLocale =
|
||||||
UserHistoryDictionaryTestsHelper.getDummyLocale("switching_languages" + i);
|
UserHistoryDictionaryTestsHelper.getFakeLocale("switching_languages" + i);
|
||||||
final String dictName = UserHistoryDictionary.getUserHistoryDictName(
|
final String dictName = UserHistoryDictionary.getUserHistoryDictName(
|
||||||
UserHistoryDictionary.NAME, dummyLocale, null /* dictFile */,
|
UserHistoryDictionary.NAME, fakeLocale, null /* dictFile */,
|
||||||
testAccount /* account */);
|
testAccount /* account */);
|
||||||
dictFiles[i] = ExpandableBinaryDictionary.getDictFile(
|
dictFiles[i] = ExpandableBinaryDictionary.getDictFile(
|
||||||
getContext(), dictName, null /* dictFile */);
|
getContext(), dictName, null /* dictFile */);
|
||||||
dicts[i] = PersonalizationHelper.getUserHistoryDictionary(getContext(),
|
dicts[i] = PersonalizationHelper.getUserHistoryDictionary(getContext(),
|
||||||
dummyLocale, testAccount);
|
fakeLocale, testAccount);
|
||||||
clearHistory(dicts[i]);
|
clearHistory(dicts[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -214,19 +214,19 @@ public class UserHistoryDictionaryTests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void doTestAddManyWords(final String testAccount) {
|
private void doTestAddManyWords(final String testAccount) {
|
||||||
final Locale dummyLocale =
|
final Locale fakeLocale =
|
||||||
UserHistoryDictionaryTestsHelper.getDummyLocale("many_random_words");
|
UserHistoryDictionaryTestsHelper.getFakeLocale("many_random_words");
|
||||||
final String dictName = UserHistoryDictionary.getUserHistoryDictName(
|
final String dictName = UserHistoryDictionary.getUserHistoryDictName(
|
||||||
UserHistoryDictionary.NAME, dummyLocale, null /* dictFile */, testAccount);
|
UserHistoryDictionary.NAME, fakeLocale, null /* dictFile */, testAccount);
|
||||||
final File dictFile = ExpandableBinaryDictionary.getDictFile(
|
final File dictFile = ExpandableBinaryDictionary.getDictFile(
|
||||||
getContext(), dictName, null /* dictFile */);
|
getContext(), dictName, null /* dictFile */);
|
||||||
final int numberOfWords = 10000;
|
final int numberOfWords = 10000;
|
||||||
final Random random = new Random(123456);
|
final Random random = new Random(123456);
|
||||||
final UserHistoryDictionary dict = PersonalizationHelper.getUserHistoryDictionary(
|
final UserHistoryDictionary dict = PersonalizationHelper.getUserHistoryDictionary(
|
||||||
getContext(), dummyLocale, testAccount);
|
getContext(), fakeLocale, testAccount);
|
||||||
clearHistory(dict);
|
clearHistory(dict);
|
||||||
assertTrue(UserHistoryDictionaryTestsHelper.addAndWriteRandomWords(dict,
|
assertTrue(UserHistoryDictionaryTestsHelper.addAndWriteRandomWords(dict,
|
||||||
numberOfWords, random, true /* checksContents */, mCurrentTime));
|
numberOfWords, random, true /* checksContents */, mCurrentTime));
|
||||||
assertDictionaryExists(dict, dictFile);
|
assertDictionaryExists(dict, dictFile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -110,7 +110,7 @@ public class UserHistoryDictionaryTestsHelper {
|
|||||||
/**
|
/**
|
||||||
* Creates unique test locale for using within tests.
|
* Creates unique test locale for using within tests.
|
||||||
*/
|
*/
|
||||||
public static Locale getDummyLocale(final String name) {
|
public static Locale getFakeLocale(final String name) {
|
||||||
return new Locale(TEST_LOCALE_PREFIX + name + System.currentTimeMillis());
|
return new Locale(TEST_LOCALE_PREFIX + name + System.currentTimeMillis());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@ public class Info extends Dicttool.Command {
|
|||||||
int wordCount = 0;
|
int wordCount = 0;
|
||||||
int bigramCount = 0;
|
int bigramCount = 0;
|
||||||
int shortcutCount = 0;
|
int shortcutCount = 0;
|
||||||
int whitelistCount = 0;
|
int allowlistCount = 0;
|
||||||
for (final WordProperty wordProperty : dict) {
|
for (final WordProperty wordProperty : dict) {
|
||||||
++wordCount;
|
++wordCount;
|
||||||
if (wordProperty.mHasNgrams) {
|
if (wordProperty.mHasNgrams) {
|
||||||
@ -51,8 +51,8 @@ public class Info extends Dicttool.Command {
|
|||||||
}
|
}
|
||||||
System.out.println("Words in the dictionary : " + wordCount);
|
System.out.println("Words in the dictionary : " + wordCount);
|
||||||
System.out.println("Bigram count : " + bigramCount);
|
System.out.println("Bigram count : " + bigramCount);
|
||||||
System.out.println("Shortcuts : " + shortcutCount + " (out of which " + whitelistCount
|
System.out.println("Shortcuts : " + shortcutCount + " (out of which " + allowlistCount
|
||||||
+ " whitelist entries)");
|
+ " allowlist entries)");
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void showWordInfo(final FusionDictionary dict, final String word) {
|
private static void showWordInfo(final FusionDictionary dict, final String word) {
|
||||||
|
@ -60,7 +60,7 @@ public final class KeyboardTextsTable {
|
|||||||
if (text != null) {
|
if (text != null) {
|
||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
// Sanity check.
|
// Validity check.
|
||||||
if (index >= 0 && index < TEXTS_DEFAULT.length) {
|
if (index >= 0 && index < TEXTS_DEFAULT.length) {
|
||||||
return TEXTS_DEFAULT[index];
|
return TEXTS_DEFAULT[index];
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user