Split sentences for formatting.
775621
def split_sentences(s, pad=0):
    
    sentences = []
    for index, sentence in enumerate(s.split('. ')):
        padding = ''
        if index > 0:
            padding = ' ' * (pad + 1)
        if sentence.endswith('.'):
            sentence = sentence[:-1]
        sentences.append('%s %s.' % (padding, sentence.strip()))
    return "\n".join(sentences)
1181479
def scrub_sentence(sentence)
    sentence.split(/([\s]|--)+/).collect {|a| scrub_word(a)}.select {|a| a.length>0}
  end
858350
def _tokenize(self, text):
        
        sentences = []
        tokens = []
        for word in self._clean_accents(text).split(' '):
            tokens.append(word)
            if '.' in word:
                sentences.append(tokens)
                tokens = []
        return sentences
774071
def _mangle_sentences_from_file(input_file):
    """"""
    try:
        with open(input_file, 'r') as f:
            # final sentence may not be a complete sentence, save and prepend to next chunk
            leftovers = ''
            sentence_no = 0
            for chunk in read_in_chunks(f): # lazy way of reading our file in case it's large
                # prepend leftovers to chunk
                chunk = chunk.decode('utf8')
                chunk = leftovers + chunk
                chunk = chunk.replace(';', '.') # replace semi colons with periods 
                doc = nlp(chunk)

                # last sentence may not be sentence, move to next chunk
                sents = [sent.string.strip() for sent in doc.sents]
                if len(sents) > 1:
                    leftovers = sents[-1] + chunk.rpartition(sents[-1])[-1]
                    sents = sents[:-1]

                for sent in sents:
                    sent = sent.replace('\n', ' ')
                    sent = sent.replace('\r', ' ')
                    sent = re.sub( '\s+', ' ', sent ).strip()
                    if len(sent) < 5:
                        continue # skip tiny sentences
                    # add original sentence to database
                    cursor.execute('''insert into orignal_sentences (sentence,
                    flesch_reading_ease, flesch_kincaid_grade_level) values (?,
                    ?, ?)''', (sent, textstat.flesch_reading_ease(sent),
                        textstat.flesch_kincaid_grade(sent)))
                    og_sent_id = cursor.lastrowid
                    for mangled_sentence in mangle_agreement(sent):
                        # add mangled sentence to database
                        cursor.execute('''insert into mangled_sentences
                        (original_sentence_id, sentence) values (?, ?)''',
                        (og_sent_id, mangled_sentence))
                conn.commit() # commit all sentences in this chunk

    except Exception as e:
        print('error on {}'.format(input_file))
        print(e)
817839
def sentences(self):
        """"""
        sents = []
        spans = self.sentence_tokenizer.span_tokenize(self.text)
        for span in spans:
            sent = Sentence(
                text=self.text[span[0]:span[1]],
                start=span[0],
                end=span[1],
                word_tokenizer=self.word_tokenizer,
                lexicon=self.lexicon,
                abbreviation_detector=self.abbreviation_detector,
                pos_tagger=self.pos_tagger,
                ner_tagger=self.ner_tagger,
                parsers=self.parsers,
                document=self.document
            )
            sents.append(sent)
        return sents
1369217
def join_sentences(string1, string2, glue='.'):
    ""
    if not string1 or string1 == '':
        return string2
    if not string2 or string2 == '':
        return string1
    # both are strings, continue joining them together with the glue and whitespace
    new_string = string1.rstrip()
    if not new_string.endswith(glue):
        new_string += glue
    new_string += ' ' + string2.lstrip()
    return new_string
1085988
def split_focus(self):
        """"""

        focus = self.lines[self.focus]
        pos = focus.edit_pos
        edit = urwid.Edit("", focus.edit_text[pos:], allow_tab=True)
        edit.original_text = ""
        focus.set_edit_text(focus.edit_text[:pos])
        edit.set_edit_pos(0)
        self.lines.insert(self.focus + 1, edit)
672325
def split(self, text):
        """"""
        text = cleanup(text)
        return self.sent_detector.tokenize(text.strip())
44129
def split(self, sep=None, maxsplit=None, regex=False):
        """"""
        if maxsplit is not None:
            raise NotImplementedError('no maxsplit yet')
        s = self.s
        if sep is None:
            sep = r'\s+'
        elif not regex:
            sep = re.escape(sep)
        matches = list(re.finditer(sep, s))
        return [self[start:end] for start, end in zip(
            [0] + [m.end() for m in matches],
            [m.start() for m in matches] + [len(s)])]
1032237
def multi_split(txt, delims):
    
    res = [txt]
    for delimChar in delims:
        txt, res = res, []
        for word in txt:
            if len(word) > 1:
                res += word.split(delimChar)
    return res
733999
def split(self, sep=TOKENS):
        
        if sep != TOKENS:
            return unicode.split(self, sep)
        if len(self) == 0:
            return []
        return [[[x.replace("&slash;", "/") for x in token.split("/")]
            for token in sentence.split(" ")]
                for sentence in unicode.split(self, "\n")]
1358946
def tokenize_words(self, text):
        """"""
        return [
            self.strip_punctuation(word) for word in text.split(' ')
            if self.strip_punctuation(word)
        ]
1078129
def split_title(title, width, title_fs):
    """"""
    titles = []
    if not title:
        return titles
    size = reverse_text_len(width, title_fs * 1.1)
    title_lines = title.split("\n")
    for title_line in title_lines:
        while len(title_line) > size:
            title_part = title_line[:size]
            i = title_part.rfind(' ')
            if i == -1:
                i = len(title_part)
            titles.append(title_part[:i])
            title_line = title_line[i:].strip()
        titles.append(title_line)
    return titles
925931
def split_text(text: str, length: int = MAX_MESSAGE_LENGTH) -> typing.List[str]:
    
    return [text[i:i + length] for i in range(0, len(text), length)]
330820
def split(self):
        """"""
        key = '%s/split' % self.key
        return self._server.query(key, method=self._server._session.put)
1178571
def split_on(s, sep=" "):
    """"""
    pattern = '''((?:[^%s"']|"[^"]*"|'[^']*')+)''' % sep

    return [_strip_speechmarks(t) for t in re.split(pattern, s)[1::2]]
64120
public static List<String> splitSentence2(String text, SentenceDetector sd) {
        List<String> sentences = new ArrayList<String>();
        try {
            int sentenceOffsets[] = sd.sentPosDetect(text);

            int begin = 0;
            int end = 0;
            for (int i = 0; i < sentenceOffsets.length; i++) {
                end = begin
                        + (text.substring(begin, sentenceOffsets[i]).trim())
                                .length();
                sentences.add(text.substring(begin, end));
                begin = sentenceOffsets[i];
            }
        } catch (Exception e) {
            LOG.warn("failed to extract sentences from text '" + text + "'", e);
        }
        return sentences;
    }