aboutsummaryrefslogtreecommitdiffstats
path: root/java/src
diff options
context:
space:
mode:
authorKurt Partridge <kep@google.com>2012-08-09 12:24:47 -0700
committerKurt Partridge <kep@google.com>2012-11-29 20:32:12 -0800
commit6a0720478d2e44fc876b3446d7348083f154aeb8 (patch)
tree242606abecf6831b17a076e82559b2bb4838d90f /java/src
parent98967539fda520e6003baf80feba4cc1f1364d6e (diff)
downloadlatinime-6a0720478d2e44fc876b3446d7348083f154aeb8.tar.gz
latinime-6a0720478d2e44fc876b3446d7348083f154aeb8.tar.xz
latinime-6a0720478d2e44fc876b3446d7348083f154aeb8.zip
ResearchLogger switch word segmentation
Previously, a logunit was considered a word only if it was all letters. This is important for tracking bigrams correctly. Now, a logunit must have only at least one letter. The dictionary check is still performed, and punctuation, etc. still comes in as separate LogUnits. But a word can contain a space, which helps set up for logging words where spaces are inserted automatically, and other situations in which text is committed with an additional space tacked onto the end. Change-Id: Ia74094a99058890d20a9cdadf2d0989841a79a41
Diffstat (limited to 'java/src')
-rw-r--r--java/src/com/android/inputmethod/research/ResearchLogger.java10
1 files changed, 5 insertions, 5 deletions
diff --git a/java/src/com/android/inputmethod/research/ResearchLogger.java b/java/src/com/android/inputmethod/research/ResearchLogger.java
index bae34340f..ea3f6fd7a 100644
--- a/java/src/com/android/inputmethod/research/ResearchLogger.java
+++ b/java/src/com/android/inputmethod/research/ResearchLogger.java
@@ -731,20 +731,20 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang
researchLog.publish(closingLogUnit, true /* isIncludingPrivateData */);
}
- private boolean hasOnlyLetters(final String word) {
+ private boolean hasLetters(final String word) {
final int length = word.length();
for (int i = 0; i < length; i = word.offsetByCodePoints(i, 1)) {
final int codePoint = word.codePointAt(i);
- if (!Character.isLetter(codePoint)) {
- return false;
+ if (Character.isLetter(codePoint)) {
+ return true;
}
}
- return true;
+ return false;
}
private void onWordComplete(final String word) {
Log.d(TAG, "onWordComplete: " + word);
- if (word != null && word.length() > 0 && hasOnlyLetters(word)) {
+ if (word != null && word.length() > 0 && hasLetters(word)) {
mCurrentLogUnit.setWord(word);
mStatistics.recordWordEntered();
}