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
722b0027
Commit
722b0027
authored
12 years ago
by
Jean Chalard
Committed by
Android (Google) Code Review
12 years ago
Browse files
Options
Downloads
Plain Diff
Merge "Pull up some identical code (A98)"
parents
8b166465
8eaeb60e
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/BinaryDictionary.java
+23
-39
23 additions, 39 deletions
java/src/com/android/inputmethod/latin/BinaryDictionary.java
with
23 additions
and
39 deletions
java/src/com/android/inputmethod/latin/BinaryDictionary.java
+
23
−
39
View file @
722b0027
...
...
@@ -114,31 +114,16 @@ public class BinaryDictionary extends Dictionary {
// TODO: toLowerCase in the native code
final
int
[]
prevWordCodePointArray
=
(
null
==
prevWord
)
?
null
:
StringUtils
.
toCodePointArray
(
prevWord
.
toString
());
final
int
count
;
if
(
composer
.
size
()
<=
1
)
{
return
TextUtils
.
isEmpty
(
prevWord
)
?
null
:
getBigramsInternal
(
composer
,
count
=
TextUtils
.
isEmpty
(
prevWord
)
?
-
1
:
getBigramsInternal
(
composer
,
prevWordCodePointArray
);
}
else
{
return
getWordsInternal
(
composer
,
prevWordCodePointArray
,
proximityInfo
);
count
=
getWordsInternal
(
composer
,
prevWordCodePointArray
,
proximityInfo
);
}
}
// TODO: move to native code
private
ArrayList
<
SuggestedWordInfo
>
getBigramsInternal
(
final
WordComposer
codes
,
final
int
[]
previousWord
)
{
int
codesSize
=
codes
.
size
();
if
(
codesSize
>
0
)
{
mInputCodes
[
0
]
=
codes
.
getCodeAt
(
0
);
}
int
count
=
getBigramsNative
(
mNativeDict
,
previousWord
,
previousWord
.
length
,
mInputCodes
,
codesSize
,
mOutputChars
,
mOutputScores
,
MAX_WORD_LENGTH
,
MAX_BIGRAMS
);
if
(
count
>
MAX_BIGRAMS
)
{
count
=
MAX_BIGRAMS
;
}
final
ArrayList
<
SuggestedWordInfo
>
suggestions
=
new
ArrayList
<
SuggestedWordInfo
>();
for
(
int
j
=
0
;
j
<
count
;
++
j
)
{
if
(
co
desS
ize
>
0
&&
mOutputScores
[
j
]
<
1
)
break
;
if
(
co
mposer
.
s
ize
()
>
0
&&
mOutputScores
[
j
]
<
1
)
break
;
final
int
start
=
j
*
MAX_WORD_LENGTH
;
int
len
=
0
;
while
(
len
<
MAX_WORD_LENGTH
&&
mOutputChars
[
start
+
len
]
!=
0
)
{
...
...
@@ -153,9 +138,25 @@ public class BinaryDictionary extends Dictionary {
return
suggestions
;
}
// TODO: move to native code
private
int
getBigramsInternal
(
final
WordComposer
codes
,
final
int
[]
previousWord
)
{
int
codesSize
=
codes
.
size
();
if
(
codesSize
>
0
)
{
mInputCodes
[
0
]
=
codes
.
getCodeAt
(
0
);
}
int
count
=
getBigramsNative
(
mNativeDict
,
previousWord
,
previousWord
.
length
,
mInputCodes
,
codesSize
,
mOutputChars
,
mOutputScores
,
MAX_WORD_LENGTH
,
MAX_BIGRAMS
);
if
(
count
>
MAX_BIGRAMS
)
{
count
=
MAX_BIGRAMS
;
}
return
count
;
}
// TODO: move to native code
// proximityInfo and/or prevWordForBigrams may not be null.
private
ArrayList
<
SuggestedWordInfo
>
getWordsInternal
(
final
WordComposer
codes
,
private
int
getWordsInternal
(
final
WordComposer
codes
,
final
int
[]
prevWord
,
final
ProximityInfo
proximityInfo
)
{
final
InputPointers
ips
=
codes
.
getInputPointers
();
final
boolean
isGesture
=
codes
.
isBatchMode
();
...
...
@@ -165,33 +166,16 @@ public class BinaryDictionary extends Dictionary {
}
else
{
codesSize
=
codes
.
size
();
// Won't deal with really long words.
if
(
codesSize
>
MAX_WORD_LENGTH
-
1
)
return
null
;
if
(
codesSize
>
MAX_WORD_LENGTH
-
1
)
return
-
1
;
for
(
int
i
=
0
;
i
<
codesSize
;
i
++)
{
mInputCodes
[
i
]
=
codes
.
getCodeAt
(
i
);
}
}
final
int
count
=
getSuggestionsNative
(
mNativeDict
,
proximityInfo
.
getNativeProximityInfo
(),
return
getSuggestionsNative
(
mNativeDict
,
proximityInfo
.
getNativeProximityInfo
(),
ips
.
getXCoordinates
(),
ips
.
getYCoordinates
(),
ips
.
getTimes
(),
ips
.
getPointerIds
(),
mInputCodes
,
codesSize
,
0
/* unused */
,
isGesture
,
prevWord
,
mUseFullEditDistance
,
mOutputChars
,
mOutputScores
,
mSpaceIndices
);
final
ArrayList
<
SuggestedWordInfo
>
suggestions
=
new
ArrayList
<
SuggestedWordInfo
>();
for
(
int
j
=
0
;
j
<
count
;
++
j
)
{
if
(
mOutputScores
[
j
]
<
1
)
break
;
final
int
start
=
j
*
MAX_WORD_LENGTH
;
int
len
=
0
;
while
(
len
<
MAX_WORD_LENGTH
&&
mOutputChars
[
start
+
len
]
!=
0
)
{
++
len
;
}
if
(
len
>
0
)
{
// TODO: actually get the kind from native code
suggestions
.
add
(
new
SuggestedWordInfo
(
new
String
(
mOutputChars
,
start
,
len
),
mOutputScores
[
j
],
SuggestedWordInfo
.
KIND_CORRECTION
,
mDictType
));
}
}
return
suggestions
;
}
/* package for test */
boolean
isValidDictionary
()
{
...
...
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