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
a4bd4e44
Commit
a4bd4e44
authored
12 years ago
by
Jean Chalard
Committed by
Android (Google) Code Review
12 years ago
Browse files
Options
Downloads
Plain Diff
Merge "Neutralize Suggest#addWords (A12)"
parents
18223887
78304760
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
+39
-4
39 additions, 4 deletions
java/src/com/android/inputmethod/latin/Suggest.java
with
39 additions
and
4 deletions
java/src/com/android/inputmethod/latin/Suggest.java
+
39
−
4
View file @
a4bd4e44
...
@@ -26,6 +26,7 @@ import com.android.inputmethod.latin.SuggestedWords.SuggestedWordInfo;
...
@@ -26,6 +26,7 @@ import com.android.inputmethod.latin.SuggestedWords.SuggestedWordInfo;
import
java.io.File
;
import
java.io.File
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.HashSet
;
import
java.util.HashSet
;
import
java.util.Locale
;
import
java.util.Locale
;
import
java.util.concurrent.ConcurrentHashMap
;
import
java.util.concurrent.ConcurrentHashMap
;
...
@@ -63,6 +64,18 @@ public class Suggest implements Dictionary.WordCallback {
...
@@ -63,6 +64,18 @@ public class Suggest implements Dictionary.WordCallback {
// User history dictionary for the bigram map, internal to LatinIME
// User history dictionary for the bigram map, internal to LatinIME
public
static
final
String
DICT_KEY_USER_HISTORY_BIGRAM
=
"history_bigram"
;
public
static
final
String
DICT_KEY_USER_HISTORY_BIGRAM
=
"history_bigram"
;
public
static
final
String
DICT_KEY_WHITELIST
=
"whitelist"
;
public
static
final
String
DICT_KEY_WHITELIST
=
"whitelist"
;
// TODO: remove this map. This only serves as backward compatibility with a feature
// that has never been used and has been broken for a while.
private
static
final
HashMap
<
String
,
Integer
>
sDictKeyToDictIndex
=
new
HashMap
<
String
,
Integer
>();
static
{
sDictKeyToDictIndex
.
put
(
DICT_KEY_MAIN
,
DIC_MAIN
);
sDictKeyToDictIndex
.
put
(
DICT_KEY_USER
,
DIC_USER
);
sDictKeyToDictIndex
.
put
(
DICT_KEY_USER_HISTORY_UNIGRAM
,
DIC_USER_HISTORY
);
sDictKeyToDictIndex
.
put
(
DICT_KEY_USER_HISTORY_BIGRAM
,
DIC_USER_HISTORY
);
sDictKeyToDictIndex
.
put
(
DICT_KEY_CONTACTS
,
DIC_CONTACTS
);
sDictKeyToDictIndex
.
put
(
DICT_KEY_WHITELIST
,
DIC_WHITELIST
);
}
private
static
final
boolean
DBG
=
LatinImeLogger
.
sDBG
;
private
static
final
boolean
DBG
=
LatinImeLogger
.
sDBG
;
...
@@ -247,10 +260,18 @@ public class Suggest implements Dictionary.WordCallback {
...
@@ -247,10 +260,18 @@ public class Suggest implements Dictionary.WordCallback {
lowerPrevWord
=
null
;
lowerPrevWord
=
null
;
}
}
for
(
final
String
key
:
mBigramDictionaries
.
keySet
())
{
for
(
final
String
key
:
mBigramDictionaries
.
keySet
())
{
final
int
dicTypeId
=
sDictKeyToDictIndex
.
get
(
key
);
final
Dictionary
dictionary
=
mBigramDictionaries
.
get
(
key
);
final
Dictionary
dictionary
=
mBigramDictionaries
.
get
(
key
);
dictionary
.
getBigrams
(
wordComposer
,
prevWordForBigram
,
this
);
final
ArrayList
<
SuggestedWordInfo
>
suggestions
=
dictionary
.
getBigrams
(
wordComposer
,
prevWordForBigram
,
this
);
if
(
null
!=
lowerPrevWord
)
{
if
(
null
!=
lowerPrevWord
)
{
dictionary
.
getBigrams
(
wordComposer
,
lowerPrevWord
,
this
);
suggestions
.
addAll
(
dictionary
.
getBigrams
(
wordComposer
,
lowerPrevWord
,
this
));
}
for
(
final
SuggestedWordInfo
suggestion
:
suggestions
)
{
final
String
suggestionStr
=
suggestion
.
mWord
.
toString
();
oldAddWord
(
suggestionStr
.
toCharArray
(),
null
,
0
,
suggestionStr
.
length
(),
suggestion
.
mScore
,
dicTypeId
,
Dictionary
.
BIGRAM
);
}
}
}
}
}
}
...
@@ -269,8 +290,16 @@ public class Suggest implements Dictionary.WordCallback {
...
@@ -269,8 +290,16 @@ public class Suggest implements Dictionary.WordCallback {
// Skip UserUnigramDictionary and WhitelistDictionary to lookup
// Skip UserUnigramDictionary and WhitelistDictionary to lookup
if
(
key
.
equals
(
DICT_KEY_USER_HISTORY_UNIGRAM
)
||
key
.
equals
(
DICT_KEY_WHITELIST
))
if
(
key
.
equals
(
DICT_KEY_USER_HISTORY_UNIGRAM
)
||
key
.
equals
(
DICT_KEY_WHITELIST
))
continue
;
continue
;
final
int
dicTypeId
=
sDictKeyToDictIndex
.
get
(
key
);
final
Dictionary
dictionary
=
mUnigramDictionaries
.
get
(
key
);
final
Dictionary
dictionary
=
mUnigramDictionaries
.
get
(
key
);
dictionary
.
getWords
(
wordComposerForLookup
,
prevWordForBigram
,
this
,
proximityInfo
);
final
ArrayList
<
SuggestedWordInfo
>
suggestions
=
dictionary
.
getWords
(
wordComposerForLookup
,
prevWordForBigram
,
this
,
proximityInfo
);
for
(
final
SuggestedWordInfo
suggestion
:
suggestions
)
{
final
String
suggestionStr
=
suggestion
.
mWord
.
toString
();
oldAddWord
(
suggestionStr
.
toCharArray
(),
null
,
0
,
suggestionStr
.
length
(),
suggestion
.
mScore
,
dicTypeId
,
Dictionary
.
UNIGRAM
);
}
}
}
}
}
...
@@ -376,10 +405,16 @@ public class Suggest implements Dictionary.WordCallback {
...
@@ -376,10 +405,16 @@ public class Suggest implements Dictionary.WordCallback {
return
suggestionsList
;
return
suggestionsList
;
}
}
// TODO:
Use codepoint instead of char
// TODO:
Remove this method
@Override
@Override
public
boolean
addWord
(
final
char
[]
word
,
int
[]
indices
,
final
int
offset
,
final
int
length
,
public
boolean
addWord
(
final
char
[]
word
,
int
[]
indices
,
final
int
offset
,
final
int
length
,
int
score
,
final
int
dicTypeId
,
final
int
dataType
)
{
int
score
,
final
int
dicTypeId
,
final
int
dataType
)
{
return
true
;
}
// TODO: Use codepoint instead of char
public
boolean
oldAddWord
(
final
char
[]
word
,
int
[]
indices
,
final
int
offset
,
final
int
length
,
int
score
,
final
int
dicTypeId
,
final
int
dataType
)
{
int
dataTypeForLog
=
dataType
;
int
dataTypeForLog
=
dataType
;
final
ArrayList
<
SuggestedWordInfo
>
suggestions
;
final
ArrayList
<
SuggestedWordInfo
>
suggestions
;
final
int
prefMaxSuggestions
;
final
int
prefMaxSuggestions
;
...
...
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