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
5d218bc0
Commit
5d218bc0
authored
12 years ago
by
Jean Chalard
Committed by
Android (Google) Code Review
12 years ago
Browse files
Options
Downloads
Plain Diff
Merge "Simplify a method call."
parents
61c1002b
bed514bd
No related branches found
No related tags found
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
+21
-24
21 additions, 24 deletions
java/src/com/android/inputmethod/latin/Suggest.java
with
21 additions
and
24 deletions
java/src/com/android/inputmethod/latin/Suggest.java
+
21
−
24
View file @
5d218bc0
...
@@ -222,7 +222,7 @@ public class Suggest {
...
@@ -222,7 +222,7 @@ public class Suggest {
mIsFirstCharCapitalized
=
!
isPrediction
&&
wordComposer
.
isFirstCharCapitalized
();
mIsFirstCharCapitalized
=
!
isPrediction
&&
wordComposer
.
isFirstCharCapitalized
();
mIsAllUpperCase
=
!
isPrediction
&&
wordComposer
.
isAllUpperCase
();
mIsAllUpperCase
=
!
isPrediction
&&
wordComposer
.
isAllUpperCase
();
mTrailingSingleQuotesCount
=
wordComposer
.
trailingSingleQuotesCount
();
mTrailingSingleQuotesCount
=
wordComposer
.
trailingSingleQuotesCount
();
final
ArrayList
<
SuggestedWordInfo
>
suggestions
=
final
ArrayList
<
SuggestedWordInfo
>
suggestions
Container
=
new
ArrayList
<
SuggestedWordInfo
>(
MAX_SUGGESTIONS
);
new
ArrayList
<
SuggestedWordInfo
>(
MAX_SUGGESTIONS
);
final
String
typedWord
=
wordComposer
.
getTypedWord
();
final
String
typedWord
=
wordComposer
.
getTypedWord
();
...
@@ -250,11 +250,9 @@ public class Suggest {
...
@@ -250,11 +250,9 @@ public class Suggest {
if
(
null
!=
lowerPrevWord
)
{
if
(
null
!=
lowerPrevWord
)
{
localSuggestions
.
addAll
(
dictionary
.
getBigrams
(
wordComposer
,
lowerPrevWord
));
localSuggestions
.
addAll
(
dictionary
.
getBigrams
(
wordComposer
,
lowerPrevWord
));
}
}
for
(
final
SuggestedWordInfo
suggestion
:
localSuggestions
)
{
for
(
final
SuggestedWordInfo
localSuggestion
:
localSuggestions
)
{
final
String
suggestionStr
=
suggestion
.
mWord
.
toString
();
addWord
(
localSuggestion
,
dicTypeId
,
Dictionary
.
BIGRAM
,
addWord
(
suggestionStr
,
null
,
suggestionsContainer
,
consideredWord
);
suggestion
.
mScore
,
dicTypeId
,
Dictionary
.
BIGRAM
,
suggestions
,
consideredWord
);
}
}
}
}
}
}
...
@@ -278,10 +276,8 @@ public class Suggest {
...
@@ -278,10 +276,8 @@ public class Suggest {
final
ArrayList
<
SuggestedWordInfo
>
localSuggestions
=
dictionary
.
getWords
(
final
ArrayList
<
SuggestedWordInfo
>
localSuggestions
=
dictionary
.
getWords
(
wordComposerForLookup
,
prevWordForBigram
,
proximityInfo
);
wordComposerForLookup
,
prevWordForBigram
,
proximityInfo
);
for
(
final
SuggestedWordInfo
suggestion
:
localSuggestions
)
{
for
(
final
SuggestedWordInfo
suggestion
:
localSuggestions
)
{
final
String
suggestionStr
=
suggestion
.
mWord
.
toString
();
addWord
(
suggestion
,
dicTypeId
,
Dictionary
.
UNIGRAM
,
addWord
(
suggestionStr
,
null
,
suggestionsContainer
,
consideredWord
);
suggestion
.
mScore
,
dicTypeId
,
Dictionary
.
UNIGRAM
,
suggestions
,
consideredWord
);
}
}
}
}
}
}
...
@@ -293,7 +289,7 @@ public class Suggest {
...
@@ -293,7 +289,7 @@ public class Suggest {
if
(
isCorrectionEnabled
)
{
if
(
isCorrectionEnabled
)
{
final
CharSequence
autoCorrection
=
final
CharSequence
autoCorrection
=
AutoCorrection
.
computeAutoCorrectionWord
(
mDictionaries
,
wordComposer
,
AutoCorrection
.
computeAutoCorrectionWord
(
mDictionaries
,
wordComposer
,
suggestions
,
consideredWord
,
mAutoCorrectionThreshold
,
suggestions
Container
,
consideredWord
,
mAutoCorrectionThreshold
,
whitelistedWord
);
whitelistedWord
);
hasAutoCorrection
=
(
null
!=
autoCorrection
);
hasAutoCorrection
=
(
null
!=
autoCorrection
);
}
else
{
}
else
{
...
@@ -306,25 +302,25 @@ public class Suggest {
...
@@ -306,25 +302,25 @@ public class Suggest {
for
(
int
i
=
mTrailingSingleQuotesCount
-
1
;
i
>=
0
;
--
i
)
{
for
(
int
i
=
mTrailingSingleQuotesCount
-
1
;
i
>=
0
;
--
i
)
{
sb
.
appendCodePoint
(
Keyboard
.
CODE_SINGLE_QUOTE
);
sb
.
appendCodePoint
(
Keyboard
.
CODE_SINGLE_QUOTE
);
}
}
suggestions
.
add
(
0
,
new
SuggestedWordInfo
(
sb
.
toString
(),
suggestions
Container
.
add
(
0
,
new
SuggestedWordInfo
(
sb
.
toString
(),
SuggestedWordInfo
.
MAX_SCORE
,
SuggestedWordInfo
.
KIND_WHITELIST
));
SuggestedWordInfo
.
MAX_SCORE
,
SuggestedWordInfo
.
KIND_WHITELIST
));
}
else
{
}
else
{
suggestions
.
add
(
0
,
new
SuggestedWordInfo
(
whitelistedWord
,
suggestions
Container
.
add
(
0
,
new
SuggestedWordInfo
(
whitelistedWord
,
SuggestedWordInfo
.
MAX_SCORE
,
SuggestedWordInfo
.
KIND_WHITELIST
));
SuggestedWordInfo
.
MAX_SCORE
,
SuggestedWordInfo
.
KIND_WHITELIST
));
}
}
}
}
if
(!
isPrediction
)
{
if
(!
isPrediction
)
{
suggestions
.
add
(
0
,
new
SuggestedWordInfo
(
typedWord
,
SuggestedWordInfo
.
MAX_SCORE
,
suggestions
Container
.
add
(
0
,
new
SuggestedWordInfo
(
typedWord
,
SuggestedWordInfo
.
KIND_TYPED
));
SuggestedWordInfo
.
MAX_SCORE
,
SuggestedWordInfo
.
KIND_TYPED
));
}
}
SuggestedWordInfo
.
removeDups
(
suggestions
);
SuggestedWordInfo
.
removeDups
(
suggestions
Container
);
final
ArrayList
<
SuggestedWordInfo
>
suggestionsList
;
final
ArrayList
<
SuggestedWordInfo
>
suggestionsList
;
if
(
DBG
&&
!
suggestions
.
isEmpty
())
{
if
(
DBG
&&
!
suggestions
Container
.
isEmpty
())
{
suggestionsList
=
getSuggestionsInfoListWithDebugInfo
(
typedWord
,
suggestions
);
suggestionsList
=
getSuggestionsInfoListWithDebugInfo
(
typedWord
,
suggestions
Container
);
}
else
{
}
else
{
suggestionsList
=
suggestions
;
suggestionsList
=
suggestions
Container
;
}
}
// TODO: Change this scheme - a boolean is not enough. A whitelisted word may be "valid"
// TODO: Change this scheme - a boolean is not enough. A whitelisted word may be "valid"
...
@@ -388,13 +384,14 @@ public class Suggest {
...
@@ -388,13 +384,14 @@ public class Suggest {
return
suggestionsList
;
return
suggestionsList
;
}
}
public
boolean
addWord
(
final
S
tring
word
,
int
[]
indices
,
public
boolean
addWord
(
final
S
uggestedWordInfo
wordInfo
,
int
score
,
final
int
dicTypeId
,
final
int
dataType
,
final
int
dicTypeId
,
final
int
dataType
,
final
ArrayList
<
SuggestedWordInfo
>
suggestions
,
final
String
consideredWord
)
{
final
ArrayList
<
SuggestedWordInfo
>
suggestions
,
final
String
consideredWord
)
{
int
dataTypeForLog
=
dataType
;
int
dataTypeForLog
=
dataType
;
final
int
prefMaxSuggestions
=
MAX_SUGGESTIONS
;
final
int
prefMaxSuggestions
=
MAX_SUGGESTIONS
;
final
int
length
=
word
.
codePointCount
(
0
,
word
.
length
());
final
String
word
=
wordInfo
.
mWord
.
toString
();
final
int
score
=
wordInfo
.
mScore
;
int
pos
=
0
;
int
pos
=
0
;
// Check if it's the same word, only caps are different
// Check if it's the same word, only caps are different
...
@@ -416,6 +413,7 @@ public class Suggest {
...
@@ -416,6 +413,7 @@ public class Suggest {
// Check the last one's score and bail
// Check the last one's score and bail
if
(
suggestions
.
size
()
>=
prefMaxSuggestions
if
(
suggestions
.
size
()
>=
prefMaxSuggestions
&&
suggestions
.
get
(
prefMaxSuggestions
-
1
).
mScore
>=
score
)
return
true
;
&&
suggestions
.
get
(
prefMaxSuggestions
-
1
).
mScore
>=
score
)
return
true
;
final
int
length
=
word
.
codePointCount
(
0
,
word
.
length
());
while
(
pos
<
suggestions
.
size
())
{
while
(
pos
<
suggestions
.
size
())
{
final
int
curScore
=
suggestions
.
get
(
pos
).
mScore
;
final
int
curScore
=
suggestions
.
get
(
pos
).
mScore
;
if
(
curScore
<
score
if
(
curScore
<
score
...
@@ -440,8 +438,7 @@ public class Suggest {
...
@@ -440,8 +438,7 @@ public class Suggest {
for
(
int
i
=
mTrailingSingleQuotesCount
-
1
;
i
>=
0
;
--
i
)
{
for
(
int
i
=
mTrailingSingleQuotesCount
-
1
;
i
>=
0
;
--
i
)
{
sb
.
appendCodePoint
(
Keyboard
.
CODE_SINGLE_QUOTE
);
sb
.
appendCodePoint
(
Keyboard
.
CODE_SINGLE_QUOTE
);
}
}
// TODO: figure out what type of suggestion this is
suggestions
.
add
(
pos
,
new
SuggestedWordInfo
(
sb
,
score
,
wordInfo
.
mKind
));
suggestions
.
add
(
pos
,
new
SuggestedWordInfo
(
sb
,
score
,
SuggestedWordInfo
.
KIND_CORRECTION
));
if
(
suggestions
.
size
()
>
prefMaxSuggestions
)
{
if
(
suggestions
.
size
()
>
prefMaxSuggestions
)
{
suggestions
.
remove
(
prefMaxSuggestions
);
suggestions
.
remove
(
prefMaxSuggestions
);
}
else
{
}
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