MultiWordPhrasesPipeline { public static void main(String[] args) throws UIMAException, IOException { String featurePath = Token.class.getCanonicalName(); { CollectionReaderDescription reader = createReaderDescription(TextReader.class, TextReader.PARAM_SOURCE_LOCATION, TEXT_PATH, TextReader.PARAM_LANGUAGE, "en", TextReader.PARAM_LOG_FREQ, 10); AnalysisEngineDescription segmenter = createEngineDescription(OpenNlpSegmenter.class); AnalysisEngineDescription freqCounter = createEngineDescription(FrequencyWriter.class, FrequencyWriter.PARAM_TARGET_LOCATION, COUNTS1_PATH, FrequencyWriter.PARAM_SORT_BY_COUNT, true, FrequencyWriter.PARAM_MIN_COUNT, MIN_COUNT, FrequencyWriter.PARAM_FEATURE_PATH, featurePath, FrequencyWriter.PARAM_LOWERCASE, LOWERCASE); AnalysisEngineDescription writer = createEngineDescription(BinaryCasWriter.class, BinaryCasWriter.PARAM_TARGET_LOCATION, BINCAS_PATH, BinaryCasWriter.PARAM_OVERWRITE, true); runPipeline(reader, segmenter, freqCounter, writer); } float threshold = (float) 100; { CollectionReaderDescription reader = createReaderDescription(BinaryCasReader.class, BinaryCasReader.PARAM_SOURCE_LOCATION, BINCAS_PATH + " AnalysisEngineDescription writer = createEngineDescription(BinaryCasWriter.class, BinaryCasWriter.PARAM_TARGET_LOCATION, BINCAS_PATH, BinaryCasWriter.PARAM_OVERWRITE, true); runPipeline(reader, phraseAnnotator, writer); } featurePath = LexicalPhrase.class.getCanonicalName(); { CollectionReaderDescription reader = createReaderDescription(BinaryCasReader.class, BinaryCasReader.PARAM_SOURCE_LOCATION, BINCAS_PATH + " threshold = (float) 70; { CollectionReaderDescription reader = createReaderDescription(BinaryCasReader.class, BinaryCasReader.PARAM_SOURCE_LOCATION, BINCAS_PATH + " for (JCas jCas : iteratePipeline(reader, phraseAnnotator)) { select(jCas, LexicalPhrase.class).stream() .map(Annotation::getCoveredText) .filter(phrase -> phrase.contains(" ")) .forEach(System.out::println); } } }  static void main(String[] args);  }
@Test public void testMain() throws Exception { File countsFile1 = new File(MultiWordPhrasesPipeline.COUNTS1_PATH); int expectedLines1 = 14612; String expectedFirstLine1 = ",\t3306"; File countsFile2 = new File(MultiWordPhrasesPipeline.COUNTS2_PATH); int expectedLines2 = 14524; String expectedFirstLine2 = ",\t3306"; MultiWordPhrasesPipeline.main(new String[0]); assertTrue(countsFile1.exists()); assertTrue(countsFile2.exists()); List<String> lines1 = Files.readAllLines(countsFile1.toPath()); assertEquals(expectedFirstLine1, lines1.get(0)); assertEquals(expectedLines1, lines1.size()); List<String> lines2 = Files.readAllLines(countsFile2.toPath()); assertEquals(expectedFirstLine2, lines2.get(0)); assertEquals(expectedLines2, lines2.size()); }