@Test public void testCollectionProcessComplete() throws UIMAException, IOException, InterruptedException { final CollectionReader reader = createReader(createReaderDescription(TextReader.class, TextReader.PARAM_SOURCE_LOCATION, "src/test/resources/keyphrase/evaluator", TextReader.PARAM_PATTERNS, TextReader.INCLUDE_PREFIX + "*.txt")); final AnalysisEngine analysisEngine = createEngine(createEngineDescription( createEngineDescription(BreakIteratorSegmenter.class), createEngineDescription(KeyphraseDatasetStatistics.class))); final StringBuilder actual = new StringBuilder(); final StringBuilderOutputStream fout = new StringBuilderOutputStream(actual); final MultiOutputStream multiOut = new MultiOutputStream(System.out, fout); final PrintStream stdout = new PrintStream(multiOut); System.setOut(stdout); SimplePipeline.runPipeline(reader, analysisEngine); final String[] lines = actual.toString().split(LINE_SEPARATOR); actual.delete(0, actual.length()); for (int i = 1; i < lines.length; ++i) { actual.append(lines[i]); } final String expected = "# Documents: 1Tokens / Document: " + "5.0(+/- 0.0) Median: 5.0)# Keyphrases: 1Keyphrases / " + "Document: 1.0(+/- 0.0)Characters / Keyphrase: 4.0(+/- 0.0)Tokens / " + "Keyphrase: 1.0(+/- 0.0)Upper bound (P@10): 0.09999999999999998" + "Upper bound (R@10): 1.0Pearson Correlation between document size and " + "the number of gold keyphrases:1:1"; Assert.assertThat(actual.toString(), CoreMatchers.is(expected)); }
@Override public void collectionProcessComplete() throws AnalysisEngineProcessException { final double averageNrofTokens = (double) sumNrofTokens / nrofDocuments; final double stdDevAvgNrTokens = stdDev(tokensPerDocument); final double avgLngthKeyphrs = (double) sumLgthKeyphrs / nrofKeyphrases; final double stdDevAvgLnthKphr = stdDev(charsPerKeyphr); final double avgToksKeyphrs = mean(tknsPerKeyphr); final double stdDevToksKeyphr = stdDev(tknsPerKeyphr); final double avgKeyphrPerDoc = (double) nrofKeyphrases / nrofDocuments; final double stdDevKeyphrDoc = stdDev(keyphrsPerDoc); final double upperBoundP5 = meanDouble(upperBoundP10s); final double upperBoundR5 = meanDouble(upperBoundR10s); final StringBuilder stringBuilder = new StringBuilder(272); stringBuilder.append(LINE_SEPARATOR); stringBuilder.append("# Documents: "); stringBuilder.append(nrofDocuments); stringBuilder.append(LINE_SEPARATOR); stringBuilder.append("Tokens / Document: "); stringBuilder.append(averageNrofTokens); stringBuilder.append(MORE_LESS_LITERAL); stringBuilder.append(stdDevAvgNrTokens); stringBuilder.append(") Median: "); stringBuilder.append(median(tokensPerDocument)); stringBuilder.append(')'); stringBuilder.append(LINE_SEPARATOR); stringBuilder.append("# Keyphrases: "); stringBuilder.append(nrofKeyphrases); stringBuilder.append(LINE_SEPARATOR); stringBuilder.append("Keyphrases / Document: "); stringBuilder.append(avgKeyphrPerDoc); stringBuilder.append(MORE_LESS_LITERAL); stringBuilder.append(stdDevKeyphrDoc); stringBuilder.append(')'); stringBuilder.append(LINE_SEPARATOR); stringBuilder.append("Characters / Keyphrase: "); stringBuilder.append(avgLngthKeyphrs); stringBuilder.append(MORE_LESS_LITERAL); stringBuilder.append(stdDevAvgLnthKphr); stringBuilder.append(')'); stringBuilder.append(LINE_SEPARATOR); stringBuilder.append("Tokens / Keyphrase: "); stringBuilder.append(avgToksKeyphrs); stringBuilder.append(MORE_LESS_LITERAL); stringBuilder.append(stdDevToksKeyphr); stringBuilder.append(')'); stringBuilder.append(LINE_SEPARATOR); stringBuilder.append(LINE_SEPARATOR); stringBuilder.append("Upper bound (P@10): "); stringBuilder.append(upperBoundP5); stringBuilder.append(LINE_SEPARATOR); stringBuilder.append("Upper bound (R@10): "); stringBuilder.append(upperBoundR5); stringBuilder.append(LINE_SEPARATOR); stringBuilder.append(LINE_SEPARATOR); stringBuilder.append("Pearson Correlation between document size and the number of gold keyphrases:"); stringBuilder.append(LINE_SEPARATOR); stringBuilder.append(LINE_SEPARATOR); stringBuilder.append(getNrOfTokensPerKeyphraseHistogramm()); stringBuilder.append(LINE_SEPARATOR); stringBuilder.append(LINE_SEPARATOR); getContext().getLogger().setOutputStream(System.out); getContext().getLogger().log(Level.INFO, stringBuilder.toString()); }
KeyphraseDatasetStatistics extends JCasAnnotator_ImplBase { @Override public void collectionProcessComplete() throws AnalysisEngineProcessException { final double averageNrofTokens = (double) sumNrofTokens / nrofDocuments; final double stdDevAvgNrTokens = stdDev(tokensPerDocument); final double avgLngthKeyphrs = (double) sumLgthKeyphrs / nrofKeyphrases; final double stdDevAvgLnthKphr = stdDev(charsPerKeyphr); final double avgToksKeyphrs = mean(tknsPerKeyphr); final double stdDevToksKeyphr = stdDev(tknsPerKeyphr); final double avgKeyphrPerDoc = (double) nrofKeyphrases / nrofDocuments; final double stdDevKeyphrDoc = stdDev(keyphrsPerDoc); final double upperBoundP5 = meanDouble(upperBoundP10s); final double upperBoundR5 = meanDouble(upperBoundR10s); final StringBuilder stringBuilder = new StringBuilder(272); stringBuilder.append(LINE_SEPARATOR); stringBuilder.append("# Documents: "); stringBuilder.append(nrofDocuments); stringBuilder.append(LINE_SEPARATOR); stringBuilder.append("Tokens / Document: "); stringBuilder.append(averageNrofTokens); stringBuilder.append(MORE_LESS_LITERAL); stringBuilder.append(stdDevAvgNrTokens); stringBuilder.append(") Median: "); stringBuilder.append(median(tokensPerDocument)); stringBuilder.append(')'); stringBuilder.append(LINE_SEPARATOR); stringBuilder.append("# Keyphrases: "); stringBuilder.append(nrofKeyphrases); stringBuilder.append(LINE_SEPARATOR); stringBuilder.append("Keyphrases / Document: "); stringBuilder.append(avgKeyphrPerDoc); stringBuilder.append(MORE_LESS_LITERAL); stringBuilder.append(stdDevKeyphrDoc); stringBuilder.append(')'); stringBuilder.append(LINE_SEPARATOR); stringBuilder.append("Characters / Keyphrase: "); stringBuilder.append(avgLngthKeyphrs); stringBuilder.append(MORE_LESS_LITERAL); stringBuilder.append(stdDevAvgLnthKphr); stringBuilder.append(')'); stringBuilder.append(LINE_SEPARATOR); stringBuilder.append("Tokens / Keyphrase: "); stringBuilder.append(avgToksKeyphrs); stringBuilder.append(MORE_LESS_LITERAL); stringBuilder.append(stdDevToksKeyphr); stringBuilder.append(')'); stringBuilder.append(LINE_SEPARATOR); stringBuilder.append(LINE_SEPARATOR); stringBuilder.append("Upper bound (P@10): "); stringBuilder.append(upperBoundP5); stringBuilder.append(LINE_SEPARATOR); stringBuilder.append("Upper bound (R@10): "); stringBuilder.append(upperBoundR5); stringBuilder.append(LINE_SEPARATOR); stringBuilder.append(LINE_SEPARATOR); stringBuilder.append("Pearson Correlation between document size and the number of gold keyphrases:"); stringBuilder.append(LINE_SEPARATOR); stringBuilder.append(LINE_SEPARATOR); stringBuilder.append(getNrOfTokensPerKeyphraseHistogramm()); stringBuilder.append(LINE_SEPARATOR); stringBuilder.append(LINE_SEPARATOR); getContext().getLogger().setOutputStream(System.out); getContext().getLogger().log(Level.INFO, stringBuilder.toString()); } }
KeyphraseDatasetStatistics extends JCasAnnotator_ImplBase { @Override public void collectionProcessComplete() throws AnalysisEngineProcessException { final double averageNrofTokens = (double) sumNrofTokens / nrofDocuments; final double stdDevAvgNrTokens = stdDev(tokensPerDocument); final double avgLngthKeyphrs = (double) sumLgthKeyphrs / nrofKeyphrases; final double stdDevAvgLnthKphr = stdDev(charsPerKeyphr); final double avgToksKeyphrs = mean(tknsPerKeyphr); final double stdDevToksKeyphr = stdDev(tknsPerKeyphr); final double avgKeyphrPerDoc = (double) nrofKeyphrases / nrofDocuments; final double stdDevKeyphrDoc = stdDev(keyphrsPerDoc); final double upperBoundP5 = meanDouble(upperBoundP10s); final double upperBoundR5 = meanDouble(upperBoundR10s); final StringBuilder stringBuilder = new StringBuilder(272); stringBuilder.append(LINE_SEPARATOR); stringBuilder.append("# Documents: "); stringBuilder.append(nrofDocuments); stringBuilder.append(LINE_SEPARATOR); stringBuilder.append("Tokens / Document: "); stringBuilder.append(averageNrofTokens); stringBuilder.append(MORE_LESS_LITERAL); stringBuilder.append(stdDevAvgNrTokens); stringBuilder.append(") Median: "); stringBuilder.append(median(tokensPerDocument)); stringBuilder.append(')'); stringBuilder.append(LINE_SEPARATOR); stringBuilder.append("# Keyphrases: "); stringBuilder.append(nrofKeyphrases); stringBuilder.append(LINE_SEPARATOR); stringBuilder.append("Keyphrases / Document: "); stringBuilder.append(avgKeyphrPerDoc); stringBuilder.append(MORE_LESS_LITERAL); stringBuilder.append(stdDevKeyphrDoc); stringBuilder.append(')'); stringBuilder.append(LINE_SEPARATOR); stringBuilder.append("Characters / Keyphrase: "); stringBuilder.append(avgLngthKeyphrs); stringBuilder.append(MORE_LESS_LITERAL); stringBuilder.append(stdDevAvgLnthKphr); stringBuilder.append(')'); stringBuilder.append(LINE_SEPARATOR); stringBuilder.append("Tokens / Keyphrase: "); stringBuilder.append(avgToksKeyphrs); stringBuilder.append(MORE_LESS_LITERAL); stringBuilder.append(stdDevToksKeyphr); stringBuilder.append(')'); stringBuilder.append(LINE_SEPARATOR); stringBuilder.append(LINE_SEPARATOR); stringBuilder.append("Upper bound (P@10): "); stringBuilder.append(upperBoundP5); stringBuilder.append(LINE_SEPARATOR); stringBuilder.append("Upper bound (R@10): "); stringBuilder.append(upperBoundR5); stringBuilder.append(LINE_SEPARATOR); stringBuilder.append(LINE_SEPARATOR); stringBuilder.append("Pearson Correlation between document size and the number of gold keyphrases:"); stringBuilder.append(LINE_SEPARATOR); stringBuilder.append(LINE_SEPARATOR); stringBuilder.append(getNrOfTokensPerKeyphraseHistogramm()); stringBuilder.append(LINE_SEPARATOR); stringBuilder.append(LINE_SEPARATOR); getContext().getLogger().setOutputStream(System.out); getContext().getLogger().log(Level.INFO, stringBuilder.toString()); }  }
KeyphraseDatasetStatistics extends JCasAnnotator_ImplBase { @Override public void collectionProcessComplete() throws AnalysisEngineProcessException { final double averageNrofTokens = (double) sumNrofTokens / nrofDocuments; final double stdDevAvgNrTokens = stdDev(tokensPerDocument); final double avgLngthKeyphrs = (double) sumLgthKeyphrs / nrofKeyphrases; final double stdDevAvgLnthKphr = stdDev(charsPerKeyphr); final double avgToksKeyphrs = mean(tknsPerKeyphr); final double stdDevToksKeyphr = stdDev(tknsPerKeyphr); final double avgKeyphrPerDoc = (double) nrofKeyphrases / nrofDocuments; final double stdDevKeyphrDoc = stdDev(keyphrsPerDoc); final double upperBoundP5 = meanDouble(upperBoundP10s); final double upperBoundR5 = meanDouble(upperBoundR10s); final StringBuilder stringBuilder = new StringBuilder(272); stringBuilder.append(LINE_SEPARATOR); stringBuilder.append("# Documents: "); stringBuilder.append(nrofDocuments); stringBuilder.append(LINE_SEPARATOR); stringBuilder.append("Tokens / Document: "); stringBuilder.append(averageNrofTokens); stringBuilder.append(MORE_LESS_LITERAL); stringBuilder.append(stdDevAvgNrTokens); stringBuilder.append(") Median: "); stringBuilder.append(median(tokensPerDocument)); stringBuilder.append(')'); stringBuilder.append(LINE_SEPARATOR); stringBuilder.append("# Keyphrases: "); stringBuilder.append(nrofKeyphrases); stringBuilder.append(LINE_SEPARATOR); stringBuilder.append("Keyphrases / Document: "); stringBuilder.append(avgKeyphrPerDoc); stringBuilder.append(MORE_LESS_LITERAL); stringBuilder.append(stdDevKeyphrDoc); stringBuilder.append(')'); stringBuilder.append(LINE_SEPARATOR); stringBuilder.append("Characters / Keyphrase: "); stringBuilder.append(avgLngthKeyphrs); stringBuilder.append(MORE_LESS_LITERAL); stringBuilder.append(stdDevAvgLnthKphr); stringBuilder.append(')'); stringBuilder.append(LINE_SEPARATOR); stringBuilder.append("Tokens / Keyphrase: "); stringBuilder.append(avgToksKeyphrs); stringBuilder.append(MORE_LESS_LITERAL); stringBuilder.append(stdDevToksKeyphr); stringBuilder.append(')'); stringBuilder.append(LINE_SEPARATOR); stringBuilder.append(LINE_SEPARATOR); stringBuilder.append("Upper bound (P@10): "); stringBuilder.append(upperBoundP5); stringBuilder.append(LINE_SEPARATOR); stringBuilder.append("Upper bound (R@10): "); stringBuilder.append(upperBoundR5); stringBuilder.append(LINE_SEPARATOR); stringBuilder.append(LINE_SEPARATOR); stringBuilder.append("Pearson Correlation between document size and the number of gold keyphrases:"); stringBuilder.append(LINE_SEPARATOR); stringBuilder.append(LINE_SEPARATOR); stringBuilder.append(getNrOfTokensPerKeyphraseHistogramm()); stringBuilder.append(LINE_SEPARATOR); stringBuilder.append(LINE_SEPARATOR); getContext().getLogger().setOutputStream(System.out); getContext().getLogger().log(Level.INFO, stringBuilder.toString()); }  @Override void initialize(final UimaContext context); @Override void process(final JCas jcas); @Override void collectionProcessComplete(); double mean(final List<Integer> values); double meanDouble(final List<Double> values); double median(final List<Integer> values); double stdDev(final List<Integer> values); }
KeyphraseDatasetStatistics extends JCasAnnotator_ImplBase { @Override public void collectionProcessComplete() throws AnalysisEngineProcessException { final double averageNrofTokens = (double) sumNrofTokens / nrofDocuments; final double stdDevAvgNrTokens = stdDev(tokensPerDocument); final double avgLngthKeyphrs = (double) sumLgthKeyphrs / nrofKeyphrases; final double stdDevAvgLnthKphr = stdDev(charsPerKeyphr); final double avgToksKeyphrs = mean(tknsPerKeyphr); final double stdDevToksKeyphr = stdDev(tknsPerKeyphr); final double avgKeyphrPerDoc = (double) nrofKeyphrases / nrofDocuments; final double stdDevKeyphrDoc = stdDev(keyphrsPerDoc); final double upperBoundP5 = meanDouble(upperBoundP10s); final double upperBoundR5 = meanDouble(upperBoundR10s); final StringBuilder stringBuilder = new StringBuilder(272); stringBuilder.append(LINE_SEPARATOR); stringBuilder.append("# Documents: "); stringBuilder.append(nrofDocuments); stringBuilder.append(LINE_SEPARATOR); stringBuilder.append("Tokens / Document: "); stringBuilder.append(averageNrofTokens); stringBuilder.append(MORE_LESS_LITERAL); stringBuilder.append(stdDevAvgNrTokens); stringBuilder.append(") Median: "); stringBuilder.append(median(tokensPerDocument)); stringBuilder.append(')'); stringBuilder.append(LINE_SEPARATOR); stringBuilder.append("# Keyphrases: "); stringBuilder.append(nrofKeyphrases); stringBuilder.append(LINE_SEPARATOR); stringBuilder.append("Keyphrases / Document: "); stringBuilder.append(avgKeyphrPerDoc); stringBuilder.append(MORE_LESS_LITERAL); stringBuilder.append(stdDevKeyphrDoc); stringBuilder.append(')'); stringBuilder.append(LINE_SEPARATOR); stringBuilder.append("Characters / Keyphrase: "); stringBuilder.append(avgLngthKeyphrs); stringBuilder.append(MORE_LESS_LITERAL); stringBuilder.append(stdDevAvgLnthKphr); stringBuilder.append(')'); stringBuilder.append(LINE_SEPARATOR); stringBuilder.append("Tokens / Keyphrase: "); stringBuilder.append(avgToksKeyphrs); stringBuilder.append(MORE_LESS_LITERAL); stringBuilder.append(stdDevToksKeyphr); stringBuilder.append(')'); stringBuilder.append(LINE_SEPARATOR); stringBuilder.append(LINE_SEPARATOR); stringBuilder.append("Upper bound (P@10): "); stringBuilder.append(upperBoundP5); stringBuilder.append(LINE_SEPARATOR); stringBuilder.append("Upper bound (R@10): "); stringBuilder.append(upperBoundR5); stringBuilder.append(LINE_SEPARATOR); stringBuilder.append(LINE_SEPARATOR); stringBuilder.append("Pearson Correlation between document size and the number of gold keyphrases:"); stringBuilder.append(LINE_SEPARATOR); stringBuilder.append(LINE_SEPARATOR); stringBuilder.append(getNrOfTokensPerKeyphraseHistogramm()); stringBuilder.append(LINE_SEPARATOR); stringBuilder.append(LINE_SEPARATOR); getContext().getLogger().setOutputStream(System.out); getContext().getLogger().log(Level.INFO, stringBuilder.toString()); }  @Override void initialize(final UimaContext context); @Override void process(final JCas jcas); @Override void collectionProcessComplete(); double mean(final List<Integer> values); double meanDouble(final List<Double> values); double median(final List<Integer> values); double stdDev(final List<Integer> values); static final String PARAM_LOWERCASE; static final String PARAM_GOLD_SUFFIX; }