@Test public void PositionKeyphraseTest() throws Exception { String testDocument = "example sentence funny. second example."; AnalysisEngine analysisEngine = AnalysisEngineFactory.createEngine( PositionRanking.class); JCas jcas = setup(testDocument, analysisEngine); analysisEngine.process(jcas); int i=0; for (Keyphrase k : JCasUtil.select(jcas, Keyphrase.class)) { System.out.println(k); if (i==0) { assertEquals("example", k.getKeyphrase()); assertEquals(1.0, k.getScore(), EPSILON); } if (i==1) { assertEquals("second", k.getKeyphrase()); assertEquals(0.384615385, k.getScore(), EPSILON); } i++; } assertEquals(2,i); }
@Override public void process(JCas jcas) throws AnalysisEngineProcessException { int totalLength = jcas.getDocumentText().length(); for (Keyphrase keyphrase : JCasUtil.select(jcas, Keyphrase.class)) { keyphrase.setScore((totalLength - keyphrase.getBegin())/(double)totalLength); } }
PositionRanking extends JCasAnnotator_ImplBase { @Override public void process(JCas jcas) throws AnalysisEngineProcessException { int totalLength = jcas.getDocumentText().length(); for (Keyphrase keyphrase : JCasUtil.select(jcas, Keyphrase.class)) { keyphrase.setScore((totalLength - keyphrase.getBegin())/(double)totalLength); } } }
PositionRanking extends JCasAnnotator_ImplBase { @Override public void process(JCas jcas) throws AnalysisEngineProcessException { int totalLength = jcas.getDocumentText().length(); for (Keyphrase keyphrase : JCasUtil.select(jcas, Keyphrase.class)) { keyphrase.setScore((totalLength - keyphrase.getBegin())/(double)totalLength); } }  }
PositionRanking extends JCasAnnotator_ImplBase { @Override public void process(JCas jcas) throws AnalysisEngineProcessException { int totalLength = jcas.getDocumentText().length(); for (Keyphrase keyphrase : JCasUtil.select(jcas, Keyphrase.class)) { keyphrase.setScore((totalLength - keyphrase.getBegin())/(double)totalLength); } }  @Override void process(JCas jcas); }
PositionRanking extends JCasAnnotator_ImplBase { @Override public void process(JCas jcas) throws AnalysisEngineProcessException { int totalLength = jcas.getDocumentText().length(); for (Keyphrase keyphrase : JCasUtil.select(jcas, Keyphrase.class)) { keyphrase.setScore((totalLength - keyphrase.getBegin())/(double)totalLength); } }  @Override void process(JCas jcas);  }