splitSentencesIndex method

List<SentenceIndex> splitSentencesIndex(
  1. String text,
  2. bool useHeuristic,
  3. bool useQuotesBracketsProcessing,
  4. int maxRecoverStep,
  5. int maxRecoverLength,
)

Implementation

List<SentenceIndex> splitSentencesIndex(
    String text, bool useHeuristic, bool useQuotesBracketsProcessing, int maxRecoverStep, int maxRecoverLength) {
  List<String> sentences = splitSentences(text, useHeuristic, useQuotesBracketsProcessing, maxRecoverStep, maxRecoverLength, 0, true);

  List<SentenceIndex> sentenceIndexes = [];
  int offset = 0;

  for (String sentence in sentences) {
    sentenceIndexes.add(new SentenceIndex(start: offset + text.indexOf(sentence), end: offset + text.indexOf(sentence) + sentence.length));

    offset += text.indexOf(sentence) + sentence.length;
    text = text.substring(text.indexOf(sentence) + sentence.length);
  }
  return sentenceIndexes;
}