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
845c0619
Commit
845c0619
authored
10 years ago
by
Keisuke Kuroyanagi
Browse files
Options
Downloads
Patches
Plain Diff
Fix unit tests.
Change-Id: I7706db4c9279488552ea5fabc16dd1dd2bc7fa05
parent
261622aa
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
java/src/com/android/inputmethod/latin/PrevWordsInfo.java
+24
-3
24 additions, 3 deletions
java/src/com/android/inputmethod/latin/PrevWordsInfo.java
java/src/com/android/inputmethod/latin/utils/PrevWordsInfoUtils.java
+2
-2
2 additions, 2 deletions
...m/android/inputmethod/latin/utils/PrevWordsInfoUtils.java
with
26 additions
and
5 deletions
java/src/com/android/inputmethod/latin/PrevWordsInfo.java
+
24
−
3
View file @
845c0619
...
...
@@ -132,7 +132,8 @@ public class PrevWordsInfo {
@Override
public
int
hashCode
()
{
return
Arrays
.
hashCode
(
mPrevWordsInfo
);
// Just for having equals().
return
mPrevWordsInfo
[
0
].
hashCode
();
}
@Override
...
...
@@ -140,7 +141,23 @@ public class PrevWordsInfo {
if
(
this
==
o
)
return
true
;
if
(!(
o
instanceof
PrevWordsInfo
))
return
false
;
final
PrevWordsInfo
prevWordsInfo
=
(
PrevWordsInfo
)
o
;
return
Arrays
.
equals
(
mPrevWordsInfo
,
prevWordsInfo
.
mPrevWordsInfo
);
final
int
minLength
=
Math
.
min
(
mPrevWordsInfo
.
length
,
prevWordsInfo
.
mPrevWordsInfo
.
length
);
for
(
int
i
=
0
;
i
<
minLength
;
i
++)
{
if
(!
mPrevWordsInfo
[
i
].
equals
(
prevWordsInfo
.
mPrevWordsInfo
[
i
]))
{
return
false
;
}
}
final
WordInfo
[]
longerWordsInfo
=
(
mPrevWordsInfo
.
length
>
prevWordsInfo
.
mPrevWordsInfo
.
length
)
?
mPrevWordsInfo
:
prevWordsInfo
.
mPrevWordsInfo
;
for
(
int
i
=
minLength
;
i
<
longerWordsInfo
.
length
;
i
++)
{
if
(
longerWordsInfo
[
i
]
!=
null
&&
!
WordInfo
.
EMPTY_WORD_INFO
.
equals
(
longerWordsInfo
[
i
]))
{
return
false
;
}
}
return
true
;
}
@Override
...
...
@@ -151,7 +168,11 @@ public class PrevWordsInfo {
builder
.
append
(
"PrevWord["
);
builder
.
append
(
i
);
builder
.
append
(
"]: "
);
if
(
wordInfo
==
null
||
!
wordInfo
.
isValid
())
{
if
(
wordInfo
==
null
)
{
builder
.
append
(
"null. "
);
continue
;
}
if
(!
wordInfo
.
isValid
())
{
builder
.
append
(
"Empty. "
);
continue
;
}
...
...
This diff is collapsed.
Click to expand it.
java/src/com/android/inputmethod/latin/utils/PrevWordsInfoUtils.java
+
2
−
2
View file @
845c0619
...
...
@@ -16,6 +16,7 @@
package
com.android.inputmethod.latin.utils
;
import
java.util.Arrays
;
import
java.util.regex.Pattern
;
import
com.android.inputmethod.latin.Constants
;
...
...
@@ -56,6 +57,7 @@ public final class PrevWordsInfoUtils {
if
(
prev
==
null
)
return
PrevWordsInfo
.
EMPTY_PREV_WORDS_INFO
;
final
String
[]
w
=
SPACE_REGEX
.
split
(
prev
);
final
WordInfo
[]
prevWordsInfo
=
new
WordInfo
[
Constants
.
MAX_PREV_WORD_COUNT_FOR_N_GRAM
];
Arrays
.
fill
(
prevWordsInfo
,
WordInfo
.
EMPTY_WORD_INFO
);
for
(
int
i
=
0
;
i
<
prevWordsInfo
.
length
;
i
++)
{
final
int
focusedWordIndex
=
w
.
length
-
n
-
i
;
// Referring to the word after the focused word.
...
...
@@ -66,7 +68,6 @@ public final class PrevWordsInfoUtils {
if
(
spacingAndPunctuations
.
isWordConnector
(
firstChar
))
{
// The word following the focused word is starting with a word connector.
// TODO: Return meaningful context for this case.
prevWordsInfo
[
i
]
=
WordInfo
.
EMPTY_WORD_INFO
;
break
;
}
}
...
...
@@ -93,7 +94,6 @@ public final class PrevWordsInfoUtils {
// TODO: Return meaningful context for this case.
if
(
spacingAndPunctuations
.
isWordSeparator
(
lastChar
)
||
spacingAndPunctuations
.
isWordConnector
(
lastChar
))
{
prevWordsInfo
[
i
]
=
WordInfo
.
EMPTY_WORD_INFO
;
break
;
}
prevWordsInfo
[
i
]
=
new
WordInfo
(
focusedWord
);
...
...
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