}
public static WordType isRecognizedWord(final String word, final boolean tolerate) {
byte prefLen = 0;
Integer prefixMask;
MorphData md;
if (customWords != null) {
try {
if (customWords.lookup(word) != null) return WordType.CUSTOM;
} catch (IllegalArgumentException ignored_ex) {
}
while (true) {
// Make sure there are at least 2 letters left after the prefix (the words של, שלא for example)
if (word.length() - prefLen < 2)
break;
try {
prefixMask = prefixesTree.lookup(word.substring(0, ++prefLen));
} catch (IllegalArgumentException ignored_ex) {
break;
}
try {
md = customWords.lookup(word.substring(prefLen));
} catch (IllegalArgumentException ignored_ex) {
md = null;
}
if ((md != null) && ((md.getPrefixes() & prefixMask) > 0)) {
for (int result = 0; result < md.getLemmas().length; result++) {
if ((LingInfo.DMask2ps(md.getDescFlags()[result]) & prefixMask) > 0) {
return WordType.CUSTOM_WITH_PREFIX;
}
}
}
}
}
if (!isHebrewWord(word))
return WordType.NON_HEBREW;
try {
if (dictRadix.lookup(word) != null) return WordType.HEBREW;
} catch (IllegalArgumentException ignored_ex) {
}
if (word.endsWith("'")) { // Try ommitting closing Geresh
try {
if (dictRadix.lookup(word.substring(0, word.length() - 1)) != null) return WordType.HEBREW;
} catch (IllegalArgumentException ignored_ex) {
}
}
prefLen = 0;
while (true) {
// Make sure there are at least 2 letters left after the prefix (the words של, שלא for example)
if (word.length() - prefLen < 2)
break;
try {
prefixMask = prefixesTree.lookup(word.substring(0, ++prefLen));
} catch (IllegalArgumentException e) {
break;
}
try {
md = dictRadix.lookup(word.substring(prefLen));
} catch (IllegalArgumentException e) {
md = null;
}
if ((md != null) && ((md.getPrefixes() & prefixMask) > 0)) {
for (int result = 0; result < md.getLemmas().length; result++) {
if ((LingInfo.DMask2ps(md.getDescFlags()[result]) & prefixMask) > 0) {
return WordType.HEBREW_WITH_PREFIX;
}
}
}
}