Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
LatinIME
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
keyboard
LatinIME
Commits
0d0f1829
Commit
0d0f1829
authored
13 years ago
by
Jean Chalard
Browse files
Options
Downloads
Patches
Plain Diff
Cut out a private method to make things more readable
Change-Id: I791700890338e023bd86b8794dbc90379b91dc7d
parent
ac5e4634
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
java/src/com/android/inputmethod/latin/Suggest.java
+32
-24
32 additions, 24 deletions
java/src/com/android/inputmethod/latin/Suggest.java
with
32 additions
and
24 deletions
java/src/com/android/inputmethod/latin/Suggest.java
+
32
−
24
View file @
0d0f1829
...
...
@@ -395,30 +395,7 @@ public class Suggest implements Dictionary.WordCallback {
final
ArrayList
<
SuggestedWordInfo
>
suggestionsList
;
if
(
DBG
)
{
// TODO: this doesn't take into account the fact that removing dupes from mSuggestions
// may have made mScores[] and mSuggestions out of sync.
final
CharSequence
autoCorrectionSuggestion
=
mSuggestions
.
get
(
0
);
double
normalizedScore
=
BinaryDictionary
.
calcNormalizedScore
(
typedWord
,
autoCorrectionSuggestion
.
toString
(),
mScores
[
0
]);
final
int
suggestionsSize
=
mSuggestions
.
size
();
suggestionsList
=
new
ArrayList
<
SuggestedWordInfo
>(
suggestionsSize
);
suggestionsList
.
add
(
new
SuggestedWordInfo
(
autoCorrectionSuggestion
,
"+"
,
false
));
// Note: i here is the index in mScores[], but the index in mSuggestions is one more
// than i because we added the typed word to mSuggestions without touching mScores.
for
(
int
i
=
0
;
i
<
mScores
.
length
&&
i
<
suggestionsSize
-
1
;
++
i
)
{
final
String
scoreInfoString
;
if
(
normalizedScore
>
0
)
{
scoreInfoString
=
String
.
format
(
"%d (%4.2f)"
,
mScores
[
i
],
normalizedScore
);
normalizedScore
=
0.0
;
}
else
{
scoreInfoString
=
Integer
.
toString
(
mScores
[
i
]);
}
suggestionsList
.
add
(
new
SuggestedWordInfo
(
mSuggestions
.
get
(
i
+
1
),
scoreInfoString
,
false
));
}
for
(
int
i
=
mScores
.
length
;
i
<
suggestionsSize
;
++
i
)
{
suggestionsList
.
add
(
new
SuggestedWordInfo
(
mSuggestions
.
get
(
i
),
"--"
,
false
));
}
suggestionsList
=
getSuggestionsInfoListWithDebugInfo
(
typedWord
,
mSuggestions
,
mScores
);
}
else
{
suggestionsList
=
SuggestedWords
.
getFromCharSequenceList
(
mSuggestions
);
}
...
...
@@ -446,6 +423,37 @@ public class Suggest implements Dictionary.WordCallback {
false
/* isPunctuationSuggestions */
);
}
// This assumes the scores[] array is at least as long as suggestions.size() - 1.
private
static
ArrayList
<
SuggestedWordInfo
>
getSuggestionsInfoListWithDebugInfo
(
final
String
typedWord
,
final
ArrayList
<
CharSequence
>
suggestions
,
final
int
[]
scores
)
{
// TODO: this doesn't take into account the fact that removing dupes from mSuggestions
// may have made mScores[] and mSuggestions out of sync.
final
CharSequence
autoCorrectionSuggestion
=
suggestions
.
get
(
0
);
double
normalizedScore
=
BinaryDictionary
.
calcNormalizedScore
(
typedWord
,
autoCorrectionSuggestion
.
toString
(),
scores
[
0
]);
final
int
suggestionsSize
=
suggestions
.
size
();
final
ArrayList
<
SuggestedWordInfo
>
suggestionsList
=
new
ArrayList
<
SuggestedWordInfo
>(
suggestionsSize
);
suggestionsList
.
add
(
new
SuggestedWordInfo
(
autoCorrectionSuggestion
,
"+"
,
false
));
// Note: i here is the index in mScores[], but the index in mSuggestions is one more
// than i because we added the typed word to mSuggestions without touching mScores.
for
(
int
i
=
0
;
i
<
scores
.
length
&&
i
<
suggestionsSize
-
1
;
++
i
)
{
final
String
scoreInfoString
;
if
(
normalizedScore
>
0
)
{
scoreInfoString
=
String
.
format
(
"%d (%4.2f)"
,
scores
[
i
],
normalizedScore
);
normalizedScore
=
0.0
;
}
else
{
scoreInfoString
=
Integer
.
toString
(
scores
[
i
]);
}
suggestionsList
.
add
(
new
SuggestedWordInfo
(
suggestions
.
get
(
i
+
1
),
scoreInfoString
,
false
));
}
for
(
int
i
=
scores
.
length
;
i
<
suggestionsSize
;
++
i
)
{
suggestionsList
.
add
(
new
SuggestedWordInfo
(
suggestions
.
get
(
i
),
"--"
,
false
));
}
return
suggestionsList
;
}
@Override
public
boolean
addWord
(
final
char
[]
word
,
final
int
offset
,
final
int
length
,
int
score
,
final
int
dicTypeId
,
final
int
dataType
)
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment