Cosmetic code changes
Change-Id: I0e4218de3657890b43afec95596b9ddcdb5fef60
diff --git a/src/main/java/org/ids_mannheim/TotalNGrams.java b/src/main/java/org/ids_mannheim/TotalNGrams.java
index 2057676..50b7028 100644
--- a/src/main/java/org/ids_mannheim/TotalNGrams.java
+++ b/src/main/java/org/ids_mannheim/TotalNGrams.java
@@ -36,65 +36,68 @@
@CommandLine.Parameters(arity = "1..*", description = "input files")
private ArrayList<String> inputFiles = new ArrayList<>();
- @CommandLine.Option(names = {"-L",
- "--log-file"}, defaultValue = DEFAULT_LOGFILE, description = "log file name (default: ${DEFAULT-VALUE})")
+ @CommandLine.Option(names = { "-L",
+ "--log-file" }, defaultValue = DEFAULT_LOGFILE, description = "log file name (default: ${DEFAULT-VALUE})")
String logFileName;
@SuppressWarnings("CanBeFinal")
- @CommandLine.Option(names = {"-o",
- "--output-file"}, description = "Output file (default: ${DEFAULT-VALUE})")
+ @CommandLine.Option(names = { "-o",
+ "--output-file" }, description = "Output file (default: ${DEFAULT-VALUE})")
String output_fillename = "-";
@SuppressWarnings("CanBeFinal")
- @CommandLine.Option(names = {"-d", "--downcase"}, description = "Convert all token characters into lower case (default: ${DEFAULT-VALUE})")
+ @CommandLine.Option(names = { "-d",
+ "--downcase" }, description = "Convert all token characters into lower case (default: ${DEFAULT-VALUE})")
boolean downcase_tokens = false;
@SuppressWarnings("CanBeFinal")
- @CommandLine.Option(names = {"--force"}, description = "Force overwrite (default: ${DEFAULT-VALUE})")
+ @CommandLine.Option(names = { "--force" }, description = "Force overwrite (default: ${DEFAULT-VALUE})")
boolean force_overwrite = false;
@SuppressWarnings("CanBeFinal")
- @CommandLine.Option(names = {"-l", "--with-lemma-pos"}, description = "Use also lemma and part-of-speech annotations (default: ${DEFAULT-VALUE}")
+ @CommandLine.Option(names = { "-l",
+ "--with-lemma-pos" }, description = "Use also lemma and part-of-speech annotations (default: ${DEFAULT-VALUE}")
boolean with_lemma_and_pos = false;
@SuppressWarnings("CanBeFinal")
- @CommandLine.Option(names = {"-P",
- "--max-procs"}, description = "Run up to max-procs processes at a time (default: ${DEFAULT-VALUE})")
+ @CommandLine.Option(names = { "-P",
+ "--max-procs" }, description = "Run up to max-procs processes at a time (default: ${DEFAULT-VALUE})")
int max_threads = MAX_THREADS;
@SuppressWarnings("CanBeFinal")
- @CommandLine.Option(names = {"-p",
- "--worker-pool"}, description = "Run preprocessing on extern hosts, e.g. '10*local,5*host1,3*smith@host2' (default: ${DEFAULT-VALUE})")
+ @CommandLine.Option(names = { "-p",
+ "--worker-pool" }, description = "Run preprocessing on extern hosts, e.g. '10*local,5*host1,3*smith@host2' (default: ${DEFAULT-VALUE})")
String worker_pool_specification = "";
@SuppressWarnings("CanBeFinal")
- @CommandLine.Option(names = {"-n",
- "--ngram-size"}, description = "n-gram size (default: ${DEFAULT-VALUE})")
+ @CommandLine.Option(names = { "-n",
+ "--ngram-size" }, description = "n-gram size (default: ${DEFAULT-VALUE})")
int ngram_size = 1;
@SuppressWarnings("CanBeFinal")
- @CommandLine.Option(names = {"-F",
- "--folds"}, description = "number of random folds (default: ${DEFAULT-VALUE})")
+ @CommandLine.Option(names = { "-F",
+ "--folds" }, description = "number of random folds (default: ${DEFAULT-VALUE})")
int FOLDS = 1;
@SuppressWarnings("CanBeFinal")
- @CommandLine.Option(names = {"-f",
- "--fold"}, description = "current fold (default: ${DEFAULT-VALUE})")
+ @CommandLine.Option(names = { "-f",
+ "--fold" }, description = "current fold (default: ${DEFAULT-VALUE})")
int fold = 1;
@SuppressWarnings("CanBeFinal")
- @CommandLine.Option(names = {"-S",
- "--sort"}, description = "Toggle output sorting (default: ${DEFAULT-VALUE})")
+ @CommandLine.Option(names = { "-S",
+ "--sort" }, description = "Toggle output sorting (default: ${DEFAULT-VALUE})")
boolean sort = true;
@SuppressWarnings("CanBeFinal")
- @CommandLine.Option(names = {"-N",
- "--numeric-secondary-sort"}, description = "Sort entries with same frequency numerically (default: ${DEFAULT-VALUE})")
+ @CommandLine.Option(names = { "-N",
+ "--numeric-secondary-sort" }, description = "Sort entries with same frequency numerically (default: ${DEFAULT-VALUE})")
boolean numericSecondarySort = false;
@SuppressWarnings("CanBeFinal")
@CommandLine.Option(names = {
- "--pad"}, description = "Add padding " + PaddedSlidingWindowQueue.TEXT_START_SYMBOL + " and " + PaddedSlidingWindowQueue.TEXT_END_SYMBOL + " symbols at text edges (default: ${DEFAULT-VALUE})")
+ "--pad" }, description = "Add padding " + PaddedSlidingWindowQueue.TEXT_START_SYMBOL + " and "
+ + PaddedSlidingWindowQueue.TEXT_END_SYMBOL + " symbols at text edges (default: ${DEFAULT-VALUE})")
boolean addPadding = false;
private Progressbar etaPrinter;
@@ -115,7 +118,8 @@
System.setProperty("java.util.logging.SimpleFormatter.format",
"[%1$tF %1$tT] [%4$-7s] %5$s %n");
fileHandler.setFormatter(new SimpleFormatter());
- //java.util.logging.SimpleFormatter.format="%1$tb %1$td, %1$tY %1$tl:%1$tM:%1$tS %1$Tp %2$s%n%4$s: %5$s%n";
+ // java.util.logging.SimpleFormatter.format="%1$tb %1$td, %1$tY
+ // %1$tl:%1$tM:%1$tS %1$Tp %2$s%n%4$s: %5$s%n";
java.util.Locale.setDefault(Locale.Category.FORMAT, Locale.ROOT);
logger.addHandler(fileHandler);
ConsoleHandler consoleHandler = new ConsoleHandler();
@@ -136,9 +140,11 @@
} else {
File f = Utils.createFile(output_fillename, force_overwrite);
if (output_fillename.endsWith(".gz")) {
- output_stream = new PrintStream(new ParallelGZIPOutputStream((new BufferedOutputStream(new FileOutputStream(f)))));
+ output_stream = new PrintStream(
+ new ParallelGZIPOutputStream((new BufferedOutputStream(new FileOutputStream(f)))));
} else if (output_fillename.endsWith(".xz")) {
- output_stream = new PrintStream(new XZCompressorOutputStream((new BufferedOutputStream(new FileOutputStream(f)))));
+ output_stream = new PrintStream(
+ new XZCompressorOutputStream((new BufferedOutputStream(new FileOutputStream(f)))));
} else {
output_stream = new PrintStream(new BufferedOutputStream(new FileOutputStream(f)));
}
@@ -150,14 +156,14 @@
long totalFilesSizes = inputFiles.parallelStream().mapToLong(fname -> {
long l = new File(fname).length();
if (l == 0) {
- logger.severe("File "+fname+" does not exist or is empty.");
+ logger.severe("File " + fname + " does not exist or is empty.");
System.exit(-1);
}
return l;
}).sum();
- inputFiles = (ArrayList<String>) inputFiles.parallelStream().sorted((a, b) ->
- Long.compareUnsigned(new File(b).length(), new File(a).length())
- ).collect(Collectors.toList());
+ inputFiles = (ArrayList<String>) inputFiles.parallelStream()
+ .sorted((a, b) -> Long.compareUnsigned(new File(b).length(), new File(a).length()))
+ .collect(Collectors.toList());
etaPrinter = new Progressbar(totalFilesSizes);
BlockingQueue<Integer> queue = new LinkedBlockingQueue<>(inputFiles.size());
@@ -169,7 +175,8 @@
int threads = Math.min(max_threads, inputFiles.size());
logger.info("Processing fold " + fold + "/" + FOLDS);
logger.info("Using " + threads + " threads");
- IntStream.range(0, threads).forEach(unused -> es.execute(new Worker(queue, inputFiles, ngram_size, fold, FOLDS, map, with_lemma_and_pos, downcase_tokens, workerNodePool, etaPrinter, logger, addPadding)));
+ IntStream.range(0, threads).forEach(unused -> es.execute(new Worker(queue, inputFiles, ngram_size, fold, FOLDS,
+ map, with_lemma_and_pos, downcase_tokens, workerNodePool, etaPrinter, logger, addPadding)));
queue.addAll(IntStream.range(0, inputFiles.size()).boxed().collect(Collectors.toList()));
IntStream.range(0, threads).forEach(unused -> {
try {
@@ -210,7 +217,8 @@
return a.getKey().compareTo(b.getKey());
}
})
- .forEachOrdered(entry -> output_stream.println(entry.getKey() + "\t" + Integer.toUnsignedString(entry.getValue().get())));
+ .forEachOrdered(entry -> output_stream
+ .println(entry.getKey() + "\t" + Integer.toUnsignedString(entry.getValue().get())));
}
logger.info("Finished.");
output_stream.close();