aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorJean Chalard <jchalard@google.com>2012-10-31 15:35:20 +0900
committerJean Chalard <jchalard@google.com>2012-10-31 16:35:22 +0900
commit51a0ef8c59ea590b6e5e80a82fc75bf244084270 (patch)
treefb62328bb44263922cf698e0d44515446d5c23e0 /tools
parenta8058d169dad450eca428ca76c5a0f44e45f41a7 (diff)
downloadlatinime-51a0ef8c59ea590b6e5e80a82fc75bf244084270.tar.gz
latinime-51a0ef8c59ea590b6e5e80a82fc75bf244084270.tar.xz
latinime-51a0ef8c59ea590b6e5e80a82fc75bf244084270.zip
Add a plumbing option to dicttool info.
Also align the `porcelain' option to the diff command that was used mistakenly. Bug: 7388665 Change-Id: Ic0e1b98c62ce37b2e909384a0370af4458563703
Diffstat (limited to 'tools')
-rw-r--r--tools/dicttool/src/com/android/inputmethod/latin/dicttool/Diff.java10
-rw-r--r--tools/dicttool/src/com/android/inputmethod/latin/dicttool/Info.java22
2 files changed, 22 insertions, 10 deletions
diff --git a/tools/dicttool/src/com/android/inputmethod/latin/dicttool/Diff.java b/tools/dicttool/src/com/android/inputmethod/latin/dicttool/Diff.java
index 9548f2509..855c026b9 100644
--- a/tools/dicttool/src/com/android/inputmethod/latin/dicttool/Diff.java
+++ b/tools/dicttool/src/com/android/inputmethod/latin/dicttool/Diff.java
@@ -34,7 +34,7 @@ public class Diff extends Dicttool.Command {
@Override
public String getHelp() {
return COMMAND + " [-p] <dict> <dict> : shows differences between two dictionaries.\n"
- + " If -p (porcelain) option is given, produce output suitable for a script";
+ + " If -p (plumbing) option is given, produce output suitable for a script";
}
@Override
@@ -42,15 +42,15 @@ public class Diff extends Dicttool.Command {
if (mArgs.length < 2) {
throw new RuntimeException("Not enough arguments for command " + COMMAND);
}
- final boolean porcelain;
+ final boolean plumbing;
if ("-p".equals(mArgs[0])) {
- porcelain = true;
+ plumbing = true;
mArgs = Arrays.copyOfRange(mArgs, 1, mArgs.length);
if (mArgs.length != 2) { // There should be only 2 arguments left
throw new RuntimeException("Wrong number of arguments for command " + COMMAND);
}
} else {
- porcelain = false;
+ plumbing = false;
}
final FusionDictionary dict0 =
BinaryDictOffdeviceUtils.getDictionary(mArgs[0], false /* report */);
@@ -58,7 +58,7 @@ public class Diff extends Dicttool.Command {
final FusionDictionary dict1 =
BinaryDictOffdeviceUtils.getDictionary(mArgs[1], false /* report */);
if (null == dict1) throw new RuntimeException("Can't read dictionary " + mArgs[1]);
- if (!porcelain) {
+ if (!plumbing) {
System.out.println("Header :");
diffHeaders(dict0, dict1);
if (languageDiffers(dict0, dict1)) {
diff --git a/tools/dicttool/src/com/android/inputmethod/latin/dicttool/Info.java b/tools/dicttool/src/com/android/inputmethod/latin/dicttool/Info.java
index d91a409d3..f2894544f 100644
--- a/tools/dicttool/src/com/android/inputmethod/latin/dicttool/Info.java
+++ b/tools/dicttool/src/com/android/inputmethod/latin/dicttool/Info.java
@@ -22,6 +22,7 @@ import com.android.inputmethod.latin.makedict.FusionDictionary.CharGroup;
import com.android.inputmethod.latin.makedict.FusionDictionary.WeightedString;
import com.android.inputmethod.latin.makedict.Word;
+import java.util.Arrays;
import java.util.ArrayList;
public class Info extends Dicttool.Command {
@@ -35,9 +36,9 @@ public class Info extends Dicttool.Command {
return COMMAND + " <filename>: prints various information about a dictionary file";
}
- private static void showInfo(final FusionDictionary dict) {
+ private static void showInfo(final FusionDictionary dict, final boolean plumbing) {
System.out.println("Header attributes :");
- System.out.print(dict.mOptions.toString(2));
+ System.out.print(dict.mOptions.toString(2, plumbing));
int wordCount = 0;
int bigramCount = 0;
int shortcutCount = 0;
@@ -62,7 +63,8 @@ public class Info extends Dicttool.Command {
+ " whitelist entries)");
}
- private static void showWordInfo(final FusionDictionary dict, final String word) {
+ private static void showWordInfo(final FusionDictionary dict, final String word,
+ final boolean plumbing) {
final CharGroup group = FusionDictionary.findWordInTree(dict.mRoot, word);
if (null == group) {
System.out.println(word + " is not in the dictionary");
@@ -101,15 +103,25 @@ public class Info extends Dicttool.Command {
if (mArgs.length < 1) {
throw new RuntimeException("Not enough arguments for command " + COMMAND);
}
+ final boolean plumbing;
+ if ("-p".equals(mArgs[0])) {
+ plumbing = true;
+ mArgs = Arrays.copyOfRange(mArgs, 1, mArgs.length);
+ if (mArgs.length != 1) { // There should be only 1 argument left
+ throw new RuntimeException("Wrong number of arguments for command " + COMMAND);
+ }
+ } else {
+ plumbing = false;
+ }
final String filename = mArgs[0];
final boolean hasWordArguments = (1 == mArgs.length);
final FusionDictionary dict = BinaryDictOffdeviceUtils.getDictionary(filename,
hasWordArguments /* report */);
if (hasWordArguments) {
- showInfo(dict);
+ showInfo(dict, plumbing);
} else {
for (int i = 1; i < mArgs.length; ++i) {
- showWordInfo(dict, mArgs[i]);
+ showWordInfo(dict, mArgs[i], plumbing);
}
}
}