def __init__(<EOL>self,<EOL>corpus_text='<STR_LIT>',<EOL>doc_split='<STR_LIT>',<EOL>sent_split='<STR_LIT:\n>',<EOL>filter_chars='<STR_LIT>',<EOL>stop_words=None,<EOL>):
self.corpus = []<EOL>self.doc_split = doc_split<EOL>self.sent_split = sent_split<EOL>for document in corpus_text.split(doc_split):<EOL><INDENT>doc = []<EOL>for sentence in (s.split() for s in document.split(sent_split)):<EOL><INDENT>if stop_words:<EOL><INDENT>for word in set(stop_words):<EOL><INDENT>while word in sentence:<EOL><INDENT>sentence.remove(word)<EOL><DEDENT><DEDENT><DEDENT>for char in set(filter_chars):<EOL><INDENT>sentence = [word.replace(char, '<STR_LIT>') for word in sentence]<EOL><DEDENT>if sentence:<EOL><INDENT>doc.append(sentence)<EOL><DEDENT><DEDENT>if doc:<EOL><INDENT>self.corpus.append(doc)<EOL><DEDENT><DEDENT>
r"""Initialize Corpus.

        By default, when importing a corpus:
            - two consecutive newlines divide documents
            - single newlines divide sentences
            - other whitespace divides words

        Parameters
        ----------
        corpus_text : str
            The corpus text as a single string
        doc_split : str
            A character or string used to split corpus_text into documents
        sent_split : str
            A character or string used to split documents into sentences
        filter_chars : list
            A list of characters (as a string, tuple, set, or list) to filter
            out of the corpus text
        stop_words : list
            A list of words (as a tuple, set, or list) to filter out of the
            corpus text

        Example
        -------
        >>> tqbf = 'The quick brown fox jumped over the lazy dog.\n'
        >>> tqbf += 'And then it slept.\n And the dog ran off.'
        >>> corp = Corpus(tqbf)