Returns the first sentence of the specified paragraph.  Uses
<code>java.text.BreakIterator.getSentenceInstance()</code>
19189
public String getFirstSentence(String paragraph) {

        if (paragraph == null || paragraph.length() == 0) {
            return "";
        }

        BreakIterator sentenceBreaks = BreakIterator.getSentenceInstance();
        sentenceBreaks.setText(paragraph);
        int start = sentenceBreaks.first();
        int end = sentenceBreaks.next();

        String sentence = paragraph;
        
        if (start >= 0 && end <= paragraph.length()) {
            sentence = paragraph.substring(start, end);
        }

        return sentence.trim();
    }
998527
def paragraphs(total, opts)
      list = []
      total.times do
        sentence_count = rand(sentence_count_range_in_a_paragraph)
        start_sep = opts[:start_sep].to_s
        end_sep = opts[:end_sep].to_s
        list << start_sep + self.sentences(sentence_count) + end_sep
      end
      return list.join()
    end
1021771
public String tokenizeToText() {

    final StringBuilder sb = new StringBuilder();
    if (isNoSeg) {
      String[] sentences = text.toArray(new String[text.size()]);
      final List<List<Token>> tokens = tokenizer.tokenize(sentences);
      for (final List<Token> tokSentence : tokens) {
        for (final Token tok : tokSentence) {
          String tokenValue = tok.getTokenValue();
          sb.append(tokenValue.trim()).append(DELIMITER);
        }
        sb.append(LINE_BREAK);
      }
    } else {
      final String[] sentences = segmenter.segmentSentence();
      final List<List<Token>> tokens = tokenizer.tokenize(sentences);
      for (final List<Token> tokSentence : tokens) {
        for (final Token token : tokSentence) {
          String tokenValue = token.getTokenValue();
          if (tokenValue.equals(RuleBasedSegmenter.PARAGRAPH)) {
            sb.append(DEFAULT_TOKEN_VALUE).append(LINE_BREAK);
          } else {
            sb.append(tokenValue.trim()).append(DELIMITER);
          }
        }
        sb.append(LINE_BREAK);
      }
    }
    return sb.toString().trim();
  }
1229257
protected IWord getNextPunctuationPairWord(int c, int pos) throws IOException
    {
        IWord w = null, w2 = null;
        String text = getPairPunctuationText(c);
        
        //handle the punctuation.
        String str = String.valueOf((char)c);
        if ( ! ( config.CLEAR_STOPWORD 
                && dic.match(ILexicon.STOP_WORD, str) ) ) {
            w = new Word(str, IWord.T_PUNCTUATION);
            w.setPartSpeech(IWord.PUNCTUATION);
            w.setPosition(pos);
        }
        
        //handle the pair text.
        if ( text != null && text.length() > 0
                && ! ( config.CLEAR_STOPWORD 
                        && dic.match(ILexicon.STOP_WORD, text) ) ) {
            w2 = new Word( text, ILexicon.CJK_WORD );
            w2.setPartSpeech(IWord.PPT_POSPEECH);
            w2.setPosition(pos+1);
            
            if ( w == null ) w = w2;
            else wordPool.add(w2);
        }
        
        /* here: 
         * 1. the punctuation is clear.
         * 2. the pair text is null or being cleared.
         * @date 2013-09-06
        */
        if ( w == null && w2 == null ) {
            return null;
        }
        
        return w;
    }
763974
static Tag[] firstSentenceTags(DocImpl holder, String text) {
        DocLocale doclocale = holder.env.doclocale;
        return getInlineTags(holder,
                             doclocale.localeSpecificFirstSentence(holder, text));
    }
158199
public String nextParagraph(int totalSentences) {
        StringBuilder out = new StringBuilder();

        List<String> lastWords = new ArrayList<String>();
        lastWords.add(null);
        lastWords.add(null);
        int numSentences = 0;
        boolean inSentence = false;
        boolean inQuote = false;
        while(numSentences < totalSentences) {
            List<String> words = pairTable.get(lastWords);
            if(words == null) {
                // no hit for the digram, try just the last word
                words = singleWordTable.get(lastWords.get(1));
            }
            if(words == null) {
                // hit end of paragraph pair, nothing directly following. start again
                words = pairTable.get(Arrays.<String>asList(null, null));
            }
            String nextWord = words.get(random.nextInt(words.size()));
            if(nextWord.length() == 1 && sentenceEndChars.indexOf(nextWord.charAt(0)) != -1) {
                out.append(nextWord);
                if(inQuote) {
                    out.append('"');
                }
                numSentences++;
                inSentence = false;
                inQuote = false;
                lastWords.remove(0);
                lastWords.add(null); // look up
            } else {
                if(!inSentence) {
                    // start a new sentence
                    if(out.length() > 0) {
                        out.append(" ");
                    }
                    inSentence = true;
                } else {
                    // need a word separator
                    out.append(" ");
                }
                out.append(nextWord);
                if(nextWord.indexOf('"') != -1) {
                    inQuote = true;
                }
            }
            lastWords.remove(0);
            lastWords.add(nextWord);

        }
        return out.toString();
    }
812362
def start_new_paragraph(self):
        
        if self.pieces[-1:] == ['']: # respect special marker
            return
        elif self.pieces == []: # first paragraph, add '\n', override with ''
            self.pieces = ['\n']
        elif self.pieces[-1][-1:] != '\n': # previous line not ended
            self.pieces.extend(['  \n' ,'\n'])
        else: #default
            self.pieces.append('\n')
1168418
public static String sentences(int sentenceCount, boolean supplemental) {
        List<String> sentenceList = new ArrayList<String>();
        for (int i = 0; i < sentenceCount; i++) {
            sentenceList.add(sentence(3, supplemental, 6));
        }

        String sentenceString = StringUtils.join(sentenceList, " ");
        return sentenceString;

    }
493000
public float getBeginnings(int i) {
    if (DocumentLine_Type.featOkTst && ((DocumentLine_Type)jcasType).casFeat_beginnings == null)
      jcasType.jcas.throwFeatMissing("beginnings", "ch.epfl.bbp.uima.types.DocumentLine");
    jcasType.jcas.checkArrayBounds(jcasType.ll_cas.ll_getRefValue(addr, ((DocumentLine_Type)jcasType).casFeatCode_beginnings), i);
    return jcasType.ll_cas.ll_getFloatArrayValue(jcasType.ll_cas.ll_getRefValue(addr, ((DocumentLine_Type)jcasType).casFeatCode_beginnings), i);}
774248
def _getPhrase( self, i, sentence, NPlabels ):
        ''' 
        ''' 
        phrase  = []
        indices = []
        if 0 <= i and i < len(sentence) and NPlabels[i] == 'B':
            phrase  = [ sentence[i] ]
            indices = [ i ]
            j = i + 1
            while ( j < len(sentence) ):
                if NPlabels[j] in ['B', '']:
                    break
                else:
                    phrase.append( sentence[j] )
                    indices.append( j )
                j += 1
        return phrase, indices
501734
@Override
	public String getParagraphs(int min, int max) {
		int count = getCount(min, max);
		StringBuilder sb = new StringBuilder();
		for (int j = 0; j < count; j++) {
			int sentences = random.nextInt(5) + 2; // 2 to 6
			for (int i = 0; i < sentences; i++) {
				String first = getWords(1, 1, false);
				first = first.substring(0, 1).toUpperCase()
						+ first.substring(1);
				sb.append(first);

				sb.append(getWords(2, 20, false));
				sb.append(".  ");
			}
			sb.append("\n");
		}
		return sb.toString().trim();
	}
340983
def _begins_with_one_of(sentence, parts_of_speech):
    """"""
    doc = nlp(sentence)
    if doc[0].tag_ in parts_of_speech:
        return True
    return False
766613
public int getScannerStart( int p )
  {
    Element elem = getDefaultRootElement();
    int lineNum = elem.getElementIndex( p );
    Element line = elem.getElement( lineNum );
    AttributeSet a = line.getAttributes();
    while( a.isDefined( CommentAttribute ) && lineNum > 0 )
    {
      lineNum -= 1;
      line = elem.getElement( lineNum );
      a = line.getAttributes();
    }
    return line.getStartOffset();
  }
1010771
protected int getStartArgNo(final ParsedLine line) {
		// コード補完する引数の番号を特定。
		if (line.wordIndex() >= 1) {
			return commands.stream().filter(c -> c.is(line.words().get(0)))
					.mapToInt(c -> c.getStartArgNo(this.getClass())).findFirst().orElse(-1);
		} else {
			return -1;
		}
	}
707426
@Override
    public String getReasonPhrase() {
        if (null == this.myReason) {
            this.myReason = GenericUtils.getEnglishString(getReasonPhraseBytes());
        }
        return this.myReason;
    }
1101231
def get_sentence(start=None, depth=7):
    '''  '''
    if not GRAMMAR:
        return 'Please set a GRAMMAR file'

    start = start if start else GRAMMAR.start()

    if isinstance(start, Nonterminal):
        productions = GRAMMAR.productions(start)
        if not depth:
            # time to break the cycle
            terminals = [p for p in productions if not isinstance(start, Nonterminal)]
            if len(terminals):
                production = terminals
        production = random.choice(productions)

        sentence = []
        for piece in production.rhs():
            sentence += get_sentence(start=piece, depth=depth-1)
        return sentence
    else:
        return [start]
506304
@Override
    public int first() {
        fCachedBreakPositions = null;
        fDictionaryCharCount = 0;
        fPositionInCache = 0;
        fLastRuleStatusIndex  = 0;
        fLastStatusIndexValid = true;
        if (fText == null) {
            return BreakIterator.DONE;
        }
        fText.first();
        return fText.getIndex();
    }