// Path: src/main/java/cz/brmlab/brmson/blanqa/framework/data/Sentence.java
// public class Sentence {
// 	private String text;
// 	private Sentence prev, next;
// 
// 	private SearchResult resultRef;
// 
// 	private float score;
// 
// 	public Sentence(SearchResult resultRef, String text) {
// 		this.resultRef = resultRef;
// 		this.text = text;
// 		this.score = 0;
// 	}
// 
// 	public String getText() {
// 		return text;
// 	}
// 	public SearchResult getResultRef() {
// 		return resultRef;
// 	}
// 
// 	public Sentence getPrev() {
// 		return prev;
// 	}
// 	public void setPrev(Sentence s) {
// 		this.prev = s;
// 	}
// 
// 	public Sentence getNext() {
// 		return next;
// 	}
// 	public void setNext(Sentence s) {
// 		this.next = s;
// 	}
// 
// 	public float getScore() {
// 		return score;
// 	}
// 	public void setScore(float score) {
// 		this.score = score;
// 	}
// 	public void addScore(float score) {
// 		this.score += score;
// 	}
// }
// 
// Path: src/main/java/cz/brmlab/brmson/core/provider/opennlp/OpenNLPWrapper.java
// public final class OpenNLPWrapper extends OpenNLP {
// 	/* These data files can be download at http://pasky.or.cz/dev/brmson/res-opennlp.zip */
// 
// 	private static final String TOKENIZER_PATH = "res/ephyra/nlp/tokenizer/opennlp/EnglishTok.bin.gz";
// 
// 	private static final String SENT_DETECTOR_PATH = "res/ephyra/nlp/sentencedetector/opennlp/EnglishSD.bin.gz";
// 
// 	private static final String TAGGER_PATH = "res/ephyra/nlp/postagger/opennlp/tag.bin.gz";
// 	private static final String TAGGER_DICT_PATH = "res/ephyra/nlp/postagger/opennlp/tagdict";
// 
// 	private static final String CHUNKER_PATH = "res/ephyra/nlp/phrasechunker/opennlp/EnglishChunk.bin.gz";
// 
// 
// 	private static boolean initialized = false;
// 
// 	public static void initialize() throws Exception {
// 		if (initialized)
// 			return;
// 
// 		if (!createTokenizer(TOKENIZER_PATH))
// 			throw new Exception("Could not initialize tokenizer.");
// 
// 		// sentence segmenter
// 		if (!createSentenceDetector(SENT_DETECTOR_PATH))
// 			throw new Exception("Could not initialize sentence segmenter.");
// 
// 		// part of speech tagger
// 		if (!createPosTagger(TAGGER_PATH, TAGGER_DICT_PATH))
// 			throw new Exception("Could not initialize POS tagger.");
// 
// 		// phrase chunker
// 		if (!createChunker(CHUNKER_PATH))
// 			throw new Exception("Could not initialize phrase chunker.");
// 
// 		initialized = true;
// 	}
// }


import java.util.LinkedList;
import java.util.List;
import org.oaqa.model.SearchResult;
import cz.brmlab.brmson.blanqa.framework.data.Sentence;
import cz.brmlab.brmson.core.provider.opennlp.OpenNLPWrapper;
package cz.brmlab.brmson.blanqa.analysis;




/**
 * Split text to a series of sentences.
 */

public class SentenceSplitter {
	private static final int MIN_SENTENCE_LENGTH = 3;
	private static final int MAX_SENTENCE_LENGTH = 512;

	/**
	 * Split a given result with a given text (may be preprocessed)
	 * to a list of contextualized sentences.
	 */
	public static List<Sentence> split(SearchResult srcResult, String srcText) {
		String[] sentenceTexts = OpenNLPWrapper.sentDetect(srcText);

		LinkedList<Sentence> sentences = new LinkedList<Sentence>();
		for (String text : sentenceTexts) {
			if (text.length() <= MIN_SENTENCE_LENGTH)
				continue;
			if (text.length() > MAX_SENTENCE_LENGTH) {
				System.err.println("Omitting extremely long sentence: " + text.substring(0, 64) + " ...");
// Path: src/main/java/cz/brmlab/brmson/blanqa/framework/data/Sentence.java
// public class Sentence {
// 	private String text;
// 	private Sentence prev, next;
// 
// 	private SearchResult resultRef;
// 
// 	private float score;
// 
// 	public Sentence(SearchResult resultRef, String text) {
// 		this.resultRef = resultRef;
// 		this.text = text;
// 		this.score = 0;
// 	}
// 
// 	public String getText() {
// 		return text;
// 	}
// 	public SearchResult getResultRef() {
// 		return resultRef;
// 	}
// 
// 	public Sentence getPrev() {
// 		return prev;
// 	}
// 	public void setPrev(Sentence s) {
// 		this.prev = s;
// 	}
// 
// 	public Sentence getNext() {
// 		return next;
// 	}
// 	public void setNext(Sentence s) {
// 		this.next = s;
// 	}
// 
// 	public float getScore() {
// 		return score;
// 	}
// 	public void setScore(float score) {
// 		this.score = score;
// 	}
// 	public void addScore(float score) {
// 		this.score += score;
// 	}
// }
// 
// Path: src/main/java/cz/brmlab/brmson/core/provider/opennlp/OpenNLPWrapper.java
// public final class OpenNLPWrapper extends OpenNLP {
// 	/* These data files can be download at http://pasky.or.cz/dev/brmson/res-opennlp.zip */
// 
// 	private static final String TOKENIZER_PATH = "res/ephyra/nlp/tokenizer/opennlp/EnglishTok.bin.gz";
// 
// 	private static final String SENT_DETECTOR_PATH = "res/ephyra/nlp/sentencedetector/opennlp/EnglishSD.bin.gz";
// 
// 	private static final String TAGGER_PATH = "res/ephyra/nlp/postagger/opennlp/tag.bin.gz";
// 	private static final String TAGGER_DICT_PATH = "res/ephyra/nlp/postagger/opennlp/tagdict";
// 
// 	private static final String CHUNKER_PATH = "res/ephyra/nlp/phrasechunker/opennlp/EnglishChunk.bin.gz";
// 
// 
// 	private static boolean initialized = false;
// 
// 	public static void initialize() throws Exception {
// 		if (initialized)
// 			return;
// 
// 		if (!createTokenizer(TOKENIZER_PATH))
// 			throw new Exception("Could not initialize tokenizer.");
// 
// 		// sentence segmenter
// 		if (!createSentenceDetector(SENT_DETECTOR_PATH))
// 			throw new Exception("Could not initialize sentence segmenter.");
// 
// 		// part of speech tagger
// 		if (!createPosTagger(TAGGER_PATH, TAGGER_DICT_PATH))
// 			throw new Exception("Could not initialize POS tagger.");
// 
// 		// phrase chunker
// 		if (!createChunker(CHUNKER_PATH))
// 			throw new Exception("Could not initialize phrase chunker.");
// 
// 		initialized = true;
// 	}
// }


// Path: src/main/java/cz/brmlab/brmson/blanqa/analysis/SentenceSplitter.java
import java.util.LinkedList;
import java.util.List;
import org.oaqa.model.SearchResult;
import cz.brmlab.brmson.blanqa.framework.data.Sentence;
import cz.brmlab.brmson.core.provider.opennlp.OpenNLPWrapper;

package cz.brmlab.brmson.blanqa.analysis;




/**
 * Split text to a series of sentences.
 */

public class SentenceSplitter {
	private static final int MIN_SENTENCE_LENGTH = 3;
	private static final int MAX_SENTENCE_LENGTH = 512;

	/**
	 * Split a given result with a given text (may be preprocessed)
	 * to a list of contextualized sentences.
	 */
	public static List<Sentence> split(SearchResult srcResult, String srcText) {
		String[] sentenceTexts = OpenNLPWrapper.sentDetect(srcText);

		LinkedList<Sentence> sentences = new LinkedList<Sentence>();
		for (String text : sentenceTexts) {
			if (text.length() <= MIN_SENTENCE_LENGTH)
				continue;
			if (text.length() > MAX_SENTENCE_LENGTH) {
				System.err.println("Omitting extremely long sentence: " + text.substring(0, 64) + " ...");
				continue;