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
b7cdafd7
Commit
b7cdafd7
authored
12 years ago
by
Jean Chalard
Browse files
Options
Downloads
Patches
Plain Diff
Don't pass everything to a function that needs only the head (A2)
Change-Id: Ic367836202ab8071c1a9a02eaf0651b0da947d51
parent
09b30ac9
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
java/src/com/android/inputmethod/latin/AutoCorrection.java
+11
-12
11 additions, 12 deletions
java/src/com/android/inputmethod/latin/AutoCorrection.java
java/src/com/android/inputmethod/latin/Suggest.java
+3
-1
3 additions, 1 deletion
java/src/com/android/inputmethod/latin/Suggest.java
with
14 additions
and
13 deletions
java/src/com/android/inputmethod/latin/AutoCorrection.java
+
11
−
12
View file @
b7cdafd7
...
...
@@ -34,17 +34,17 @@ public class AutoCorrection {
public
static
CharSequence
computeAutoCorrectionWord
(
final
ConcurrentHashMap
<
String
,
Dictionary
>
dictionaries
,
final
WordComposer
wordComposer
,
final
ArrayList
<
SuggestedWordInfo
>
suggestion
s
,
final
WordComposer
wordComposer
,
SuggestedWordInfo
suggestion
,
final
CharSequence
consideredWord
,
final
float
autoCorrectionThreshold
,
final
CharSequence
whitelistedWord
)
{
if
(
hasAutoCorrectionForWhitelistedWord
(
whitelistedWord
))
{
return
whitelistedWord
;
}
else
if
(
hasAutoCorrectionForConsideredWord
(
dictionaries
,
wordComposer
,
suggestion
s
,
consideredWord
))
{
dictionaries
,
wordComposer
,
suggestion
,
consideredWord
))
{
return
consideredWord
;
}
else
if
(
hasAutoCorrectionForBinaryDictionary
(
wordComposer
,
suggestion
s
,
}
else
if
(
hasAutoCorrectionForBinaryDictionary
(
wordComposer
,
suggestion
,
consideredWord
,
autoCorrectionThreshold
))
{
return
suggestion
s
.
get
(
0
)
.
mWord
;
return
suggestion
.
mWord
;
}
return
null
;
}
...
...
@@ -111,27 +111,26 @@ public class AutoCorrection {
private
static
boolean
hasAutoCorrectionForConsideredWord
(
final
ConcurrentHashMap
<
String
,
Dictionary
>
dictionaries
,
final
WordComposer
wordComposer
,
final
ArrayList
<
SuggestedWordInfo
>
suggestion
s
,
final
WordComposer
wordComposer
,
final
SuggestedWordInfo
suggestion
,
final
CharSequence
consideredWord
)
{
if
(
TextUtils
.
isEmpty
(
consideredWord
))
return
false
;
return
wordComposer
.
size
()
>
1
&&
suggestion
s
.
size
()
>
0
return
wordComposer
.
size
()
>
1
&&
null
!=
suggestion
&&
!
allowsToBeAutoCorrected
(
dictionaries
,
consideredWord
,
false
);
}
private
static
boolean
hasAutoCorrectionForBinaryDictionary
(
WordComposer
wordComposer
,
ArrayList
<
SuggestedWordInfo
>
suggestion
s
,
SuggestedWordInfo
suggestion
,
CharSequence
consideredWord
,
float
autoCorrectionThreshold
)
{
if
(
wordComposer
.
size
()
>
1
&&
suggestions
.
size
()
>
0
)
{
final
SuggestedWordInfo
autoCorrectionSuggestion
=
suggestions
.
get
(
0
);
if
(
wordComposer
.
size
()
>
1
&&
null
!=
suggestion
)
{
//final int autoCorrectionSuggestionScore = sortedScores[0];
final
int
autoCorrectionSuggestionScore
=
autoCorrectionS
uggestion
.
mScore
;
final
int
autoCorrectionSuggestionScore
=
s
uggestion
.
mScore
;
// TODO: when the normalized score of the first suggestion is nearly equals to
// the normalized score of the second suggestion, behave less aggressive.
final
float
normalizedScore
=
BinaryDictionary
.
calcNormalizedScore
(
consideredWord
.
toString
(),
autoCorrectionS
uggestion
.
mWord
.
toString
(),
consideredWord
.
toString
(),
s
uggestion
.
mWord
.
toString
(),
autoCorrectionSuggestionScore
);
if
(
DBG
)
{
Log
.
d
(
TAG
,
"Normalized "
+
consideredWord
+
","
+
autoCorrectionS
uggestion
+
","
Log
.
d
(
TAG
,
"Normalized "
+
consideredWord
+
","
+
s
uggestion
+
","
+
autoCorrectionSuggestionScore
+
", "
+
normalizedScore
+
"("
+
autoCorrectionThreshold
+
")"
);
}
...
...
This diff is collapsed.
Click to expand it.
java/src/com/android/inputmethod/latin/Suggest.java
+
3
−
1
View file @
b7cdafd7
...
...
@@ -249,6 +249,8 @@ public class Suggest {
transformedWordInfo
.
mSourceDict
);
}
final
SuggestedWordInfo
bestSuggestion
=
suggestionsContainer
.
isEmpty
()
?
null
:
suggestionsContainer
.
get
(
0
);
final
CharSequence
whitelistedWord
=
capitalizeWord
(
isAllUpperCase
,
isFirstCharCapitalized
,
mWhiteListDictionary
.
getWhitelistedWord
(
consideredWord
));
...
...
@@ -256,7 +258,7 @@ public class Suggest {
if
(
isCorrectionEnabled
)
{
final
CharSequence
autoCorrection
=
AutoCorrection
.
computeAutoCorrectionWord
(
mDictionaries
,
wordComposer
,
s
uggestion
sContainer
,
consideredWord
,
mAutoCorrectionThreshold
,
bestS
uggestion
,
consideredWord
,
mAutoCorrectionThreshold
,
whitelistedWord
);
hasAutoCorrection
=
(
null
!=
autoCorrection
);
}
else
{
...
...
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