BookIndexPhraseExtractor_BaseImpl implements BookIndexPhraseExtractor { @Override public List<String> extract(File textFile) { AnalysisEngine ae; try { ae = createEngine(createAggregate()); JCas jcas = ae.newJCas(); jcas.setDocumentText(FileUtils.readFileToString(textFile)); DocumentMetaData docMetaData = new DocumentMetaData(jcas); docMetaData.addToIndexes(); jcas = ae.processAndOutputNewCASes(jcas).next(); return getBookIndexPhrases(jcas); } catch (Exception e) { throw new RuntimeException(e); } } BookIndexPhraseExtractor_BaseImpl(); @Override List<String> extract(File textFile); CandidateSet getCandidateSet(); void setCandidateSet(CandidateSet candidateSet); void setMergePhrases(boolean mergePhrases); void setPhraseLengthRange(int minPhraseLength, int maxPhraseLength); boolean isConvertToLowercase(); void setConvertToLowercase(boolean convertToLowercase); String getLanguage(); @Override String toString(); void setLanguage(String language); void setSegmentation(SegmentationType segmentationType, int n); final static String LF; }
@Test @Ignore public void extract() { BookIndexPhraseExtractor_BaseImpl extractor = new BookIndexPhraseExtractor_BaseImplTestable(); extractor.setCandidateSet(new TokenCandidateSet()); List<String> actual = extractor.extract(new File(TEXT_FILE)); List<String> expected = list("bar", "quuz", "foo"); assertEquals(expected, actual); }