RandomRanking extends JCasAnnotator_ImplBase { @Override public void process(JCas jcas) throws AnalysisEngineProcessException { for (Keyphrase k : JCasUtil.select(jcas, Keyphrase.class)) { k.setScore( random.nextDouble() ); } }  @Override void initialize(UimaContext context); @Override void process(JCas jcas);  }
@Test public void randomKeyphraseTest() throws Exception { System.out.println("Default settings. Maximum."); String testDocument = "example sentence funny. second example."; AnalysisEngine analysisEngine = AnalysisEngineFactory.createPrimitive( RandomRanking.class); JCas jcas = setup(testDocument, analysisEngine); analysisEngine.process(jcas); Set<String> expectedKeyphrases = new HashSet<String>(); expectedKeyphrases.add("example sentence funny"); expectedKeyphrases.add("second example"); int i=0; for (Keyphrase k : JCasUtil.select(jcas, Keyphrase.class)) { System.out.println(k); assertTrue(k.getKeyphrase(), expectedKeyphrases.contains(k.getKeyphrase())); i++; } assertEquals(2,i); }