Avoid the removal of high-ranking exactly typed candidates.

It used to be the case that the scoring system turns up the same word
that was entered with a different capitalization, but with a lower
score than some other, more frequent word. To cope with this, there
was code that would order such candidates in the first slot no matter
what. This processing is now useless because fully matching words now
have a huge boost that ensures they will get to the top of the list,
before any non-fully matching word (which means, differing only by
capitalization or accents).

The bug that did happen with this was, if a fully-matching word got
matched by several processing passes, and the (chronologically) later
score affected to this word was weaker, it would result in the
duplicate removal pass removing the stronger score. This in turn would
mess with autocorrect.

In an effort to keep the risk at a minimum for MR1, this change does
not actually remove the useless code, but adds a check in the odd case
to avoid the bad situation. Another change will remove the code for
ICS release.

bug: 4100269

Change-Id: I18c0575332981ffec0e257e26a360995838d521e
main
Jean Chalard 2011-03-15 15:56:29 -07:00
parent c0471c43fb
commit d631651b12
1 changed files with 14 additions and 1 deletions

View File

@ -454,7 +454,20 @@ public class Suggest implements Dictionary.WordCallback {
// Check if it's the same word, only caps are different // Check if it's the same word, only caps are different
if (compareCaseInsensitive(mLowerOriginalWord, word, offset, length)) { if (compareCaseInsensitive(mLowerOriginalWord, word, offset, length)) {
pos = 0; // TODO: remove this surrounding if clause and move this logic to
// getSuggestedWordBuilder.
if (suggestions.size() > 0) {
final String currentHighestWordLowerCase =
suggestions.get(0).toString().toLowerCase();
// If the current highest word is also equal to typed word, we need to compare
// frequency to determine the insertion position. This does not ensure strictly
// correct ordering, but ensures the top score is on top which is enough for
// removing duplicates correctly.
if (compareCaseInsensitive(currentHighestWordLowerCase, word, offset, length)
&& freq <= priorities[0]) {
pos = 1;
}
}
} else { } else {
if (dataType == Dictionary.DataType.UNIGRAM) { if (dataType == Dictionary.DataType.UNIGRAM) {
// Check if the word was already added before (by bigram data) // Check if the word was already added before (by bigram data)