public static void main(String[] args) throws Exception { Path tableFileDir = Paths.get(args[0]); Path commonTokensDir = Paths.get(args[1]); for (File f : tableFileDir.toFile().listFiles()) { System.err.println(f); if (!f.getName().contains("bn_table")) { //continue; } Path commonTokensFile = commonTokensDir.resolve( f.getName().replaceAll("_table(\\.txt)?(\\.gz)?$", "")); TopCommonTokenCounter.main( new String[]{ ProcessUtils.escapeCommandLine(f.getAbsolutePath()), ProcessUtils.escapeCommandLine(commonTokensFile.toAbsolutePath().toString()) } ); } } }
private static String extractJavaPath(String[] args) { String javaHome = null; for (int i = 0; i < args.length; i++) { if (args[i].equals("-javaHome")) { if (i == args.length-1) { throw new IllegalArgumentException("must specify a value for -javaHome"); } javaHome = args[i+1]; break; } } if (javaHome == null) { javaHome = System.getenv("JAVA_HOME"); } if (javaHome != null) { Path jPath = Paths.get(javaHome).resolve("bin").resolve("java"); return ProcessUtils.escapeCommandLine( jPath.toAbsolutePath().toString()); } return "java"; } private static List<String> extractJVMArgs(String[] args) {
childArgs.add(ProcessUtils.escapeCommandLine(childStatusFile.toAbsolutePath().toString()));
dirString += "/"; dirString = ProcessUtils.escapeCommandLine(dirString); command.add(dirString); command.add("org.apache.tika.fork.ForkServer");
private String[] commandLine(String testConfig, String loggerProps, String[] args) { List<String> commandLine = new ArrayList<>(); commandLine.add("java"); commandLine.add("-Dlog4j.configuration=file:"+ this.getClass().getResource(loggerProps).getFile()); commandLine.add("-Xmx128m"); commandLine.add("-cp"); String cp = System.getProperty("java.class.path"); cp = ProcessUtils.escapeCommandLine(cp); commandLine.add(cp); commandLine.add("org.apache.tika.batch.fs.FSBatchProcessCLI"); String configFile = null; try { configFile = Paths.get(this.getClass().getResource(testConfig).toURI()).toAbsolutePath().toString(); } catch (URISyntaxException e) { e.printStackTrace(); } commandLine.add("-bc"); commandLine.add(configFile); for (String s : args) { commandLine.add(s); } return commandLine.toArray(new String[commandLine.size()]); }
@BeforeClass public static void setUp() throws Exception { String[] docs = new String[] { "the quick brown fox", "jumped over the brown lazy", "brown lazy fox", "\u666e\u6797\u65af\u987f\u5927\u5b66", "\u666e\u6797\u65af\u987f\u5927\u5b66" }; WORKING_DIR = Files.createTempDirectory("tika-eval-common-tokens"); try (BufferedWriter writer = Files.newBufferedWriter(WORKING_DIR.resolve(INPUT_FILE), StandardCharsets.UTF_8)) { //do this 10 times to bump the numbers above the TopCommonTokenCounter's MIN_DOC_FREQ for (int i = 0; i < 10; i++) { for (String d : docs) { writer.write(d); writer.newLine(); } } writer.flush(); } TopCommonTokenCounter.main( new String[]{ ProcessUtils.escapeCommandLine( WORKING_DIR.resolve(INPUT_FILE).toAbsolutePath().toString()), ProcessUtils.escapeCommandLine( WORKING_DIR.resolve(COMMON_TOKENS_FILE).toAbsolutePath().toString()) }); }
public BatchProcessDriverCLI getNewDriver(String testConfig, String[] args) throws Exception { List<String> commandLine = new ArrayList<>(); commandLine.add("java"); commandLine.add("-Xmx128m"); commandLine.add("-cp"); String cp = System.getProperty("java.class.path"); //need to test for " " on *nix, can't just add double quotes //across platforms. cp = ProcessUtils.escapeCommandLine(cp); commandLine.add(cp); commandLine.add("org.apache.tika.batch.fs.FSBatchProcessCLI"); String configFile = Paths.get( this.getClass().getResource(testConfig).toURI()).toAbsolutePath().toString(); commandLine.add("-bc"); commandLine.add(configFile); for (String s : args) { commandLine.add(s); } BatchProcessDriverCLI driver = new BatchProcessDriverCLI( commandLine.toArray(new String[commandLine.size()])); driver.setRedirectChildProcessToStdOut(false); return driver; }
dirString += "/"; dirString = ProcessUtils.escapeCommandLine(dirString); command.add(dirString); command.add("org.apache.tika.fork.ForkServer");