@Test public void PosFilterTest() throws Exception { Map<String,Double> expectedResults = new HashMap<String,Double>(); expectedResults.put("sentence", 1.6487752080270504); expectedResults.put("second", 0.8508165279819666); expectedResults.put("long", 0.5004082639909833); expectedResults.put("more", 0.5004082639909833); expectedResults.put("necessary", 0.8508165279819666); expectedResults.put("test", 1.6487752080270504); String testDocument = "This is a not so long test sentence. This is a longer second test sentence. More sentences are necessary for the tests."; AnalysisEngineDescription aggregate = createEngineDescription( createEngineDescription(de.tudarmstadt.ukp.dkpro.core.tokit.BreakIteratorSegmenter.class), AnalysisEngineFactory.createEngineDescription(StanfordPosTagger.class, StanfordPosTagger.PARAM_LANGUAGE, "en"), AnalysisEngineFactory.createEngineDescription(StanfordLemmatizer.class), createEngineDescription( PosFilter.class, PosFilter.PARAM_TYPE_TO_REMOVE, Lemma.class.getName(), PosFilter.PARAM_ADJ, true, PosFilter.PARAM_N, true ), CooccurrenceGraphFactory.getCooccurrenceGraph_lemma(), createEngineDescription(PageRankRanking.class, PageRankRanking.PARAM_WEIGHTED, false)); AnalysisEngine engine = AnalysisEngineFactory.createEngine(aggregate); JCas aJCas = engine.newJCas(); aJCas.setDocumentText(testDocument); engine.process(aJCas); int i=0; for (Keyphrase keyphrase : JCasUtil.select(aJCas, Keyphrase.class)) { assertTrue(keyphrase.getKeyphrase(), expectedResults.containsKey(keyphrase.getKeyphrase())); assertEquals(keyphrase.getKeyphrase(), expectedResults.get(keyphrase.getKeyphrase()), keyphrase.getScore(), EPSILON); i++; } assertEquals(10,i); }
@Override public void process(JCas jcas) throws AnalysisEngineProcessException { getContext().getLogger().log(Level.CONFIG, "Entering " + this.getClass().getSimpleName()); pageRank.initializeFromAnnotationPairIterator( JCasUtil.select(jcas, AnnotationPair.class), weighted ); pageRank.run(); List<TermRank> termRanks = pageRank.getTermRanks(); getContext().getLogger().log(Level.FINE, termRanks.toString()); for (TermRank termRank : termRanks) { addKeyphrase(jcas, termRank); } }
PageRankRanking extends JCasAnnotator_ImplBase { @Override public void process(JCas jcas) throws AnalysisEngineProcessException { getContext().getLogger().log(Level.CONFIG, "Entering " + this.getClass().getSimpleName()); pageRank.initializeFromAnnotationPairIterator( JCasUtil.select(jcas, AnnotationPair.class), weighted ); pageRank.run(); List<TermRank> termRanks = pageRank.getTermRanks(); getContext().getLogger().log(Level.FINE, termRanks.toString()); for (TermRank termRank : termRanks) { addKeyphrase(jcas, termRank); } } }
PageRankRanking extends JCasAnnotator_ImplBase { @Override public void process(JCas jcas) throws AnalysisEngineProcessException { getContext().getLogger().log(Level.CONFIG, "Entering " + this.getClass().getSimpleName()); pageRank.initializeFromAnnotationPairIterator( JCasUtil.select(jcas, AnnotationPair.class), weighted ); pageRank.run(); List<TermRank> termRanks = pageRank.getTermRanks(); getContext().getLogger().log(Level.FINE, termRanks.toString()); for (TermRank termRank : termRanks) { addKeyphrase(jcas, termRank); } }  }
PageRankRanking extends JCasAnnotator_ImplBase { @Override public void process(JCas jcas) throws AnalysisEngineProcessException { getContext().getLogger().log(Level.CONFIG, "Entering " + this.getClass().getSimpleName()); pageRank.initializeFromAnnotationPairIterator( JCasUtil.select(jcas, AnnotationPair.class), weighted ); pageRank.run(); List<TermRank> termRanks = pageRank.getTermRanks(); getContext().getLogger().log(Level.FINE, termRanks.toString()); for (TermRank termRank : termRanks) { addKeyphrase(jcas, termRank); } }  @Override void initialize(UimaContext context); @Override void process(JCas jcas); }
PageRankRanking extends JCasAnnotator_ImplBase { @Override public void process(JCas jcas) throws AnalysisEngineProcessException { getContext().getLogger().log(Level.CONFIG, "Entering " + this.getClass().getSimpleName()); pageRank.initializeFromAnnotationPairIterator( JCasUtil.select(jcas, AnnotationPair.class), weighted ); pageRank.run(); List<TermRank> termRanks = pageRank.getTermRanks(); getContext().getLogger().log(Level.FINE, termRanks.toString()); for (TermRank termRank : termRanks) { addKeyphrase(jcas, termRank); } }  @Override void initialize(UimaContext context); @Override void process(JCas jcas); static final String PARAM_WEIGHTED; }