am 0295a398: am eae7b293: Check the length of the word when add to FusionDictionary.
* commit '0295a39845da87f6f082d50a5c3b1b403f5e07c2': Check the length of the word when add to FusionDictionary.main
commit
3cff0dab82
|
@ -41,7 +41,7 @@ public class BinaryDictionary extends Dictionary {
|
||||||
* It is necessary to keep it at this value because some languages e.g. German have
|
* It is necessary to keep it at this value because some languages e.g. German have
|
||||||
* really long words.
|
* really long words.
|
||||||
*/
|
*/
|
||||||
public static final int MAX_WORD_LENGTH = 48;
|
public static final int MAX_WORD_LENGTH = Constants.Dictionary.MAX_WORD_LENGTH;
|
||||||
public static final int MAX_WORDS = 18;
|
public static final int MAX_WORDS = 18;
|
||||||
public static final int MAX_SPACES = 16;
|
public static final int MAX_SPACES = 16;
|
||||||
|
|
||||||
|
|
|
@ -128,6 +128,14 @@ public final class Constants {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static class Dictionary {
|
||||||
|
public static final int MAX_WORD_LENGTH = 48;
|
||||||
|
|
||||||
|
private Dictionary() {
|
||||||
|
// This utility class is no publicly instantiable.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static final int NOT_A_CODE = -1;
|
public static final int NOT_A_CODE = -1;
|
||||||
|
|
||||||
// See {@link KeyboardActionListener.Adapter#isInvalidCoordinate(int)}.
|
// See {@link KeyboardActionListener.Adapter#isInvalidCoordinate(int)}.
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
|
|
||||||
package com.android.inputmethod.latin.makedict;
|
package com.android.inputmethod.latin.makedict;
|
||||||
|
|
||||||
|
import com.android.inputmethod.latin.Constants;
|
||||||
import com.android.inputmethod.latin.makedict.FusionDictionary.CharGroup;
|
import com.android.inputmethod.latin.makedict.FusionDictionary.CharGroup;
|
||||||
import com.android.inputmethod.latin.makedict.FusionDictionary.DictionaryOptions;
|
import com.android.inputmethod.latin.makedict.FusionDictionary.DictionaryOptions;
|
||||||
import com.android.inputmethod.latin.makedict.FusionDictionary.Node;
|
import com.android.inputmethod.latin.makedict.FusionDictionary.Node;
|
||||||
|
@ -143,7 +144,7 @@ public class BinaryDictInputOutput {
|
||||||
|
|
||||||
// TODO: Make this value adaptative to content data, store it in the header, and
|
// TODO: Make this value adaptative to content data, store it in the header, and
|
||||||
// use it in the reading code.
|
// use it in the reading code.
|
||||||
private static final int MAX_WORD_LENGTH = 48;
|
private static final int MAX_WORD_LENGTH = Constants.Dictionary.MAX_WORD_LENGTH;
|
||||||
|
|
||||||
private static final int MASK_GROUP_ADDRESS_TYPE = 0xC0;
|
private static final int MASK_GROUP_ADDRESS_TYPE = 0xC0;
|
||||||
private static final int FLAG_GROUP_ADDRESS_TYPE_NOADDRESS = 0x00;
|
private static final int FLAG_GROUP_ADDRESS_TYPE_NOADDRESS = 0x00;
|
||||||
|
|
|
@ -16,6 +16,8 @@
|
||||||
|
|
||||||
package com.android.inputmethod.latin.makedict;
|
package com.android.inputmethod.latin.makedict;
|
||||||
|
|
||||||
|
import com.android.inputmethod.latin.Constants;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
@ -382,6 +384,11 @@ public class FusionDictionary implements Iterable<Word> {
|
||||||
final ArrayList<WeightedString> shortcutTargets,
|
final ArrayList<WeightedString> shortcutTargets,
|
||||||
final boolean isNotAWord, final boolean isBlacklistEntry) {
|
final boolean isNotAWord, final boolean isBlacklistEntry) {
|
||||||
assert(frequency >= 0 && frequency <= 255);
|
assert(frequency >= 0 && frequency <= 255);
|
||||||
|
if (word.length >= Constants.Dictionary.MAX_WORD_LENGTH) {
|
||||||
|
MakedictLog.w("Ignoring a word that is too long: word.length = " + word.length);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Node currentNode = mRoot;
|
Node currentNode = mRoot;
|
||||||
int charIndex = 0;
|
int charIndex = 0;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue