package relex.corpus;
/*
 * Copyright 2008 Novamente LLC
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import java.util.List;

/**
 * DocSplitter -- split document into sentences.
 * Sentences are blocks of text ending with a period, exclamation
 * mark, or question mark. Unpunctuated blocks of text are not
 * recognized as sentences.
 *
 * This class can operate in one of two modes: batch mode and fifo mode.
 *
 * In batch mode, a large block of text is submitted, and the
 * process() or split() methods are used to get arrays of sentences.
 *
 * In fifo mode, it can be fed anything from large blocks of text
 * to sentence fragments or even a few letters at a time, via the
 * addText() method. It can then be polled to see if there is a
 * complete sentence yet, by calling getNextSentence().  Calls
 * to each of these routines can be arbitrarily alternated, with
 * sentence fragments buffered up.
 *
 * This is a convenience wrapper around the opennlp toolkit;
 * it fixes some bugs encountered there, and provides a more
 * convenient interface.
 *
 * Refactored, expanded version of ord.disco.taca.SentenceAnnotator
 *
 * XXX known bugs:
 * fails to recognize exclamation mark as end of sentence, unless
 * it is preceeded by white space.
 */
public interface DocSplitter
{
	String DEFAULT_ENGLISH_FILENAME =
	        "data/sentence-detector/EnglishSD.bin.gz";

  /**
   * Sets up
   * @param emf for example, data/sentence-detector/EnglishSD.bin.gz
   * @see #DEFAULT_ENGLISH_FILENAME
   */
  void setEnglishModelFilename(String emf);

  /**
   * Gets the setting
   * @return file path
   */
  String getEnglishModelFilename();

	/**
	 * Used to prevent overzelous sentence detectors which have recognizable idiosyncracies
   * @param s ...
   * @param start ...
   * @param end ...
   * @return false if break is unacceptable
   */
  boolean acceptableBreak(String s, int start, int end);

	/**
	 * Adds more text to the buffer.
	 * This allows this class to be used in FIFO mode: text is added with
	 * this call, and sentences are extracted with the getNextSentence() call.
   * @param newText text to be added
   */
  void addText(String newText);

	/**
	 * Clears out the sentence buffer.
	 */
  void clearBuffer();

	/**
	 * Gets the next sentence out of the buffered text.
	 * @return null if there are no complete sentences in the buffer.
	 */
  String getNextSentence();

	/**
	 * Splits a document text string into sentences.
   * @param docText text to be split
   * @return a list of sentence start and end-points
   */
  List<TextInterval> process(String docText);

	/**
	 * Splits a document text string into sentences.
	 * @param docText text to be split
   * @return a list of sentence strings.
	 */
  List<String> split(String docText);
}

@@ -1,27 +1,4 @@
-package relex.corpus;%0D%0A
 /*%0D%0A
@@ -607,16 +607,41 @@
 %0A */%0D%0A%0D%0A
+package relex.corpus;%0D%0A%0D%0A
 import j
@@ -1940,25 +1940,23 @@
 gz%22;%0D%0A%0D%0A
-  
+%09
 /**%0D%0A
-  
+%09
  * Sets 
@@ -1959,18 +1959,17 @@
 ets up%0D%0A
-  
+%09
  * @para
@@ -2028,18 +2028,17 @@
 bin.gz%0D%0A
-  
+%09
  * @see 
@@ -2064,25 +2064,23 @@
 LENAME%0D%0A
-  
+%09
  */%0D%0A
-  
+%09
 void set
@@ -2120,17 +2120,15 @@
 %0D%0A%0D%0A
-  
+%09
 /**%0D%0A
-  
+%09
  * G
@@ -2144,18 +2144,17 @@
 etting%0D%0A
-  
+%09
  * @retu
@@ -2167,25 +2167,23 @@
 e path%0D%0A
-  
+%09
  */%0D%0A
-  
+%09
 String g
@@ -2278,16 +2278,22 @@
 ch have 
+%0D%0A%09 * 
 recogniz
@@ -2313,18 +2313,17 @@
 racies%0D%0A
-  
+%09
  * @para
@@ -2327,26 +2327,25 @@
 aram s ...%0D%0A
-  
+%09
  * @param st
@@ -2349,26 +2349,25 @@
  start ...%0D%0A
-  
+%09
  * @param en
@@ -2373,18 +2373,17 @@
 nd ...%0D%0A
-  
+%09
  * @retu
@@ -2417,25 +2417,23 @@
 ptable%0D%0A
-  
+%09
  */%0D%0A
-  
+%09
 boolean 
@@ -2672,18 +2672,17 @@
  call.%0D%0A
-  
+%09
  * @para
@@ -2709,25 +2709,23 @@
  added%0D%0A
-  
+%09
  */%0D%0A
-  
+%09
 void add
@@ -2798,18 +2798,17 @@
 %0D%0A%09 */%0D%0A
-  
+%09
 void cle
@@ -2956,18 +2956,17 @@
 %0D%0A%09 */%0D%0A
-  
+%09
 String g
@@ -3043,18 +3043,17 @@
 ences.%0D%0A
-  
+%09
  * @para
@@ -3072,34 +3072,33 @@
 xt to be split%0D%0A
-  
+%09
  * @return a lis
@@ -3137,17 +3137,15 @@
 ts%0D%0A
-  
+%09
  */%0D%0A
-  
+%09
 List
@@ -3281,18 +3281,17 @@
  split%0D%0A
-  
+%09
  * @retu
@@ -3328,18 +3328,17 @@
 %0D%0A%09 */%0D%0A
-  
+%09
 List%3CStr

fix the insane indentation.