@Test public void testExtractSentences() throws IOException { log.info("testExtractSentences"); Text text = readabilityService.extractSentences(source1); logAll(text); assertNotNull(text); assertEquals(3, text.getSentences().size()); assertEquals(86, text.getWordCount()); assertEquals(11, text.getComplexWordCount()); text = readabilityService.extractSentences(source2); logAll(text); assertNotNull(text); assertEquals(12, text.getSentences().size()); assertEquals(195, text.getWordCount()); assertEquals(50, text.getComplexWordCount()); text = readabilityService.extractSentences(source3); logAll(text); assertNotNull(text); assertEquals(11, text.getSentences().size()); assertEquals(157, text.getWordCount()); assertEquals(7, text.getComplexWordCount()); log.info("Tests successful!"); }
@Override public Text extractSentences(String input) { BreakIterator breakIterator = BreakIterator.getSentenceInstance(locale); breakIterator.setText(input); int start = breakIterator.first(); List<String> sentenceStrs = new ArrayList<>(); for (int end = breakIterator.next(); end != BreakIterator.DONE; start = end, end = breakIterator.next()) { sentenceStrs.add(input.substring(start, end)); } return new Text(input, sentenceStrs.stream().map(s -> new Sentence(s, extractWords(s))).collect(Collectors.toList())); }
ReadabilityServiceImpl implements ReadabilityService { @Override public Text extractSentences(String input) { BreakIterator breakIterator = BreakIterator.getSentenceInstance(locale); breakIterator.setText(input); int start = breakIterator.first(); List<String> sentenceStrs = new ArrayList<>(); for (int end = breakIterator.next(); end != BreakIterator.DONE; start = end, end = breakIterator.next()) { sentenceStrs.add(input.substring(start, end)); } return new Text(input, sentenceStrs.stream().map(s -> new Sentence(s, extractWords(s))).collect(Collectors.toList())); } }
ReadabilityServiceImpl implements ReadabilityService { @Override public Text extractSentences(String input) { BreakIterator breakIterator = BreakIterator.getSentenceInstance(locale); breakIterator.setText(input); int start = breakIterator.first(); List<String> sentenceStrs = new ArrayList<>(); for (int end = breakIterator.next(); end != BreakIterator.DONE; start = end, end = breakIterator.next()) { sentenceStrs.add(input.substring(start, end)); } return new Text(input, sentenceStrs.stream().map(s -> new Sentence(s, extractWords(s))).collect(Collectors.toList())); }  }
ReadabilityServiceImpl implements ReadabilityService { @Override public Text extractSentences(String input) { BreakIterator breakIterator = BreakIterator.getSentenceInstance(locale); breakIterator.setText(input); int start = breakIterator.first(); List<String> sentenceStrs = new ArrayList<>(); for (int end = breakIterator.next(); end != BreakIterator.DONE; start = end, end = breakIterator.next()) { sentenceStrs.add(input.substring(start, end)); } return new Text(input, sentenceStrs.stream().map(s -> new Sentence(s, extractWords(s))).collect(Collectors.toList())); }  @Activate void activate(ReadabilityConfig config); @Override double calculateARI(String text); @Override double calculateARI(Text text); @Override double calculateAverageGradeLevel(String text); @Override double calculateAverageGradeLevel(Text text); @Override double calculateColemanLiauIndex(String text); @Override double calculateColemanLiauIndex(Text text); @Override double calculateFleschKincaidGradeLevel(String text); @Override double calculateFleschKincaidGradeLevel(Text text); @Override double calculateFleschReadingEase(String text); @Override double calculateFleschReadingEase(Text text); @Override double calculateGunningFog(String text); @Override double calculateGunningFog(Text text); @Override double calculateSMOG(String text); @Override double calculateSMOG(Text text); @Override Text extractSentences(String input); @Override Locale getLocale(); }
ReadabilityServiceImpl implements ReadabilityService { @Override public Text extractSentences(String input) { BreakIterator breakIterator = BreakIterator.getSentenceInstance(locale); breakIterator.setText(input); int start = breakIterator.first(); List<String> sentenceStrs = new ArrayList<>(); for (int end = breakIterator.next(); end != BreakIterator.DONE; start = end, end = breakIterator.next()) { sentenceStrs.add(input.substring(start, end)); } return new Text(input, sentenceStrs.stream().map(s -> new Sentence(s, extractWords(s))).collect(Collectors.toList())); }  @Activate void activate(ReadabilityConfig config); @Override double calculateARI(String text); @Override double calculateARI(Text text); @Override double calculateAverageGradeLevel(String text); @Override double calculateAverageGradeLevel(Text text); @Override double calculateColemanLiauIndex(String text); @Override double calculateColemanLiauIndex(Text text); @Override double calculateFleschKincaidGradeLevel(String text); @Override double calculateFleschKincaidGradeLevel(Text text); @Override double calculateFleschReadingEase(String text); @Override double calculateFleschReadingEase(Text text); @Override double calculateGunningFog(String text); @Override double calculateGunningFog(Text text); @Override double calculateSMOG(String text); @Override double calculateSMOG(Text text); @Override Text extractSentences(String input); @Override Locale getLocale();  }