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
4466464c
Commit
4466464c
authored
10 years ago
by
Keisuke Kuroyanagi
Browse files
Options
Downloads
Patches
Plain Diff
Use PrevWordsInfo.getPrevWordCount() in Java side.
Bug: 14425059 Change-Id: Ie6295ff657c483876af403f2d474b7d857e5e3d6
parent
b349b574
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/BinaryDictionary.java
+6
-9
6 additions, 9 deletions
java/src/com/android/inputmethod/latin/BinaryDictionary.java
java/src/com/android/inputmethod/latin/PrevWordsInfo.java
+12
-11
12 additions, 11 deletions
java/src/com/android/inputmethod/latin/PrevWordsInfo.java
with
18 additions
and
20 deletions
java/src/com/android/inputmethod/latin/BinaryDictionary.java
+
6
−
9
View file @
4466464c
...
...
@@ -358,9 +358,8 @@ public final class BinaryDictionary extends Dictionary {
if
(!
prevWordsInfo
.
isValid
()
||
TextUtils
.
isEmpty
(
word
))
{
return
NOT_A_PROBABILITY
;
}
final
int
[][]
prevWordCodePointArrays
=
new
int
[
Constants
.
MAX_PREV_WORD_COUNT_FOR_N_GRAM
][];
final
boolean
[]
isBeginningOfSentenceArray
=
new
boolean
[
Constants
.
MAX_PREV_WORD_COUNT_FOR_N_GRAM
];
final
int
[][]
prevWordCodePointArrays
=
new
int
[
prevWordsInfo
.
getPrevWordCount
()][];
final
boolean
[]
isBeginningOfSentenceArray
=
new
boolean
[
prevWordsInfo
.
getPrevWordCount
()];
prevWordsInfo
.
outputToArray
(
prevWordCodePointArrays
,
isBeginningOfSentenceArray
);
final
int
[]
wordCodePoints
=
StringUtils
.
toCodePointArray
(
word
);
return
getNgramProbabilityNative
(
mNativeDict
,
prevWordCodePointArrays
,
...
...
@@ -455,9 +454,8 @@ public final class BinaryDictionary extends Dictionary {
if
(!
prevWordsInfo
.
isValid
()
||
TextUtils
.
isEmpty
(
word
))
{
return
false
;
}
final
int
[][]
prevWordCodePointArrays
=
new
int
[
Constants
.
MAX_PREV_WORD_COUNT_FOR_N_GRAM
][];
final
boolean
[]
isBeginningOfSentenceArray
=
new
boolean
[
Constants
.
MAX_PREV_WORD_COUNT_FOR_N_GRAM
];
final
int
[][]
prevWordCodePointArrays
=
new
int
[
prevWordsInfo
.
getPrevWordCount
()][];
final
boolean
[]
isBeginningOfSentenceArray
=
new
boolean
[
prevWordsInfo
.
getPrevWordCount
()];
prevWordsInfo
.
outputToArray
(
prevWordCodePointArrays
,
isBeginningOfSentenceArray
);
final
int
[]
wordCodePoints
=
StringUtils
.
toCodePointArray
(
word
);
if
(!
addNgramEntryNative
(
mNativeDict
,
prevWordCodePointArrays
,
...
...
@@ -473,9 +471,8 @@ public final class BinaryDictionary extends Dictionary {
if
(!
prevWordsInfo
.
isValid
()
||
TextUtils
.
isEmpty
(
word
))
{
return
false
;
}
final
int
[][]
prevWordCodePointArrays
=
new
int
[
Constants
.
MAX_PREV_WORD_COUNT_FOR_N_GRAM
][];
final
boolean
[]
isBeginningOfSentenceArray
=
new
boolean
[
Constants
.
MAX_PREV_WORD_COUNT_FOR_N_GRAM
];
final
int
[][]
prevWordCodePointArrays
=
new
int
[
prevWordsInfo
.
getPrevWordCount
()][];
final
boolean
[]
isBeginningOfSentenceArray
=
new
boolean
[
prevWordsInfo
.
getPrevWordCount
()];
prevWordsInfo
.
outputToArray
(
prevWordCodePointArrays
,
isBeginningOfSentenceArray
);
final
int
[]
wordCodePoints
=
StringUtils
.
toCodePointArray
(
word
);
if
(!
removeNgramEntryNative
(
mNativeDict
,
prevWordCodePointArrays
,
...
...
This diff is collapsed.
Click to expand it.
java/src/com/android/inputmethod/latin/PrevWordsInfo.java
+
12
−
11
View file @
4466464c
...
...
@@ -86,33 +86,30 @@ public class PrevWordsInfo {
// For simplicity of implementation, elements may also be EMPTY_WORD_INFO transiently after the
// WordComposer was reset and before starting a new composing word, but we should never be
// calling getSuggetions* in this situation.
public
WordInfo
[]
mPrevWordsInfo
=
new
WordInfo
[
Constants
.
MAX_PREV_WORD_COUNT_FOR_N_GRAM
]
;
public
final
WordInfo
[]
mPrevWordsInfo
;
// Construct from the previous word information.
public
PrevWordsInfo
(
final
WordInfo
prevWordInfo
)
{
mPrevWordsInfo
[
0
]
=
prevWordInfo
;
mPrevWordsInfo
=
new
WordInfo
[]
{
prevWordInfo
}
;
}
// Construct from WordInfo array. n-th element represents (n+1)-th previous word's information.
public
PrevWordsInfo
(
final
WordInfo
[]
prevWordsInfo
)
{
for
(
int
i
=
0
;
i
<
Constants
.
MAX_PREV_WORD_COUNT_FOR_N_GRAM
;
i
++)
{
mPrevWordsInfo
[
i
]
=
(
prevWordsInfo
.
length
>
i
)
?
prevWordsInfo
[
i
]
:
WordInfo
.
EMPTY_WORD_INFO
;
}
mPrevWordsInfo
=
prevWordsInfo
;
}
// Create next prevWordsInfo using current prevWordsInfo.
public
PrevWordsInfo
getNextPrevWordsInfo
(
final
WordInfo
wordInfo
)
{
final
WordInfo
[]
prevWordsInfo
=
new
WordInfo
[
Constants
.
MAX_PREV_WORD_COUNT_FOR_N_GRAM
];
final
int
nextPrevWordCount
=
Math
.
min
(
Constants
.
MAX_PREV_WORD_COUNT_FOR_N_GRAM
,
mPrevWordsInfo
.
length
+
1
);
final
WordInfo
[]
prevWordsInfo
=
new
WordInfo
[
nextPrevWordCount
];
prevWordsInfo
[
0
]
=
wordInfo
;
for
(
int
i
=
1
;
i
<
prevWordsInfo
.
length
;
i
++)
{
prevWordsInfo
[
i
]
=
mPrevWordsInfo
[
i
-
1
];
}
System
.
arraycopy
(
mPrevWordsInfo
,
0
,
prevWordsInfo
,
1
,
prevWordsInfo
.
length
-
1
);
return
new
PrevWordsInfo
(
prevWordsInfo
);
}
public
boolean
isValid
()
{
return
mPrevWordsInfo
[
0
].
isValid
();
return
mPrevWordsInfo
.
length
>
0
&&
mPrevWordsInfo
[
0
].
isValid
();
}
public
void
outputToArray
(
final
int
[][]
codePointArrays
,
...
...
@@ -129,6 +126,10 @@ public class PrevWordsInfo {
}
}
public
int
getPrevWordCount
()
{
return
mPrevWordsInfo
.
length
;
}
@Override
public
int
hashCode
()
{
return
Arrays
.
hashCode
(
mPrevWordsInfo
);
...
...
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