am 84a3047e: Fix build.
* commit '84a3047e801923bd486b0cff2f9ea0de25d7e3ba': Fix build.main
commit
f43a9a7eb2
|
@ -20,13 +20,16 @@ import android.content.ContentValues;
|
|||
import android.content.Context;
|
||||
import android.content.res.AssetManager;
|
||||
import android.content.res.Resources;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import com.android.inputmethod.annotations.UsedForTesting;
|
||||
import com.android.inputmethod.latin.AssetFileAddress;
|
||||
import com.android.inputmethod.latin.BinaryDictionaryGetter;
|
||||
import com.android.inputmethod.latin.R;
|
||||
import com.android.inputmethod.latin.makedict.BinaryDictIOUtils;
|
||||
import com.android.inputmethod.latin.makedict.FormatSpec.FileHeader;
|
||||
import com.android.inputmethod.latin.settings.SpacingAndPunctuations;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
|
@ -364,4 +367,29 @@ public class DictionaryInfoUtils {
|
|||
|
||||
return dictList;
|
||||
}
|
||||
|
||||
@UsedForTesting
|
||||
public static boolean looksValidForDictionaryInsertion(final CharSequence text,
|
||||
final SpacingAndPunctuations spacingAndPunctuations) {
|
||||
if (TextUtils.isEmpty(text)) return false;
|
||||
final int length = text.length();
|
||||
int i = 0;
|
||||
int digitCount = 0;
|
||||
while (i < length) {
|
||||
final int codePoint = Character.codePointAt(text, i);
|
||||
final int charCount = Character.charCount(codePoint);
|
||||
i += charCount;
|
||||
if (Character.isDigit(codePoint)) {
|
||||
// Count digits: see below
|
||||
digitCount += charCount;
|
||||
continue;
|
||||
}
|
||||
if (!spacingAndPunctuations.isWordCodePoint(codePoint)) return false;
|
||||
}
|
||||
// We reject strings entirely comprised of digits to avoid using PIN codes or credit
|
||||
// card numbers. It would come in handy for word prediction though; a good example is
|
||||
// when writing one's address where the street number is usually quite discriminative,
|
||||
// as well as the postal code.
|
||||
return digitCount < length;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,7 +20,6 @@ import android.text.TextUtils;
|
|||
|
||||
import com.android.inputmethod.annotations.UsedForTesting;
|
||||
import com.android.inputmethod.latin.Constants;
|
||||
import com.android.inputmethod.latin.settings.SpacingAndPunctuations;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Locale;
|
||||
|
@ -265,31 +264,6 @@ public final class StringUtils {
|
|||
return true;
|
||||
}
|
||||
|
||||
@UsedForTesting
|
||||
public static boolean looksValidForDictionaryInsertion(final CharSequence text,
|
||||
final SpacingAndPunctuations spacingAndPunctuations) {
|
||||
if (TextUtils.isEmpty(text)) return false;
|
||||
final int length = text.length();
|
||||
int i = 0;
|
||||
int digitCount = 0;
|
||||
while (i < length) {
|
||||
final int codePoint = Character.codePointAt(text, i);
|
||||
final int charCount = Character.charCount(codePoint);
|
||||
i += charCount;
|
||||
if (Character.isDigit(codePoint)) {
|
||||
// Count digits: see below
|
||||
digitCount += charCount;
|
||||
continue;
|
||||
}
|
||||
if (!spacingAndPunctuations.isWordCodePoint(codePoint)) return false;
|
||||
}
|
||||
// We reject strings entirely comprised of digits to avoid using PIN codes or credit
|
||||
// card numbers. It would come in handy for word prediction though; a good example is
|
||||
// when writing one's address where the street number is usually quite discriminative,
|
||||
// as well as the postal code.
|
||||
return digitCount < length;
|
||||
}
|
||||
|
||||
public static boolean isIdenticalAfterCapitalizeEachWord(final String text,
|
||||
final String separators) {
|
||||
boolean needCapsNext = true;
|
||||
|
|
|
@ -0,0 +1,47 @@
|
|||
/*
|
||||
* Copyright (C) 2014 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.inputmethod.latin.utils;
|
||||
|
||||
import android.content.res.Resources;
|
||||
import android.test.AndroidTestCase;
|
||||
import android.test.suitebuilder.annotation.SmallTest;
|
||||
|
||||
import com.android.inputmethod.latin.settings.SpacingAndPunctuations;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
@SmallTest
|
||||
public class DictionaryInfoUtilsTests extends AndroidTestCase {
|
||||
public void testLooksValidForDictionaryInsertion() {
|
||||
final RunInLocale<SpacingAndPunctuations> job = new RunInLocale<SpacingAndPunctuations>() {
|
||||
@Override
|
||||
protected SpacingAndPunctuations job(final Resources res) {
|
||||
return new SpacingAndPunctuations(res);
|
||||
}
|
||||
};
|
||||
final Resources res = getContext().getResources();
|
||||
final SpacingAndPunctuations sp = job.runInLocale(res, Locale.ENGLISH);
|
||||
assertTrue(DictionaryInfoUtils.looksValidForDictionaryInsertion("aochaueo", sp));
|
||||
assertFalse(DictionaryInfoUtils.looksValidForDictionaryInsertion("", sp));
|
||||
assertTrue(DictionaryInfoUtils.looksValidForDictionaryInsertion("ao-ch'aueo", sp));
|
||||
assertFalse(DictionaryInfoUtils.looksValidForDictionaryInsertion("2908743256", sp));
|
||||
assertTrue(DictionaryInfoUtils.looksValidForDictionaryInsertion("31aochaueo", sp));
|
||||
assertFalse(DictionaryInfoUtils.looksValidForDictionaryInsertion("akeo raeoch oerch .",
|
||||
sp));
|
||||
assertFalse(DictionaryInfoUtils.looksValidForDictionaryInsertion("!!!", sp));
|
||||
}
|
||||
}
|
|
@ -16,12 +16,9 @@
|
|||
|
||||
package com.android.inputmethod.latin.utils;
|
||||
|
||||
import android.content.res.Resources;
|
||||
import android.test.AndroidTestCase;
|
||||
import android.test.suitebuilder.annotation.SmallTest;
|
||||
|
||||
import com.android.inputmethod.latin.settings.SpacingAndPunctuations;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
@ -209,24 +206,6 @@ public class StringAndJsonUtilsTests extends AndroidTestCase {
|
|||
assertTrue(StringUtils.isIdenticalAfterDowncase(""));
|
||||
}
|
||||
|
||||
public void testLooksValidForDictionaryInsertion() {
|
||||
final RunInLocale<SpacingAndPunctuations> job = new RunInLocale<SpacingAndPunctuations>() {
|
||||
@Override
|
||||
protected SpacingAndPunctuations job(final Resources res) {
|
||||
return new SpacingAndPunctuations(res);
|
||||
}
|
||||
};
|
||||
final Resources res = getContext().getResources();
|
||||
final SpacingAndPunctuations sp = job.runInLocale(res, Locale.ENGLISH);
|
||||
assertTrue(StringUtils.looksValidForDictionaryInsertion("aochaueo", sp));
|
||||
assertFalse(StringUtils.looksValidForDictionaryInsertion("", sp));
|
||||
assertTrue(StringUtils.looksValidForDictionaryInsertion("ao-ch'aueo", sp));
|
||||
assertFalse(StringUtils.looksValidForDictionaryInsertion("2908743256", sp));
|
||||
assertTrue(StringUtils.looksValidForDictionaryInsertion("31aochaueo", sp));
|
||||
assertFalse(StringUtils.looksValidForDictionaryInsertion("akeo raeoch oerch .", sp));
|
||||
assertFalse(StringUtils.looksValidForDictionaryInsertion("!!!", sp));
|
||||
}
|
||||
|
||||
private static void checkCapitalize(final String src, final String dst, final String separators,
|
||||
final Locale locale) {
|
||||
assertEquals(dst, StringUtils.capitalizeEachWord(src, separators, locale));
|
||||
|
|
|
@ -1,23 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2013 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.android.inputmethod.latin.settings;
|
||||
|
||||
public class SettingsValues {
|
||||
public boolean isWordCodePoint(final int code) {
|
||||
return Character.isLetter(code);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue