SentenceWriter extends Processor { protected void writeSentences(CrawlURI curi, String cleaned_plaintext) { String perplexity_value_as_string = "null"; if(curi != null && curi.getData() != null){ Object obj = curi.getData().get(SharedConstants.EXTRA_INFO_PERPLEXITY); if(obj != null) perplexity_value_as_string = (String)obj; } String time = TimeUtils.get_ISO_8601_UTC(); int c = 0; synchronized (_lck) { for(String sentence : _sentence_maker.getSentences(cleaned_plaintext, _languagecode)){ String s = String.format("%s\t%s\t%s\t%d\t%s%n", time, sentence, curi, ++c, perplexity_value_as_string); _current_stream.print(s); _num_bytes_written.getAndAdd(s.getBytes().length); _num_bytes_sentences_written.getAndAdd(sentence.getBytes().length); } _current_stream.flush(); } _num_sentences.getAndAdd(c); _num_uris_written.getAndIncrement(); } SentenceWriter(); TextExtractor getTextExtractor(); void setTextExtractor(TextExtractor text_extractor); SentenceMaker getSentenceMaker(); void setSentenceMaker(SentenceMaker sentence_maker); ConfigPath getPath(); void setPath(ConfigPath newpath); String getLanguageCode(); void setLanguageCode(String languagecode); long getMaxFileSizeBytes(); void setMaxFileSizeBytes(long maxFileSizeBytes); String getPrefix(); void setPrefix(String prefix); String getFilenameFormat(); void setFilenameFormat(String filename_format); @Override void start(); @Override void stop(); @Override String report();  }
@Test public void test() { SentenceWriter w = new SentenceWriter(){{_sentence_maker = new SentenceMaker();}}; w._current_stream = System.out; w.writeSentences(null, "This is a test. This is also a test."); }