def decode(self, code, terminator='<STR_LIT>'):

if code:<EOL><INDENT>if terminator not in code:<EOL><INDENT>raise ValueError(<EOL>'<STR_LIT>'.format(<EOL>terminator if terminator != '<STR_LIT>' else '<STR_LIT>'<EOL>)<EOL>)<EOL><DEDENT>else:<EOL><INDENT>wordlist = ['<STR_LIT>'] * len(code)<EOL>for i in range(len(code)):<EOL><INDENT>wordlist = sorted(<EOL>code[i] + wordlist[i] for i in range(len(code))<EOL>)<EOL><DEDENT>rows = [w for w in wordlist if w[-<NUM_LIT:1>] == terminator][<NUM_LIT:0>]<EOL>return rows.rstrip(terminator)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>return '<STR_LIT>'<EOL><DEDENT>

r"""Return a word decoded from BWT form.

        Parameters
        ----------
        code : str
            The word to transform from BWT form
        terminator : str
            A character added to signal the end of the string

        Returns
        -------
        str
            Word decoded by BWT

        Raises
        ------
        ValueError
            Specified terminator absent from code.

        Examples
        --------
        >>> bwt = BWT()
        >>> bwt.decode('n\x00ilag')
        'align'
        >>> bwt.decode('annb\x00aa')
        'banana'
        >>> bwt.decode('annb@aa', '@')
        'banana'


return BWT().encode(word, terminator)<EOL>

r"""Return the Burrows-Wheeler transformed form of a word.

    This is a wrapper for :py:meth:`BWT.encode`.

    Parameters
    ----------
    word : str
        The word to transform using BWT
    terminator : str
        A character added to signal the end of the string

    Returns
    -------
    str
        Word encoded by BWT

    Examples
    --------
    >>> bwt_encode('align')
    'n\x00ilag'
    >>> bwt_encode('banana')
    'annb\x00aa'
    >>> bwt_encode('banana', '@')
    'annb@aa'


text = RLE().decode(text)<EOL>if use_bwt:<EOL><INDENT>text = BWT().decode(text)<EOL><DEDENT>return text<EOL>

r"""Perform decoding of run-length-encoding (RLE).

    This is a wrapper for :py:meth:`RLE.decode`.

    Parameters
    ----------
    text : str
        A text string to decode
    use_bwt : bool
        Indicates whether to perform BWT decoding after RLE decoding

    Returns
    -------
    str
        Word decoded by RLE

    Examples
    --------
    >>> rle_decode('n\x00ilag')
    'align'
    >>> rle_decode('align', use_bwt=False)
    'align'

    >>> rle_decode('annb\x00aa')
    'banana'
    >>> rle_decode('banana', use_bwt=False)
    'banana'

    >>> rle_decode('ab\x00abbab5a')
    'aaabaabababa'
    >>> rle_decode('3abaabababa', False)
    'aaabaabababa'


val = Fraction(longval, long(<NUM_LIT:1>) << nbits)<EOL>letters = []<EOL>probs_items = [<EOL>(char, minval, maxval)<EOL>for (char, (minval, maxval)) in self._probs.items()<EOL>]<EOL>char = '<STR_LIT:\x00>'<EOL>while True:<EOL><INDENT>for (char, minval, maxval) in probs_items:  <EOL><INDENT>if minval <= val < maxval:<EOL><INDENT>break<EOL><DEDENT><DEDENT>if char == '<STR_LIT:\x00>':<EOL><INDENT>break<EOL><DEDENT>letters.append(char)<EOL>delta = maxval - minval<EOL>val = (val - minval) / delta<EOL><DEDENT>return '<STR_LIT>'.join(letters)<EOL>

Decode the number to a string using the given statistics.

        Parameters
        ----------
        longval : int
            The first part of an encoded tuple from encode
        nbits : int
            The second part of an encoded tuple from encode

        Returns
        -------
        str
            The arithmetically decoded text

        Example
        -------
        >>> ac = Arithmetic('the quick brown fox jumped over the lazy dog')
        >>> ac.decode(16720586181, 34)
        'align'


text = text_type(text)<EOL>if '<STR_LIT:\x00>' in text:<EOL><INDENT>text = text.replace('<STR_LIT:\x00>', '<STR_LIT:U+0020>')<EOL><DEDENT>minval = Fraction(<NUM_LIT:0>)<EOL>maxval = Fraction(<NUM_LIT:1>)<EOL>for char in text + '<STR_LIT:\x00>':<EOL><INDENT>prob_range = self._probs[char]<EOL>delta = maxval - minval<EOL>maxval = minval + prob_range[<NUM_LIT:1>] * delta<EOL>minval = minval + prob_range[<NUM_LIT:0>] * delta<EOL><DEDENT>delta = (maxval - minval) / <NUM_LIT:2><EOL>nbits = long(<NUM_LIT:0>)<EOL>while delta < <NUM_LIT:1>:<EOL><INDENT>nbits += <NUM_LIT:1><EOL>delta *= <NUM_LIT:2><EOL><DEDENT>if nbits == <NUM_LIT:0>:  <EOL><INDENT>return <NUM_LIT:0>, <NUM_LIT:0><EOL><DEDENT>avg = (maxval + minval) * <NUM_LIT:2> ** (nbits - <NUM_LIT:1>)<EOL>return avg.numerator // avg.denominator, nbits<EOL>

Encode a text using arithmetic coding.

        Text and the 0-order probability statistics -> longval, nbits

        The encoded number is Fraction(longval, 2**nbits)

        Parameters
        ----------
        text : str
            A string to encode

        Returns
        -------
        tuple
            The arithmetically coded text

        Example
        -------
        >>> ac = Arithmetic('the quick brown fox jumped over the lazy dog')
        >>> ac.encode('align')
        (16720586181, 34)


coder = Arithmetic()<EOL>coder.set_probs(probs)<EOL>return coder.encode(text)<EOL>

Encode a text using arithmetic coding with the provided probabilities.

    This is a wrapper for :py:meth:`Arithmetic.encode`.

    Parameters
    ----------
    text : str
        A string to encode
    probs : dict
        A probability statistics dictionary generated by
        :py:meth:`Arithmetic.train`

    Returns
    -------
    tuple
        The arithmetically coded text

    Example
    -------
    >>> pr = ac_train('the quick brown fox jumped over the lazy dog')
    >>> ac_encode('align', pr)
    (16720586181, 34)


text = text_type(text)<EOL>if '<STR_LIT:\x00>' in text:<EOL><INDENT>text = text.replace('<STR_LIT:\x00>', '<STR_LIT:U+0020>')<EOL><DEDENT>counts = Counter(text)<EOL>counts['<STR_LIT:\x00>'] = <NUM_LIT:1><EOL>tot_letters = sum(counts.values())<EOL>tot = <NUM_LIT:0><EOL>self._probs = {}<EOL>prev = Fraction(<NUM_LIT:0>)<EOL>for char, count in sorted(<EOL>counts.items(), key=lambda x: (x[<NUM_LIT:1>], x[<NUM_LIT:0>]), reverse=True<EOL>):<EOL><INDENT>follow = Fraction(tot + count, tot_letters)<EOL>self._probs[char] = (prev, follow)<EOL>prev = follow<EOL>tot = tot + count<EOL><DEDENT>

r"""Generate a probability dict from the provided text.

        Text to 0-order probability statistics as a dict

        Parameters
        ----------
        text : str
            The text data over which to calculate probability statistics. This
            must not contain the NUL (0x00) character because that is used to
            indicate the end of data.

        Example
        -------
        >>> ac = Arithmetic()
        >>> ac.train('the quick brown fox jumped over the lazy dog')
        >>> ac.get_probs()
        {' ': (Fraction(0, 1), Fraction(8, 45)),
         'o': (Fraction(8, 45), Fraction(4, 15)),
         'e': (Fraction(4, 15), Fraction(16, 45)),
         'u': (Fraction(16, 45), Fraction(2, 5)),
         't': (Fraction(2, 5), Fraction(4, 9)),
         'r': (Fraction(4, 9), Fraction(22, 45)),
         'h': (Fraction(22, 45), Fraction(8, 15)),
         'd': (Fraction(8, 15), Fraction(26, 45)),
         'z': (Fraction(26, 45), Fraction(3, 5)),
         'y': (Fraction(3, 5), Fraction(28, 45)),
         'x': (Fraction(28, 45), Fraction(29, 45)),
         'w': (Fraction(29, 45), Fraction(2, 3)),
         'v': (Fraction(2, 3), Fraction(31, 45)),
         'q': (Fraction(31, 45), Fraction(32, 45)),
         'p': (Fraction(32, 45), Fraction(11, 15)),
         'n': (Fraction(11, 15), Fraction(34, 45)),
         'm': (Fraction(34, 45), Fraction(7, 9)),
         'l': (Fraction(7, 9), Fraction(4, 5)),
         'k': (Fraction(4, 5), Fraction(37, 45)),
         'j': (Fraction(37, 45), Fraction(38, 45)),
         'i': (Fraction(38, 45), Fraction(13, 15)),
         'g': (Fraction(13, 15), Fraction(8, 9)),
         'f': (Fraction(8, 9), Fraction(41, 45)),
         'c': (Fraction(41, 45), Fraction(14, 15)),
         'b': (Fraction(14, 15), Fraction(43, 45)),
         'a': (Fraction(43, 45), Fraction(44, 45)),
         '\x00': (Fraction(44, 45), Fraction(1, 1))}


<EOL>if feature not in _FEATURE_MASK:<EOL><INDENT>raise AttributeError(<EOL>"<STR_LIT>"<EOL>+ "<STR_LIT>".join(<EOL>(<EOL>'<STR_LIT>',<EOL>'<STR_LIT>',<EOL>'<STR_LIT>',<EOL>'<STR_LIT>',<EOL>'<STR_LIT>',<EOL>'<STR_LIT>',<EOL>'<STR_LIT>',<EOL>'<STR_LIT>',<EOL>'<STR_LIT>',<EOL>'<STR_LIT>',<EOL>'<STR_LIT>',<EOL>'<STR_LIT>',<EOL>'<STR_LIT>',<EOL>'<STR_LIT>',<EOL>'<STR_LIT>',<EOL>'<STR_LIT>',<EOL>'<STR_LIT>',<EOL>'<STR_LIT>',<EOL>'<STR_LIT>',<EOL>'<STR_LIT>',<EOL>'<STR_LIT>',<EOL>'<STR_LIT>',<EOL>'<STR_LIT>',<EOL>)<EOL>)<EOL>+ "<STR_LIT:'>"<EOL>)<EOL><DEDENT>mask = _FEATURE_MASK[feature]<EOL>pos_mask = mask >> <NUM_LIT:1><EOL>retvec = []<EOL>for char in vector:<EOL><INDENT>if char < <NUM_LIT:0>:<EOL><INDENT>retvec.append(float('<STR_LIT>'))<EOL><DEDENT>else:<EOL><INDENT>masked = char & mask<EOL>if masked == <NUM_LIT:0>:<EOL><INDENT>retvec.append(<NUM_LIT:0>)  <EOL><DEDENT>elif masked == mask:<EOL><INDENT>retvec.append(<NUM_LIT:2>)  <EOL><DEDENT>elif masked & pos_mask:<EOL><INDENT>retvec.append(<NUM_LIT:1>)  <EOL><DEDENT>else:<EOL><INDENT>retvec.append(-<NUM_LIT:1>)  <EOL><DEDENT><DEDENT><DEDENT>return retvec<EOL>

Get a feature vector.

    This returns a list of ints, equal in length to the vector input,
        representing presence/absence/neutrality with respect to a particular
        phonetic feature.

    Parameters
    ----------
    vector : list
        A tuple or list of ints representing the phonetic features of a phone
        or series of phones (such as is returned by the ipa_to_features
        function)
    feature : str
        A feature name from the set:

            - ``consonantal``
            - ``sonorant``
            - ``syllabic``
            - ``labial``
            - ``round``
            - ``coronal``
            - ``anterior``
            - ``distributed``
            - ``dorsal``
            - ``high``
            - ``low``
            - ``back``
            - ``tense``
            - ``pharyngeal``
            - ``ATR``
            - ``voice``
            - ``spread_glottis``
            - ``constricted_glottis``
            - ``continuant``
            - ``strident``
            - ``lateral``
            - ``delayed_release``
            - ``nasal``

    Returns
    -------
    list of ints
        A list indicating presence/absence/neutrality with respect to the
        feature

    Raises
    ------
    AttributeError
        feature must be one of ...

    Examples
    --------
    >>> tails = ipa_to_features('telz')
    >>> get_feature(tails, 'consonantal')
    [1, -1, 1, 1]
    >>> get_feature(tails, 'sonorant')
    [-1, 1, 1, -1]
    >>> get_feature(tails, 'nasal')
    [-1, -1, -1, -1]
    >>> get_feature(tails, 'coronal')
    [1, -1, 1, 1]


def corpus_importer(self, corpus, n_val=<NUM_LIT:1>, bos='<STR_LIT>', eos='<STR_LIT>'):

if not corpus or not isinstance(corpus, Corpus):<EOL><INDENT>raise TypeError('<STR_LIT>')<EOL><DEDENT>sentences = corpus.sents()<EOL>for sent in sentences:<EOL><INDENT>ngs = Counter(sent)<EOL>for key in ngs.keys():<EOL><INDENT>self._add_to_ngcorpus(self.ngcorpus, [key], ngs[key])<EOL><DEDENT>if n_val > <NUM_LIT:1>:<EOL><INDENT>if bos and bos != '<STR_LIT>':<EOL><INDENT>sent = [bos] + sent<EOL><DEDENT>if eos and eos != '<STR_LIT>':<EOL><INDENT>sent += [eos]<EOL><DEDENT>for i in range(<NUM_LIT:2>, n_val + <NUM_LIT:1>):<EOL><INDENT>for j in range(len(sent) - i + <NUM_LIT:1>):<EOL><INDENT>self._add_to_ngcorpus(<EOL>self.ngcorpus, sent[j : j + i], <NUM_LIT:1><EOL>)<EOL><DEDENT><DEDENT><DEDENT><DEDENT>

r"""Fill in self.ngcorpus from a Corpus argument.

        Parameters
        ----------
        corpus :Corpus
            The Corpus from which to initialize the n-gram corpus
        n_val : int
            Maximum n value for n-grams
        bos : str
            String to insert as an indicator of beginning of sentence
        eos : str
            String to insert as an indicator of end of sentence

        Raises
        ------
        TypeError
            Corpus argument of the Corpus class required.

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


if '<STR_LIT:U+0020>' in term:<EOL><INDENT>raise ValueError(<EOL>'<STR_LIT>'<EOL>)<EOL><DEDENT>tcount = self.get_count(term)<EOL>if tcount == <NUM_LIT:0>:<EOL><INDENT>return <NUM_LIT:0.0><EOL><DEDENT>return <NUM_LIT:1> + log10(tcount)<EOL>

r"""Return term frequency.

        Parameters
        ----------
        term : str
            The term for which to calculate tf

        Returns
        -------
        float
            The term frequency (tf)

        Raises
        ------
        ValueError
            tf can only calculate the frequency of individual words

        Examples
        --------
        >>> tqbf = 'The quick brown fox jumped over the lazy dog.\n'
        >>> tqbf += 'And then it slept.\n And the dog ran off.'
        >>> ngcorp = NGramCorpus(Corpus(tqbf))
        >>> NGramCorpus(Corpus(tqbf)).tf('the')
        1.3010299956639813
        >>> NGramCorpus(Corpus(tqbf)).tf('fox')
        1.0


def get_count(self, ngram, corpus=None):

if not corpus:<EOL><INDENT>corpus = self.ngcorpus<EOL><DEDENT>if not ngram:<EOL><INDENT>return corpus[None]<EOL><DEDENT>if isinstance(ngram, (text_type, str)):<EOL><INDENT>ngram = text_type(ngram).split()<EOL><DEDENT>if ngram[<NUM_LIT:0>] in corpus:<EOL><INDENT>return self.get_count(ngram[<NUM_LIT:1>:], corpus[ngram[<NUM_LIT:0>]])<EOL><DEDENT>return <NUM_LIT:0><EOL>

r"""Get the count of an n-gram in the corpus.

        Parameters
        ----------
        ngram : str
            The n-gram to retrieve the count of from the n-gram corpus
        corpus : Corpus
            The corpus

        Returns
        -------
        int
            The n-gram count

        Examples
        --------
        >>> tqbf = 'The quick brown fox jumped over the lazy dog.\n'
        >>> tqbf += 'And then it slept.\n And the dog ran off.'
        >>> ngcorp = NGramCorpus(Corpus(tqbf))
        >>> NGramCorpus(Corpus(tqbf)).get_count('the')
        2
        >>> NGramCorpus(Corpus(tqbf)).get_count('fox')
        1


return [<EOL>[words for sents in doc for words in sents] for doc in self.corpus<EOL>]<EOL>

r"""Return the docs in the corpus, with sentences flattened.

        Each list within the corpus represents all the words of that document.
        Thus the sentence level of lists has been flattened.

        Returns
        -------
        [[str]]
            The docs in the corpus as a list of list of strs

        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)
        >>> corp.docs_of_words()
        [['The', 'quick', 'brown', 'fox', 'jumped', 'over', 'the', 'lazy',
        'dog.', 'And', 'then', 'it', 'slept.', 'And', 'the', 'dog', 'ran',
        'off.']]
        >>> len(corp.docs_of_words())
        1


docs_with_term = <NUM_LIT:0><EOL>docs = self.docs_of_words()<EOL>for doc in docs:<EOL><INDENT>doc_set = set(doc)<EOL>if transform:<EOL><INDENT>transformed_doc = []<EOL>for word in doc_set:<EOL><INDENT>transformed_doc.append(transform(word))<EOL><DEDENT>doc_set = set(transformed_doc)<EOL><DEDENT>if term in doc_set:<EOL><INDENT>docs_with_term += <NUM_LIT:1><EOL><DEDENT><DEDENT>if docs_with_term == <NUM_LIT:0>:<EOL><INDENT>return float('<STR_LIT>')<EOL><DEDENT>return log10(len(docs) / docs_with_term)<EOL>

r"""Calculate the Inverse Document Frequency of a term in the corpus.

        Parameters
        ----------
        term : str
            The term to calculate the IDF of
        transform : function
            A function to apply to each document term before checking for the
            presence of term

        Returns
        -------
        float
            The IDF

        Examples
        --------
        >>> tqbf = 'The quick brown fox jumped over the lazy dog.\n\n'
        >>> tqbf += 'And then it slept.\n\n And the dog ran off.'
        >>> corp = Corpus(tqbf)
        >>> print(corp.docs())
        [[['The', 'quick', 'brown', 'fox', 'jumped', 'over', 'the', 'lazy',
        'dog.']],
        [['And', 'then', 'it', 'slept.']],
        [['And', 'the', 'dog', 'ran', 'off.']]]
        >>> round(corp.idf('dog'), 10)
        0.4771212547
        >>> round(corp.idf('the'), 10)
        0.1760912591


return [words for sents in self.corpus for words in sents]<EOL>

r"""Return the sentences in the corpus.

        Each list within a sentence represents the words within that sentence.

        Returns
        -------
        [[str]]
            The sentences in the corpus as a list of lists of strs

        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)
        >>> corp.sents()
        [['The', 'quick', 'brown', 'fox', 'jumped', 'over', 'the', 'lazy',
        'dog.'], ['And', 'then', 'it', 'slept.'], ['And', 'the', 'dog',
        'ran', 'off.']]
        >>> len(corp.sents())
        3


return self.docs()<EOL>

r"""Return the paragraphs in the corpus.

        Each list within a paragraph represents the sentences in that doc, each
        of which is in turn a list of words within that sentence.
        This is identical to the docs() member function and exists only to
        mirror part of NLTK's API for corpora.

        Returns
        -------
        [[[str]]]
            The paragraphs in the corpus as a list of lists of lists of strs

        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)
        >>> corp.paras()
        [[['The', 'quick', 'brown', 'fox', 'jumped', 'over', 'the', 'lazy',
        'dog.'], ['And', 'then', 'it', 'slept.'], ['And', 'the', 'dog',
        'ran', 'off.']]]
        >>> len(corp.paras())
        1


return [words for sents in self.sents() for words in sents]<EOL>

r"""Return the words in the corpus as a single list.

        Returns
        -------
        [str]
            The words in the corpus as a list of strs

        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)
        >>> corp.words()
        ['The', 'quick', 'brown', 'fox', 'jumped', 'over', 'the', 'lazy',
        'dog.', 'And', 'then', 'it', 'slept.', 'And', 'the', 'dog', 'ran',
        'off.']
        >>> len(corp.words())
        18


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)


lowered = word.lower()<EOL>if lowered[-<NUM_LIT:3>:] == '<STR_LIT>' and lowered[-<NUM_LIT:4>:-<NUM_LIT:3>] not in {'<STR_LIT:e>', '<STR_LIT:a>'}:<EOL><INDENT>return word[:-<NUM_LIT:3>] + ('<STR_LIT:Y>' if word[-<NUM_LIT:1>:].isupper() else '<STR_LIT:y>')<EOL><DEDENT>if lowered[-<NUM_LIT:2>:] == '<STR_LIT>' and lowered[-<NUM_LIT:3>:-<NUM_LIT:2>] not in {'<STR_LIT:a>', '<STR_LIT:e>', '<STR_LIT:o>'}:<EOL><INDENT>return word[:-<NUM_LIT:1>]<EOL><DEDENT>if lowered[-<NUM_LIT:1>:] == '<STR_LIT:s>' and lowered[-<NUM_LIT:2>:-<NUM_LIT:1>] not in {'<STR_LIT:u>', '<STR_LIT:s>'}:<EOL><INDENT>return word[:-<NUM_LIT:1>]<EOL><DEDENT>return word<EOL>

Return the S-stemmed form of a word.

        Parameters
        ----------
        word : str
            The word to stem

        Returns
        -------
        str
            Word stem

        Examples
        --------
        >>> stmr = SStemmer()
        >>> stmr.stem('summaries')
        'summary'
        >>> stmr.stem('summary')
        'summary'
        >>> stmr.stem('towers')
        'tower'
        >>> stmr.stem('reading')
        'reading'
        >>> stmr.stem('census')
        'census'


return UEALite().stem(<EOL>word, max_word_length, max_acro_length, return_rule_no, var<EOL>)<EOL>

Return UEA-Lite stem.

    This is a wrapper for :py:meth:`UEALite.stem`.

    Parameters
    ----------
    word : str
        The word to stem
    max_word_length : int
        The maximum word length allowed
    max_acro_length : int
        The maximum acronym length allowed
    return_rule_no : bool
        If True, returns the stem along with rule number
    var : str
        Variant rules to use:

            - ``Adams`` to use Jason Adams' rules
            - ``Perl`` to use the original Perl rules

    Returns
    -------
    str or (str, int)
        Word stem

    Examples
    --------
    >>> uealite('readings')
    'read'
    >>> uealite('insulted')
    'insult'
    >>> uealite('cussed')
    'cuss'
    >>> uealite('fancies')
    'fancy'
    >>> uealite('eroded')
    'erode'


def stem(self, word, alternate_vowels=False):

<EOL>word = normalize('<STR_LIT>', word.lower())<EOL>word = word.replace('<STR_LIT>', '<STR_LIT>')<EOL>if len(word) > <NUM_LIT:2>:<EOL><INDENT>for i in range(<NUM_LIT:2>, len(word)):<EOL><INDENT>if word[i] in self._vowels and word[i - <NUM_LIT:2>] in self._vowels:<EOL><INDENT>if word[i - <NUM_LIT:1>] == '<STR_LIT:u>':<EOL><INDENT>word = word[: i - <NUM_LIT:1>] + '<STR_LIT>' + word[i:]<EOL><DEDENT>elif word[i - <NUM_LIT:1>] == '<STR_LIT:y>':<EOL><INDENT>word = word[: i - <NUM_LIT:1>] + '<STR_LIT:Y>' + word[i:]<EOL><DEDENT><DEDENT><DEDENT><DEDENT>if alternate_vowels:<EOL><INDENT>word = word.replace('<STR_LIT>', '<STR_LIT>')<EOL>word = word.replace('<STR_LIT>', '<STR_LIT>')<EOL>word = word.replace('<STR_LIT>', '<STR_LIT>')<EOL>word = word.replace('<STR_LIT>', '<STR_LIT>')<EOL>word = word.replace('<STR_LIT>', '<STR_LIT>')<EOL><DEDENT>r1_start = max(<NUM_LIT:3>, self._sb_r1(word))<EOL>r2_start = self._sb_r2(word)<EOL>niss_flag = False<EOL>if word[-<NUM_LIT:3>:] == '<STR_LIT>':<EOL><INDENT>if len(word[r1_start:]) >= <NUM_LIT:3>:<EOL><INDENT>word = word[:-<NUM_LIT:3>]<EOL><DEDENT><DEDENT>elif word[-<NUM_LIT:2>:] == '<STR_LIT>':<EOL><INDENT>if len(word[r1_start:]) >= <NUM_LIT:2>:<EOL><INDENT>word = word[:-<NUM_LIT:2>]<EOL><DEDENT><DEDENT>elif word[-<NUM_LIT:2>:] == '<STR_LIT>':<EOL><INDENT>if len(word[r1_start:]) >= <NUM_LIT:2>:<EOL><INDENT>word = word[:-<NUM_LIT:2>]<EOL><DEDENT><DEDENT>elif word[-<NUM_LIT:2>:] == '<STR_LIT>':<EOL><INDENT>if len(word[r1_start:]) >= <NUM_LIT:2>:<EOL><INDENT>word = word[:-<NUM_LIT:2>]<EOL>niss_flag = True<EOL><DEDENT><DEDENT>elif word[-<NUM_LIT:2>:] == '<STR_LIT>':<EOL><INDENT>if len(word[r1_start:]) >= <NUM_LIT:2>:<EOL><INDENT>word = word[:-<NUM_LIT:2>]<EOL>niss_flag = True<EOL><DEDENT><DEDENT>elif word[-<NUM_LIT:1>:] == '<STR_LIT:e>':<EOL><INDENT>if len(word[r1_start:]) >= <NUM_LIT:1>:<EOL><INDENT>word = word[:-<NUM_LIT:1>]<EOL>niss_flag = True<EOL><DEDENT><DEDENT>elif word[-<NUM_LIT:1>:] == '<STR_LIT:s>':<EOL><INDENT>if (<EOL>len(word[r1_start:]) >= <NUM_LIT:1><EOL>and len(word) >= <NUM_LIT:2><EOL>and word[-<NUM_LIT:2>] in self._s_endings<EOL>):<EOL><INDENT>word = word[:-<NUM_LIT:1>]<EOL><DEDENT><DEDENT>if niss_flag and word[-<NUM_LIT:4>:] == '<STR_LIT>':<EOL><INDENT>word = word[:-<NUM_LIT:1>]<EOL><DEDENT>if word[-<NUM_LIT:3>:] == '<STR_LIT>':<EOL><INDENT>if len(word[r1_start:]) >= <NUM_LIT:3>:<EOL><INDENT>word = word[:-<NUM_LIT:3>]<EOL><DEDENT><DEDENT>elif word[-<NUM_LIT:2>:] == '<STR_LIT>':<EOL><INDENT>if len(word[r1_start:]) >= <NUM_LIT:2>:<EOL><INDENT>word = word[:-<NUM_LIT:2>]<EOL><DEDENT><DEDENT>elif word[-<NUM_LIT:2>:] == '<STR_LIT>':<EOL><INDENT>if len(word[r1_start:]) >= <NUM_LIT:2>:<EOL><INDENT>word = word[:-<NUM_LIT:2>]<EOL><DEDENT><DEDENT>elif word[-<NUM_LIT:2>:] == '<STR_LIT>':<EOL><INDENT>if (<EOL>len(word[r1_start:]) >= <NUM_LIT:2><EOL>and len(word) >= <NUM_LIT:6><EOL>and word[-<NUM_LIT:3>] in self._st_endings<EOL>):<EOL><INDENT>word = word[:-<NUM_LIT:2>]<EOL><DEDENT><DEDENT>if word[-<NUM_LIT:4>:] == '<STR_LIT>':<EOL><INDENT>if len(word[r2_start:]) >= <NUM_LIT:4> and word[-<NUM_LIT:5>] != '<STR_LIT:e>':<EOL><INDENT>word = word[:-<NUM_LIT:4>]<EOL><DEDENT><DEDENT>elif word[-<NUM_LIT:4>:] in {'<STR_LIT>', '<STR_LIT>'}:<EOL><INDENT>if len(word[r2_start:]) >= <NUM_LIT:4>:<EOL><INDENT>word = word[:-<NUM_LIT:4>]<EOL>if word[-<NUM_LIT:2>:] in {'<STR_LIT>', '<STR_LIT>'} and len(word[r1_start:]) >= <NUM_LIT:2>:<EOL><INDENT>word = word[:-<NUM_LIT:2>]<EOL><DEDENT><DEDENT><DEDENT>elif word[-<NUM_LIT:4>:] == '<STR_LIT>':<EOL><INDENT>if len(word[r2_start:]) >= <NUM_LIT:4>:<EOL><INDENT>word = word[:-<NUM_LIT:4>]<EOL>if word[-<NUM_LIT:4>:] == '<STR_LIT>' and len(word[r2_start:]) >= <NUM_LIT:4>:<EOL><INDENT>word = word[:-<NUM_LIT:4>]<EOL><DEDENT>elif word[-<NUM_LIT:2>:] == '<STR_LIT>' and len(word[r2_start:]) >= <NUM_LIT:2>:<EOL><INDENT>word = word[:-<NUM_LIT:2>]<EOL><DEDENT><DEDENT><DEDENT>elif word[-<NUM_LIT:3>:] in {'<STR_LIT:end>', '<STR_LIT>'}:<EOL><INDENT>if len(word[r2_start:]) >= <NUM_LIT:3>:<EOL><INDENT>word = word[:-<NUM_LIT:3>]<EOL>if (<EOL>word[-<NUM_LIT:2>:] == '<STR_LIT>'<EOL>and len(word[r2_start:]) >= <NUM_LIT:2><EOL>and word[-<NUM_LIT:3>] != '<STR_LIT:e>'<EOL>):<EOL><INDENT>word = word[:-<NUM_LIT:2>]<EOL><DEDENT><DEDENT><DEDENT>elif word[-<NUM_LIT:2>:] in {'<STR_LIT>', '<STR_LIT>'}:<EOL><INDENT>if len(word[r2_start:]) >= <NUM_LIT:2> and word[-<NUM_LIT:3>] != '<STR_LIT:e>':<EOL><INDENT>word = word[:-<NUM_LIT:2>]<EOL><DEDENT><DEDENT>for i in range(<NUM_LIT:0>, len(word)):<EOL><INDENT>if word[i] == '<STR_LIT:Y>':<EOL><INDENT>word = word[:i] + '<STR_LIT:y>' + word[i + <NUM_LIT:1> :]<EOL><DEDENT>elif word[i] == '<STR_LIT>':<EOL><INDENT>word = word[:i] + '<STR_LIT:u>' + word[i + <NUM_LIT:1> :]<EOL><DEDENT><DEDENT>_umlauts = dict(zip((ord(_) for _ in '<STR_LIT>'), '<STR_LIT>'))<EOL>word = word.translate(_umlauts)<EOL>return word<EOL>

Return Snowball German stem.

        Parameters
        ----------
        word : str
            The word to stem
        alternate_vowels : bool
            Composes ae as ä, oe as ö, and ue as ü before running the algorithm

        Returns
        -------
        str
            Word stem

        Examples
        --------
        >>> stmr = SnowballGerman()
        >>> stmr.stem('lesen')
        'les'
        >>> stmr.stem('graues')
        'grau'
        >>> stmr.stem('buchstabieren')
        'buchstabi'


if (<EOL>len(word) > <NUM_LIT:1><EOL>and word[-<NUM_LIT:1>] == word[-<NUM_LIT:2>]<EOL>and word[-<NUM_LIT:1>] in {'<STR_LIT:d>', '<STR_LIT:k>', '<STR_LIT:t>'}<EOL>):<EOL><INDENT>return word[:-<NUM_LIT:1>]<EOL><DEDENT>return word<EOL>

Undouble endings -kk, -dd, and -tt.

        Parameters
        ----------
        word : str
          The word to stem

        Returns
        -------
        str
            The word with doubled endings undoubled


<EOL>word = normalize('<STR_LIT>', text_type(word.lower()))<EOL>word = word.translate(self._accented)<EOL>for i in range(len(word)):<EOL><INDENT>if i == <NUM_LIT:0> and word[<NUM_LIT:0>] == '<STR_LIT:y>':<EOL><INDENT>word = '<STR_LIT:Y>' + word[<NUM_LIT:1>:]<EOL><DEDENT>elif word[i] == '<STR_LIT:y>' and word[i - <NUM_LIT:1>] in self._vowels:<EOL><INDENT>word = word[:i] + '<STR_LIT:Y>' + word[i + <NUM_LIT:1> :]<EOL><DEDENT>elif (<EOL>word[i] == '<STR_LIT:i>'<EOL>and word[i - <NUM_LIT:1>] in self._vowels<EOL>and i + <NUM_LIT:1> < len(word)<EOL>and word[i + <NUM_LIT:1>] in self._vowels<EOL>):<EOL><INDENT>word = word[:i] + '<STR_LIT:I>' + word[i + <NUM_LIT:1> :]<EOL><DEDENT><DEDENT>r1_start = max(<NUM_LIT:3>, self._sb_r1(word))<EOL>r2_start = self._sb_r2(word)<EOL>if word[-<NUM_LIT:5>:] == '<STR_LIT>':<EOL><INDENT>if len(word[r1_start:]) >= <NUM_LIT:5>:<EOL><INDENT>word = word[:-<NUM_LIT:3>] + '<STR_LIT:id>'<EOL><DEDENT><DEDENT>elif word[-<NUM_LIT:3>:] == '<STR_LIT>':<EOL><INDENT>if len(word[r1_start:]) >= <NUM_LIT:3> and (<EOL>word[-<NUM_LIT:4>] not in self._vowels and word[-<NUM_LIT:6>:-<NUM_LIT:3>] != '<STR_LIT>'<EOL>):<EOL><INDENT>word = self._undouble(word[:-<NUM_LIT:3>])<EOL><DEDENT><DEDENT>elif word[-<NUM_LIT:2>:] == '<STR_LIT>':<EOL><INDENT>if len(word[r1_start:]) >= <NUM_LIT:2> and (<EOL>word[-<NUM_LIT:3>] not in self._vowels and word[-<NUM_LIT:5>:-<NUM_LIT:2>] != '<STR_LIT>'<EOL>):<EOL><INDENT>word = self._undouble(word[:-<NUM_LIT:2>])<EOL><DEDENT><DEDENT>elif word[-<NUM_LIT:2>:] == '<STR_LIT>':<EOL><INDENT>if (<EOL>len(word[r1_start:]) >= <NUM_LIT:2><EOL>and word[-<NUM_LIT:3>] not in self._not_s_endings<EOL>):<EOL><INDENT>word = word[:-<NUM_LIT:2>]<EOL><DEDENT><DEDENT>elif word[-<NUM_LIT:1>:] == '<STR_LIT:s>':<EOL><INDENT>if (<EOL>len(word[r1_start:]) >= <NUM_LIT:1><EOL>and word[-<NUM_LIT:2>] not in self._not_s_endings<EOL>):<EOL><INDENT>word = word[:-<NUM_LIT:1>]<EOL><DEDENT><DEDENT>e_removed = False<EOL>if word[-<NUM_LIT:1>:] == '<STR_LIT:e>':<EOL><INDENT>if len(word[r1_start:]) >= <NUM_LIT:1> and word[-<NUM_LIT:2>] not in self._vowels:<EOL><INDENT>word = self._undouble(word[:-<NUM_LIT:1>])<EOL>e_removed = True<EOL><DEDENT><DEDENT>if word[-<NUM_LIT:4>:] == '<STR_LIT>':<EOL><INDENT>if len(word[r2_start:]) >= <NUM_LIT:4> and word[-<NUM_LIT:5>] != '<STR_LIT:c>':<EOL><INDENT>word = word[:-<NUM_LIT:4>]<EOL>if word[-<NUM_LIT:2>:] == '<STR_LIT>':<EOL><INDENT>if len(word[r1_start:]) >= <NUM_LIT:2> and (<EOL>word[-<NUM_LIT:3>] not in self._vowels and word[-<NUM_LIT:5>:-<NUM_LIT:2>] != '<STR_LIT>'<EOL>):<EOL><INDENT>word = self._undouble(word[:-<NUM_LIT:2>])<EOL><DEDENT><DEDENT><DEDENT><DEDENT>if word[-<NUM_LIT:4>:] == '<STR_LIT>':<EOL><INDENT>if len(word[r2_start:]) >= <NUM_LIT:4>:<EOL><INDENT>word = word[:-<NUM_LIT:4>]<EOL>if word[-<NUM_LIT:1>:] == '<STR_LIT:e>':<EOL><INDENT>if (<EOL>len(word[r1_start:]) >= <NUM_LIT:1><EOL>and word[-<NUM_LIT:2>] not in self._vowels<EOL>):<EOL><INDENT>word = self._undouble(word[:-<NUM_LIT:1>])<EOL><DEDENT><DEDENT><DEDENT><DEDENT>elif word[-<NUM_LIT:4>:] == '<STR_LIT>':<EOL><INDENT>if len(word[r2_start:]) >= <NUM_LIT:4>:<EOL><INDENT>word = word[:-<NUM_LIT:4>]<EOL><DEDENT><DEDENT>elif word[-<NUM_LIT:3>:] in ('<STR_LIT:end>', '<STR_LIT>'):<EOL><INDENT>if len(word[r2_start:]) >= <NUM_LIT:3>:<EOL><INDENT>word = word[:-<NUM_LIT:3>]<EOL>if (<EOL>word[-<NUM_LIT:2>:] == '<STR_LIT>'<EOL>and len(word[r2_start:]) >= <NUM_LIT:2><EOL>and word[-<NUM_LIT:3>] != '<STR_LIT:e>'<EOL>):<EOL><INDENT>word = word[:-<NUM_LIT:2>]<EOL><DEDENT>else:<EOL><INDENT>word = self._undouble(word)<EOL><DEDENT><DEDENT><DEDENT>elif word[-<NUM_LIT:3>:] == '<STR_LIT:bar>':<EOL><INDENT>if len(word[r2_start:]) >= <NUM_LIT:3> and e_removed:<EOL><INDENT>word = word[:-<NUM_LIT:3>]<EOL><DEDENT><DEDENT>elif word[-<NUM_LIT:2>:] == '<STR_LIT>':<EOL><INDENT>if len(word[r2_start:]) >= <NUM_LIT:2> and word[-<NUM_LIT:3>] != '<STR_LIT:e>':<EOL><INDENT>word = word[:-<NUM_LIT:2>]<EOL><DEDENT><DEDENT>if (<EOL>len(word) >= <NUM_LIT:4><EOL>and word[-<NUM_LIT:3>] == word[-<NUM_LIT:2>]<EOL>and word[-<NUM_LIT:2>] in {'<STR_LIT:a>', '<STR_LIT:e>', '<STR_LIT:o>', '<STR_LIT:u>'}<EOL>and word[-<NUM_LIT:4>] not in self._vowels<EOL>and word[-<NUM_LIT:1>] not in self._vowels<EOL>and word[-<NUM_LIT:1>] != '<STR_LIT:I>'<EOL>):<EOL><INDENT>word = word[:-<NUM_LIT:2>] + word[-<NUM_LIT:1>]<EOL><DEDENT>for i in range(<NUM_LIT:0>, len(word)):<EOL><INDENT>if word[i] == '<STR_LIT:Y>':<EOL><INDENT>word = word[:i] + '<STR_LIT:y>' + word[i + <NUM_LIT:1> :]<EOL><DEDENT>elif word[i] == '<STR_LIT:I>':<EOL><INDENT>word = word[:i] + '<STR_LIT:i>' + word[i + <NUM_LIT:1> :]<EOL><DEDENT><DEDENT>return word<EOL>

Return Snowball Dutch stem.

        Parameters
        ----------
        word : str
            The word to stem

        Returns
        -------
        str
            Word stem

        Examples
        --------
        >>> stmr = SnowballDutch()
        >>> stmr.stem('lezen')
        'lez'
        >>> stmr.stem('opschorting')
        'opschort'
        >>> stmr.stem('ongrijpbaarheid')
        'ongrijp'


terminate = False<EOL>intact = True<EOL>while not terminate:<EOL><INDENT>for n in range(<NUM_LIT:6>, <NUM_LIT:0>, -<NUM_LIT:1>):<EOL><INDENT>if word[-n:] in self._rule_table[n]:<EOL><INDENT>accept = False<EOL>if len(self._rule_table[n][word[-n:]]) < <NUM_LIT:4>:<EOL><INDENT>for rule in self._rule_table[n][word[-n:]]:<EOL><INDENT>(<EOL>word,<EOL>accept,<EOL>intact,<EOL>terminate,<EOL>) = self._apply_rule(word, rule, intact, terminate)<EOL>if accept:<EOL><INDENT>break<EOL><DEDENT><DEDENT><DEDENT>else:<EOL><INDENT>rule = self._rule_table[n][word[-n:]]<EOL>(word, accept, intact, terminate) = self._apply_rule(<EOL>word, rule, intact, terminate<EOL>)<EOL><DEDENT>if accept:<EOL><INDENT>break<EOL><DEDENT><DEDENT><DEDENT>else:<EOL><INDENT>break<EOL><DEDENT><DEDENT>return word<EOL>

Return Paice-Husk stem.

        Parameters
        ----------
        word : str
            The word to stem

        Returns
        -------
        str
            Word stem

        Examples
        --------
        >>> stmr = PaiceHusk()
        >>> stmr.stem('assumption')
        'assum'
        >>> stmr.stem('verifiable')
        'ver'
        >>> stmr.stem('fancies')
        'fant'
        >>> stmr.stem('fanciful')
        'fancy'
        >>> stmr.stem('torment')
        'tor'


def _sb_r2(self, term, r1_prefixes=None):

r1_start = self._sb_r1(term, r1_prefixes)<EOL>return r1_start + self._sb_r1(term[r1_start:])<EOL>

Return the R2 region, as defined in the Porter2 specification.

        Parameters
        ----------
        term : str
            The term to examine
        r1_prefixes : set
            Prefixes to consider

        Returns
        -------
        int
            Length of the R1 region


def _sb_r1(self, term, r1_prefixes=None):

vowel_found = False<EOL>if hasattr(r1_prefixes, '<STR_LIT>'):<EOL><INDENT>for prefix in r1_prefixes:<EOL><INDENT>if term[: len(prefix)] == prefix:<EOL><INDENT>return len(prefix)<EOL><DEDENT><DEDENT><DEDENT>for i in range(len(term)):<EOL><INDENT>if not vowel_found and term[i] in self._vowels:<EOL><INDENT>vowel_found = True<EOL><DEDENT>elif vowel_found and term[i] not in self._vowels:<EOL><INDENT>return i + <NUM_LIT:1><EOL><DEDENT><DEDENT>return len(term)<EOL>

Return the R1 region, as defined in the Porter2 specification.

        Parameters
        ----------
        term : str
            The term to examine
        r1_prefixes : set
            Prefixes to consider

        Returns
        -------
        int
            Length of the R1 region


def _sb_short_word(self, term, r1_prefixes=None):

if self._sb_r1(term, r1_prefixes) == len(<EOL>term<EOL>) and self._sb_ends_in_short_syllable(term):<EOL><INDENT>return True<EOL><DEDENT>return False<EOL>

Return True iff term is a short word.

        (...according to the Porter2 specification.)

        Parameters
        ----------
        term : str
            The term to examine
        r1_prefixes : set
            Prefixes to consider

        Returns
        -------
        bool
            True iff term is a short word


return len(word) - suffix_len >= <NUM_LIT:5><EOL>

Return Lovins' condition D.

        Parameters
        ----------
        word : str
            Word to check
        suffix_len : int
            Suffix length

        Returns
        -------
        bool
            True if condition is met


if stem[-<NUM_LIT:3>:-<NUM_LIT:2>] == '<STR_LIT:n>':<EOL><INDENT>return stem<EOL><DEDENT>return stem[:-<NUM_LIT:1>] + '<STR_LIT:s>'<EOL>

Return Lovins' conditional recode rule 32.

        Parameters
        ----------
        stem : str
            Word to stem

        Returns
        -------
        str
            Word stripped of suffix


self._suffix = {<EOL>'<STR_LIT>': self._cond_b,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': self._cond_b,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': self._cond_c,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': self._cond_b,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': self._cond_e,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': self._cond_b,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': self._cond_e,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': self._cond_b,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': self._cond_e,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': self._cond_g,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': self._cond_f,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': self._cond_b,<EOL>'<STR_LIT:action>': self._cond_g,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': self._cond_b,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': self._cond_b,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': self._cond_z,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': self._cond_c,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': self._cond_d,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': self._cond_e,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': self._cond_b,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': self._cond_b,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': self._cond_bb,<EOL>'<STR_LIT>': self._cond_b,<EOL>'<STR_LIT>': self._cond_b,<EOL>'<STR_LIT>': self._cond_c,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': self._cond_b,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': self._cond_i,<EOL>'<STR_LIT>': self._cond_b,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': self._cond_e,<EOL>'<STR_LIT>': self._cond_y,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': self._cond_e,<EOL>'<STR_LIT>': self._cond_e,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': self._cond_c,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': self._cond_i,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': self._cond_b,<EOL>'<STR_LIT>': self._cond_j,<EOL>'<STR_LIT>': self._cond_cc,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': self._cond_f,<EOL>'<STR_LIT>': self._cond_f,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': self._cond_b,<EOL>'<STR_LIT>': self._cond_b,<EOL>'<STR_LIT>': self._cond_b,<EOL>'<STR_LIT>': self._cond_b,<EOL>'<STR_LIT>': self._cond_b,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': self._cond_k,<EOL>'<STR_LIT>': self._cond_i,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': self._cond_b,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': self._cond_y,<EOL>'<STR_LIT>': self._cond_e,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': self._cond_e,<EOL>'<STR_LIT>': self._cond_e,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': self._cond_l,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': self._cond_m,<EOL>'<STR_LIT>': self._cond_n,<EOL>'<STR_LIT>': self._cond_b,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': self._cond_b,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': self._cond_h,<EOL>'<STR_LIT>': self._cond_f,<EOL>'<STR_LIT>': self._cond_f,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': self._cond_b,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': self._cond_b,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': self._cond_bb,<EOL>'<STR_LIT>': self._cond_b,<EOL>'<STR_LIT>': self._cond_o,<EOL>'<STR_LIT>': self._cond_f,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': self._cond_y,<EOL>'<STR_LIT>': self._cond_y,<EOL>'<STR_LIT>': self._cond_e,<EOL>'<STR_LIT>': self._cond_e,<EOL>'<STR_LIT>': self._cond_c,<EOL>'<STR_LIT>': self._cond_e,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': self._cond_l,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': self._cond_p,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': self._cond_m,<EOL>'<STR_LIT>': self._cond_n,<EOL>'<STR_LIT>': self._cond_q,<EOL>'<STR_LIT>': self._cond_c,<EOL>'<STR_LIT>': self._cond_b,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': self._cond_aa,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': self._cond_f,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': self._cond_r,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': self._cond_bb,<EOL>'<STR_LIT>': self._cond_x,<EOL>'<STR_LIT>': self._cond_b,<EOL>'<STR_LIT>': self._cond_e,<EOL>'<STR_LIT>': self._cond_f,<EOL>'<STR_LIT>': self._cond_e,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': self._cond_b,<EOL>'<STR_LIT>': self._cond_s,<EOL>'<STR_LIT>': self._cond_t,<EOL>'<STR_LIT>': self._cond_u,<EOL>'<STR_LIT>': self._cond_v,<EOL>'<STR_LIT>': self._cond_r,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT>': None,<EOL>'<STR_LIT:a>': None,<EOL>'<STR_LIT:e>': None,<EOL>'<STR_LIT:i>': None,<EOL>'<STR_LIT:o>': None,<EOL>'<STR_LIT:s>': self._cond_w,<EOL>'<STR_LIT:y>': self._cond_b,<EOL>}<EOL>self._recode = (<EOL>('<STR_LIT>', '<STR_LIT>'),<EOL>('<STR_LIT>', '<STR_LIT>'),<EOL>('<STR_LIT>', '<STR_LIT>'),<EOL>('<STR_LIT>', '<STR_LIT:rb>'),<EOL>('<STR_LIT>', '<STR_LIT>'),<EOL>('<STR_LIT>', '<STR_LIT>'),<EOL>('<STR_LIT>', '<STR_LIT>'),<EOL>('<STR_LIT>', '<STR_LIT>'),<EOL>('<STR_LIT>', self._recode9),<EOL>('<STR_LIT>', '<STR_LIT>'),<EOL>('<STR_LIT>', '<STR_LIT>'),<EOL>('<STR_LIT>', '<STR_LIT>'),<EOL>('<STR_LIT>', '<STR_LIT>'),<EOL>('<STR_LIT>', '<STR_LIT>'),<EOL>('<STR_LIT>', '<STR_LIT>'),<EOL>('<STR_LIT>', '<STR_LIT>'),<EOL>('<STR_LIT>', '<STR_LIT>'),<EOL>('<STR_LIT>', '<STR_LIT>'),<EOL>('<STR_LIT>', '<STR_LIT>'),<EOL>('<STR_LIT>', '<STR_LIT>'),<EOL>('<STR_LIT>', '<STR_LIT>'),<EOL>('<STR_LIT>', '<STR_LIT>'),<EOL>('<STR_LIT>', '<STR_LIT>'),<EOL>('<STR_LIT:end>', self._recode24),<EOL>('<STR_LIT>', '<STR_LIT>'),<EOL>('<STR_LIT>', '<STR_LIT>'),<EOL>('<STR_LIT>', '<STR_LIT>'),<EOL>('<STR_LIT>', self._recode28),<EOL>('<STR_LIT>', '<STR_LIT>'),<EOL>('<STR_LIT>', self._recode30),<EOL>('<STR_LIT>', '<STR_LIT>'),<EOL>('<STR_LIT>', self._recode32),<EOL>('<STR_LIT>', '<STR_LIT>'),<EOL>('<STR_LIT>', '<STR_LIT>'),<EOL>)<EOL>


return word[-suffix_len - <NUM_LIT:1>] == '<STR_LIT:l>'<EOL>

Return Lovins' condition CC.

        Parameters
        ----------
        word : str
            Word to check
        suffix_len : int
            Suffix length

        Returns
        -------
        bool
            True if condition is met


if stem[-<NUM_LIT:4>:-<NUM_LIT:3>] == '<STR_LIT:s>':<EOL><INDENT>return stem<EOL><DEDENT>return stem[:-<NUM_LIT:1>] + '<STR_LIT:s>'<EOL>

Return Lovins' conditional recode rule 24.

        Parameters
        ----------
        stem : str
            Word to stem

        Returns
        -------
        str
            Word stripped of suffix


return word[-suffix_len - <NUM_LIT:1>] not in {'<STR_LIT:e>', '<STR_LIT:o>'}<EOL>

Return Lovins' condition I.

        Parameters
        ----------
        word : str
            Word to check
        suffix_len : int
            Suffix length

        Returns
        -------
        bool
            True if condition is met


return word[-suffix_len - <NUM_LIT:2> : -suffix_len] == '<STR_LIT>'<EOL>

Return Lovins' condition Y.

        Parameters
        ----------
        word : str
            Word to check
        suffix_len : int
            Suffix length

        Returns
        -------
        bool
            True if condition is met


return Lovins().stem(word)<EOL>

Return Lovins stem.

    This is a wrapper for :py:meth:`Lovins.stem`.

    Parameters
    ----------
    word : str
        The word to stem

    Returns
    -------
    str: Word stem

    Examples
    --------
    >>> lovins('reading')
    'read'
    >>> lovins('suspension')
    'suspens'
    >>> lovins('elusiveness')
    'elus'


if len(word) - suffix_len >= <NUM_LIT:3>:<EOL><INDENT>if word[-suffix_len - <NUM_LIT:3>] == '<STR_LIT:s>':<EOL><INDENT>if len(word) - suffix_len >= <NUM_LIT:4>:<EOL><INDENT>return True<EOL><DEDENT><DEDENT>else:<EOL><INDENT>return True<EOL><DEDENT><DEDENT>return False<EOL>

Return Lovins' condition N.

        Parameters
        ----------
        word : str
            Word to check
        suffix_len : int
            Suffix length

        Returns
        -------
        bool
            True if condition is met


return (<EOL>len(word) - suffix_len >= <NUM_LIT:3><EOL>and word[-suffix_len - <NUM_LIT:3> : -suffix_len] != '<STR_LIT>'<EOL>and word[-suffix_len - <NUM_LIT:4> : -suffix_len] != '<STR_LIT>'<EOL>)<EOL>

Return Lovins' condition BB.

        Parameters
        ----------
        word : str
            Word to check
        suffix_len : int
            Suffix length

        Returns
        -------
        bool
            True if condition is met


return (<EOL>word[-suffix_len - <NUM_LIT:1>] == '<STR_LIT:t>'<EOL>or word[-suffix_len - <NUM_LIT:2> : -suffix_len] == '<STR_LIT>'<EOL>)<EOL>

Return Lovins' condition H.

        Parameters
        ----------
        word : str
            Word to check
        suffix_len : int
            Suffix length

        Returns
        -------
        bool
            True if condition is met


return word[-suffix_len - <NUM_LIT:1>] in {'<STR_LIT:d>', '<STR_LIT:f>', '<STR_LIT:l>', '<STR_LIT:t>'} or word[<EOL>-suffix_len - <NUM_LIT:2> : -suffix_len<EOL>] in {'<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>'}<EOL>

Return Lovins' condition AA.

        Parameters
        ----------
        word : str
            Word to check
        suffix_len : int
            Suffix length

        Returns
        -------
        bool
            True if condition is met


return word[-suffix_len - <NUM_LIT:1>] != '<STR_LIT:e>'<EOL>

Return Lovins' condition E.

        Parameters
        ----------
        word : str
            Word to check
        suffix_len : int
            Suffix length

        Returns
        -------
        bool
            True if condition is met


return len(word) - suffix_len >= <NUM_LIT:3> and word[-suffix_len - <NUM_LIT:1>] == '<STR_LIT:f>'<EOL>

Return Lovins' condition G.

        Parameters
        ----------
        word : str
            Word to check
        suffix_len : int
            Suffix length

        Returns
        -------
        bool
            True if condition is met


return word[-suffix_len - <NUM_LIT:1>] in {'<STR_LIT:i>', '<STR_LIT:l>'}<EOL>

Return Lovins' condition O.

        Parameters
        ----------
        word : str
            Word to check
        suffix_len : int
            Suffix length

        Returns
        -------
        bool
            True if condition is met


return (<EOL>word[-suffix_len - <NUM_LIT:1>] not in {'<STR_LIT:s>', '<STR_LIT:u>', '<STR_LIT:x>'}<EOL>or word[-suffix_len - <NUM_LIT:1>] == '<STR_LIT>'<EOL>)<EOL>

Return Lovins' condition L.

        Parameters
        ----------
        word : str
            Word to check
        suffix_len : int
            Suffix length

        Returns
        -------
        bool
            True if condition is met


return word[-suffix_len - <NUM_LIT:1>] in {'<STR_LIT:l>', '<STR_LIT:m>', '<STR_LIT:n>', '<STR_LIT:r>'}<EOL>

Return Lovins' condition U.

        Parameters
        ----------
        word : str
            Word to check
        suffix_len : int
            Suffix length

        Returns
        -------
        bool
            True if condition is met


if stem[-<NUM_LIT:4>:-<NUM_LIT:3>] == '<STR_LIT:m>':<EOL><INDENT>return stem<EOL><DEDENT>return stem[:-<NUM_LIT:1>] + '<STR_LIT:s>'<EOL>

Return Lovins' conditional recode rule 30.

        Parameters
        ----------
        stem : str
            Word to stem

        Returns
        -------
        str
            Word stripped of suffix


return len(word) - suffix_len >= <NUM_LIT:4><EOL>

Return Lovins' condition C.

        Parameters
        ----------
        word : str
            Word to check
        suffix_len : int
            Suffix length

        Returns
        -------
        bool
            True if condition is met


word = normalize('<STR_LIT>', text_type(word.lower()))<EOL>word = '<STR_LIT>'.join(<EOL>c<EOL>for c in word<EOL>if c<EOL>in {<EOL>'<STR_LIT:a>',<EOL>'<STR_LIT:b>',<EOL>'<STR_LIT:c>',<EOL>'<STR_LIT:d>',<EOL>'<STR_LIT:e>',<EOL>'<STR_LIT:f>',<EOL>'<STR_LIT:g>',<EOL>'<STR_LIT:h>',<EOL>'<STR_LIT:i>',<EOL>'<STR_LIT>',<EOL>'<STR_LIT:k>',<EOL>'<STR_LIT:l>',<EOL>'<STR_LIT:m>',<EOL>'<STR_LIT:n>',<EOL>'<STR_LIT:o>',<EOL>'<STR_LIT:p>',<EOL>'<STR_LIT:q>',<EOL>'<STR_LIT:r>',<EOL>'<STR_LIT:s>',<EOL>'<STR_LIT:t>',<EOL>'<STR_LIT:u>',<EOL>'<STR_LIT:v>',<EOL>'<STR_LIT:w>',<EOL>'<STR_LIT:x>',<EOL>'<STR_LIT:y>',<EOL>'<STR_LIT:z>',<EOL>}<EOL>)<EOL>word = word.replace('<STR_LIT>', '<STR_LIT:i>').replace('<STR_LIT:v>', '<STR_LIT:u>')<EOL>if word[-<NUM_LIT:3>:] == '<STR_LIT>':<EOL><INDENT>if word[:-<NUM_LIT:3>] in self._keep_que or word == '<STR_LIT>':<EOL><INDENT>return {'<STR_LIT:n>': word, '<STR_LIT:v>': word}<EOL><DEDENT>else:<EOL><INDENT>word = word[:-<NUM_LIT:3>]<EOL><DEDENT><DEDENT>noun = word<EOL>verb = word<EOL>for endlen in range(<NUM_LIT:4>, <NUM_LIT:0>, -<NUM_LIT:1>):<EOL><INDENT>if word[-endlen:] in self._n_endings[endlen]:<EOL><INDENT>if len(word) - <NUM_LIT:2> >= endlen:<EOL><INDENT>noun = word[:-endlen]<EOL><DEDENT>else:<EOL><INDENT>noun = word<EOL><DEDENT>break<EOL><DEDENT><DEDENT>for endlen in range(<NUM_LIT:6>, <NUM_LIT:0>, -<NUM_LIT:1>):<EOL><INDENT>if word[-endlen:] in self._v_endings_strip[endlen]:<EOL><INDENT>if len(word) - <NUM_LIT:2> >= endlen:<EOL><INDENT>verb = word[:-endlen]<EOL><DEDENT>else:<EOL><INDENT>verb = word<EOL><DEDENT>break<EOL><DEDENT>if word[-endlen:] in self._v_endings_alter[endlen]:<EOL><INDENT>if word[-endlen:] in {<EOL>'<STR_LIT>',<EOL>'<STR_LIT>',<EOL>'<STR_LIT>',<EOL>'<STR_LIT>',<EOL>'<STR_LIT>',<EOL>}:<EOL><INDENT>new_word = word[:-endlen] + '<STR_LIT:i>'<EOL>addlen = <NUM_LIT:1><EOL><DEDENT>elif word[-endlen:] in {'<STR_LIT>', '<STR_LIT>', '<STR_LIT>'}:<EOL><INDENT>new_word = word[:-endlen] + '<STR_LIT>'<EOL>addlen = <NUM_LIT:2><EOL><DEDENT>else:<EOL><INDENT>new_word = word[:-endlen] + '<STR_LIT>'<EOL>addlen = <NUM_LIT:3><EOL><DEDENT>if len(new_word) >= <NUM_LIT:2> + addlen:<EOL><INDENT>verb = new_word<EOL><DEDENT>else:<EOL><INDENT>verb = word<EOL><DEDENT>break<EOL><DEDENT><DEDENT>return {'<STR_LIT:n>': noun, '<STR_LIT:v>': verb}<EOL>

Return the stem of a word according to the Schinke stemmer.

        Parameters
        ----------
        word : str
            The word to stem

        Returns
        -------
        str
            Word stem

        Examples
        --------
        >>> stmr = Schinke()
        >>> stmr.stem('atque')
        {'n': 'atque', 'v': 'atque'}
        >>> stmr.stem('census')
        {'n': 'cens', 'v': 'censu'}
        >>> stmr.stem('virum')
        {'n': 'uir', 'v': 'uiru'}
        >>> stmr.stem('populusque')
        {'n': 'popul', 'v': 'populu'}
        >>> stmr.stem('senatus')
        {'n': 'senat', 'v': 'senatu'}


return Schinke().stem(word)<EOL>

Return the stem of a word according to the Schinke stemmer.

    This is a wrapper for :py:meth:`Schinke.stem`.

    Parameters
    ----------
    word : str
        The word to stem

    Returns
    -------
    str
        Word stem

    Examples
    --------
    >>> schinke('atque')
    {'n': 'atque', 'v': 'atque'}
    >>> schinke('census')
    {'n': 'cens', 'v': 'censu'}
    >>> schinke('virum')
    {'n': 'uir', 'v': 'uiru'}
    >>> schinke('populusque')
    {'n': 'popul', 'v': 'populu'}
    >>> schinke('senatus')
    {'n': 'senat', 'v': 'senatu'}


return SnowballNorwegian().stem(word)<EOL>

Return Snowball Norwegian stem.

    This is a wrapper for :py:meth:`SnowballNorwegian.stem`.

    Parameters
    ----------
    word : str
        The word to stem

    Returns
    -------
    str
        Word stem

    Examples
    --------
    >>> sb_norwegian('lese')
    'les'
    >>> sb_norwegian('suspensjon')
    'suspensjon'
    >>> sb_norwegian('sikkerhet')
    'sikker'


for letter in term:<EOL><INDENT>if letter in self._vowels:<EOL><INDENT>return True<EOL><DEDENT><DEDENT>return False<EOL>

Return Porter helper function _has_vowel value.

        Parameters
        ----------
        term : str
            The word to scan for vowels

        Returns
        -------
        bool
            True iff a vowel exists in the term (as defined in the Porter
            stemmer definition)


return (<EOL>len(term) > <NUM_LIT:1><EOL>and term[-<NUM_LIT:1>] not in self._vowels<EOL>and term[-<NUM_LIT:2>] == term[-<NUM_LIT:1>]<EOL>)<EOL>

Return Porter helper function _ends_in_doubled_cons value.

        Parameters
        ----------
        term : str
            The word to check for a final doubled consonant

        Returns
        -------
        bool
            True iff the stem ends in a doubled consonant (as defined in the
            Porter stemmer definition)


def stem(self, word, early_english=False):

<EOL>word = normalize('<STR_LIT>', text_type(word.lower()))<EOL>if len(word) < <NUM_LIT:3>:<EOL><INDENT>return word<EOL><DEDENT>if word[<NUM_LIT:0>] == '<STR_LIT:y>':<EOL><INDENT>word = '<STR_LIT:Y>' + word[<NUM_LIT:1>:]<EOL><DEDENT>for i in range(<NUM_LIT:1>, len(word)):<EOL><INDENT>if word[i] == '<STR_LIT:y>' and word[i - <NUM_LIT:1>] in self._vowels:<EOL><INDENT>word = word[:i] + '<STR_LIT:Y>' + word[i + <NUM_LIT:1> :]<EOL><DEDENT><DEDENT>if word[-<NUM_LIT:1>] == '<STR_LIT:s>':<EOL><INDENT>if word[-<NUM_LIT:4>:] == '<STR_LIT>':<EOL><INDENT>word = word[:-<NUM_LIT:2>]<EOL><DEDENT>elif word[-<NUM_LIT:3>:] == '<STR_LIT>':<EOL><INDENT>word = word[:-<NUM_LIT:2>]<EOL><DEDENT>elif word[-<NUM_LIT:2>:] == '<STR_LIT>':<EOL><INDENT>pass<EOL><DEDENT>else:<EOL><INDENT>word = word[:-<NUM_LIT:1>]<EOL><DEDENT><DEDENT>step1b_flag = False<EOL>if word[-<NUM_LIT:3>:] == '<STR_LIT>':<EOL><INDENT>if self._m_degree(word[:-<NUM_LIT:3>]) > <NUM_LIT:0>:<EOL><INDENT>word = word[:-<NUM_LIT:1>]<EOL><DEDENT><DEDENT>elif word[-<NUM_LIT:2>:] == '<STR_LIT>':<EOL><INDENT>if self._has_vowel(word[:-<NUM_LIT:2>]):<EOL><INDENT>word = word[:-<NUM_LIT:2>]<EOL>step1b_flag = True<EOL><DEDENT><DEDENT>elif word[-<NUM_LIT:3>:] == '<STR_LIT>':<EOL><INDENT>if self._has_vowel(word[:-<NUM_LIT:3>]):<EOL><INDENT>word = word[:-<NUM_LIT:3>]<EOL>step1b_flag = True<EOL><DEDENT><DEDENT>elif early_english:<EOL><INDENT>if word[-<NUM_LIT:3>:] == '<STR_LIT>':<EOL><INDENT>if self._has_vowel(word[:-<NUM_LIT:3>]):<EOL><INDENT>word = word[:-<NUM_LIT:3>]<EOL>step1b_flag = True<EOL><DEDENT><DEDENT>elif word[-<NUM_LIT:3>:] == '<STR_LIT>':<EOL><INDENT>if self._has_vowel(word[:-<NUM_LIT:3>]):<EOL><INDENT>word = word[:-<NUM_LIT:3>]<EOL>step1b_flag = True<EOL><DEDENT><DEDENT><DEDENT>if step1b_flag:<EOL><INDENT>if word[-<NUM_LIT:2>:] in {'<STR_LIT>', '<STR_LIT>', '<STR_LIT>'}:<EOL><INDENT>word += '<STR_LIT:e>'<EOL><DEDENT>elif self._ends_in_doubled_cons(word) and word[-<NUM_LIT:1>] not in {<EOL>'<STR_LIT:l>',<EOL>'<STR_LIT:s>',<EOL>'<STR_LIT:z>',<EOL>}:<EOL><INDENT>word = word[:-<NUM_LIT:1>]<EOL><DEDENT>elif self._m_degree(word) == <NUM_LIT:1> and self._ends_in_cvc(word):<EOL><INDENT>word += '<STR_LIT:e>'<EOL><DEDENT><DEDENT>if word[-<NUM_LIT:1>] in {'<STR_LIT:Y>', '<STR_LIT:y>'} and self._has_vowel(word[:-<NUM_LIT:1>]):<EOL><INDENT>word = word[:-<NUM_LIT:1>] + '<STR_LIT:i>'<EOL><DEDENT>if len(word) > <NUM_LIT:1>:<EOL><INDENT>if word[-<NUM_LIT:2>] == '<STR_LIT:a>':<EOL><INDENT>if word[-<NUM_LIT:7>:] == '<STR_LIT>':<EOL><INDENT>if self._m_degree(word[:-<NUM_LIT:7>]) > <NUM_LIT:0>:<EOL><INDENT>word = word[:-<NUM_LIT:5>] + '<STR_LIT:e>'<EOL><DEDENT><DEDENT>elif word[-<NUM_LIT:6>:] == '<STR_LIT>':<EOL><INDENT>if self._m_degree(word[:-<NUM_LIT:6>]) > <NUM_LIT:0>:<EOL><INDENT>word = word[:-<NUM_LIT:2>]<EOL><DEDENT><DEDENT><DEDENT>elif word[-<NUM_LIT:2>] == '<STR_LIT:c>':<EOL><INDENT>if word[-<NUM_LIT:4>:] in {'<STR_LIT>', '<STR_LIT>'}:<EOL><INDENT>if self._m_degree(word[:-<NUM_LIT:4>]) > <NUM_LIT:0>:<EOL><INDENT>word = word[:-<NUM_LIT:1>] + '<STR_LIT:e>'<EOL><DEDENT><DEDENT><DEDENT>elif word[-<NUM_LIT:2>] == '<STR_LIT:e>':<EOL><INDENT>if word[-<NUM_LIT:4>:] == '<STR_LIT>':<EOL><INDENT>if self._m_degree(word[:-<NUM_LIT:4>]) > <NUM_LIT:0>:<EOL><INDENT>word = word[:-<NUM_LIT:1>]<EOL><DEDENT><DEDENT><DEDENT>elif word[-<NUM_LIT:2>] == '<STR_LIT:g>':<EOL><INDENT>if word[-<NUM_LIT:4>:] == '<STR_LIT>':<EOL><INDENT>if self._m_degree(word[:-<NUM_LIT:4>]) > <NUM_LIT:0>:<EOL><INDENT>word = word[:-<NUM_LIT:1>]<EOL><DEDENT><DEDENT><DEDENT>elif word[-<NUM_LIT:2>] == '<STR_LIT:l>':<EOL><INDENT>if word[-<NUM_LIT:3>:] == '<STR_LIT>':<EOL><INDENT>if self._m_degree(word[:-<NUM_LIT:3>]) > <NUM_LIT:0>:<EOL><INDENT>word = word[:-<NUM_LIT:1>] + '<STR_LIT:e>'<EOL><DEDENT><DEDENT>elif word[-<NUM_LIT:4>:] == '<STR_LIT>':<EOL><INDENT>if self._m_degree(word[:-<NUM_LIT:4>]) > <NUM_LIT:0>:<EOL><INDENT>word = word[:-<NUM_LIT:2>]<EOL><DEDENT><DEDENT>elif word[-<NUM_LIT:5>:] == '<STR_LIT>':<EOL><INDENT>if self._m_degree(word[:-<NUM_LIT:5>]) > <NUM_LIT:0>:<EOL><INDENT>word = word[:-<NUM_LIT:2>]<EOL><DEDENT><DEDENT>elif word[-<NUM_LIT:3>:] == '<STR_LIT>':<EOL><INDENT>if self._m_degree(word[:-<NUM_LIT:3>]) > <NUM_LIT:0>:<EOL><INDENT>word = word[:-<NUM_LIT:2>]<EOL><DEDENT><DEDENT>elif word[-<NUM_LIT:5>:] == '<STR_LIT>':<EOL><INDENT>if self._m_degree(word[:-<NUM_LIT:5>]) > <NUM_LIT:0>:<EOL><INDENT>word = word[:-<NUM_LIT:2>]<EOL><DEDENT><DEDENT><DEDENT>elif word[-<NUM_LIT:2>] == '<STR_LIT:o>':<EOL><INDENT>if word[-<NUM_LIT:7>:] == '<STR_LIT>':<EOL><INDENT>if self._m_degree(word[:-<NUM_LIT:7>]) > <NUM_LIT:0>:<EOL><INDENT>word = word[:-<NUM_LIT:5>] + '<STR_LIT:e>'<EOL><DEDENT><DEDENT>elif word[-<NUM_LIT:5>:] == '<STR_LIT>':<EOL><INDENT>if self._m_degree(word[:-<NUM_LIT:5>]) > <NUM_LIT:0>:<EOL><INDENT>word = word[:-<NUM_LIT:3>] + '<STR_LIT:e>'<EOL><DEDENT><DEDENT>elif word[-<NUM_LIT:4>:] == '<STR_LIT>':<EOL><INDENT>if self._m_degree(word[:-<NUM_LIT:4>]) > <NUM_LIT:0>:<EOL><INDENT>word = word[:-<NUM_LIT:2>] + '<STR_LIT:e>'<EOL><DEDENT><DEDENT><DEDENT>elif word[-<NUM_LIT:2>] == '<STR_LIT:s>':<EOL><INDENT>if word[-<NUM_LIT:5>:] == '<STR_LIT>':<EOL><INDENT>if self._m_degree(word[:-<NUM_LIT:5>]) > <NUM_LIT:0>:<EOL><INDENT>word = word[:-<NUM_LIT:3>]<EOL><DEDENT><DEDENT>elif word[-<NUM_LIT:7>:] in {'<STR_LIT>', '<STR_LIT>', '<STR_LIT>'}:<EOL><INDENT>if self._m_degree(word[:-<NUM_LIT:7>]) > <NUM_LIT:0>:<EOL><INDENT>word = word[:-<NUM_LIT:4>]<EOL><DEDENT><DEDENT><DEDENT>elif word[-<NUM_LIT:2>] == '<STR_LIT:t>':<EOL><INDENT>if word[-<NUM_LIT:5>:] == '<STR_LIT>':<EOL><INDENT>if self._m_degree(word[:-<NUM_LIT:5>]) > <NUM_LIT:0>:<EOL><INDENT>word = word[:-<NUM_LIT:3>]<EOL><DEDENT><DEDENT>elif word[-<NUM_LIT:5>:] == '<STR_LIT>':<EOL><INDENT>if self._m_degree(word[:-<NUM_LIT:5>]) > <NUM_LIT:0>:<EOL><INDENT>word = word[:-<NUM_LIT:3>] + '<STR_LIT:e>'<EOL><DEDENT><DEDENT>elif word[-<NUM_LIT:6>:] == '<STR_LIT>':<EOL><INDENT>if self._m_degree(word[:-<NUM_LIT:6>]) > <NUM_LIT:0>:<EOL><INDENT>word = word[:-<NUM_LIT:5>] + '<STR_LIT>'<EOL><DEDENT><DEDENT><DEDENT><DEDENT>if word[-<NUM_LIT:5>:] in '<STR_LIT>':<EOL><INDENT>if self._m_degree(word[:-<NUM_LIT:5>]) > <NUM_LIT:0>:<EOL><INDENT>word = word[:-<NUM_LIT:3>]<EOL><DEDENT><DEDENT>elif word[-<NUM_LIT:5>:] == '<STR_LIT>':<EOL><INDENT>if self._m_degree(word[:-<NUM_LIT:5>]) > <NUM_LIT:0>:<EOL><INDENT>word = word[:-<NUM_LIT:5>]<EOL><DEDENT><DEDENT>elif word[-<NUM_LIT:5>:] in {'<STR_LIT>', '<STR_LIT>'}:<EOL><INDENT>if self._m_degree(word[:-<NUM_LIT:5>]) > <NUM_LIT:0>:<EOL><INDENT>word = word[:-<NUM_LIT:3>]<EOL><DEDENT><DEDENT>elif word[-<NUM_LIT:4>:] == '<STR_LIT>':<EOL><INDENT>if self._m_degree(word[:-<NUM_LIT:4>]) > <NUM_LIT:0>:<EOL><INDENT>word = word[:-<NUM_LIT:2>]<EOL><DEDENT><DEDENT>elif word[-<NUM_LIT:3>:] == '<STR_LIT>':<EOL><INDENT>if self._m_degree(word[:-<NUM_LIT:3>]) > <NUM_LIT:0>:<EOL><INDENT>word = word[:-<NUM_LIT:3>]<EOL><DEDENT><DEDENT>elif word[-<NUM_LIT:4>:] == '<STR_LIT>':<EOL><INDENT>if self._m_degree(word[:-<NUM_LIT:4>]) > <NUM_LIT:0>:<EOL><INDENT>word = word[:-<NUM_LIT:4>]<EOL><DEDENT><DEDENT>if word[-<NUM_LIT:2>:] == '<STR_LIT>':<EOL><INDENT>if self._m_degree(word[:-<NUM_LIT:2>]) > <NUM_LIT:1>:<EOL><INDENT>word = word[:-<NUM_LIT:2>]<EOL><DEDENT><DEDENT>elif word[-<NUM_LIT:4>:] in {'<STR_LIT>', '<STR_LIT>'}:<EOL><INDENT>if self._m_degree(word[:-<NUM_LIT:4>]) > <NUM_LIT:1>:<EOL><INDENT>word = word[:-<NUM_LIT:4>]<EOL><DEDENT><DEDENT>elif word[-<NUM_LIT:2>:] in {'<STR_LIT>', '<STR_LIT>'}:<EOL><INDENT>if self._m_degree(word[:-<NUM_LIT:2>]) > <NUM_LIT:1>:<EOL><INDENT>word = word[:-<NUM_LIT:2>]<EOL><DEDENT><DEDENT>elif word[-<NUM_LIT:4>:] in {'<STR_LIT>', '<STR_LIT>'}:<EOL><INDENT>if self._m_degree(word[:-<NUM_LIT:4>]) > <NUM_LIT:1>:<EOL><INDENT>word = word[:-<NUM_LIT:4>]<EOL><DEDENT><DEDENT>elif word[-<NUM_LIT:3>:] == '<STR_LIT>':<EOL><INDENT>if self._m_degree(word[:-<NUM_LIT:3>]) > <NUM_LIT:1>:<EOL><INDENT>word = word[:-<NUM_LIT:3>]<EOL><DEDENT><DEDENT>elif word[-<NUM_LIT:5>:] == '<STR_LIT>':<EOL><INDENT>if self._m_degree(word[:-<NUM_LIT:5>]) > <NUM_LIT:1>:<EOL><INDENT>word = word[:-<NUM_LIT:5>]<EOL><DEDENT><DEDENT>elif word[-<NUM_LIT:4>:] == '<STR_LIT>':<EOL><INDENT>if self._m_degree(word[:-<NUM_LIT:4>]) > <NUM_LIT:1>:<EOL><INDENT>word = word[:-<NUM_LIT:4>]<EOL><DEDENT><DEDENT>elif word[-<NUM_LIT:3>:] == '<STR_LIT>':<EOL><INDENT>if self._m_degree(word[:-<NUM_LIT:3>]) > <NUM_LIT:1>:<EOL><INDENT>word = word[:-<NUM_LIT:3>]<EOL><DEDENT><DEDENT>elif word[-<NUM_LIT:4>:] in {'<STR_LIT>', '<STR_LIT>'}:<EOL><INDENT>if self._m_degree(word[:-<NUM_LIT:3>]) > <NUM_LIT:1>:<EOL><INDENT>word = word[:-<NUM_LIT:3>]<EOL><DEDENT><DEDENT>elif word[-<NUM_LIT:2>:] == '<STR_LIT>':<EOL><INDENT>if self._m_degree(word[:-<NUM_LIT:2>]) > <NUM_LIT:1>:<EOL><INDENT>word = word[:-<NUM_LIT:2>]<EOL><DEDENT><DEDENT>elif word[-<NUM_LIT:3>:] in {'<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>'}:<EOL><INDENT>if self._m_degree(word[:-<NUM_LIT:3>]) > <NUM_LIT:1>:<EOL><INDENT>word = word[:-<NUM_LIT:3>]<EOL><DEDENT><DEDENT>if word[-<NUM_LIT:1>] == '<STR_LIT:e>':<EOL><INDENT>if self._m_degree(word[:-<NUM_LIT:1>]) > <NUM_LIT:1>:<EOL><INDENT>word = word[:-<NUM_LIT:1>]<EOL><DEDENT>elif self._m_degree(word[:-<NUM_LIT:1>]) == <NUM_LIT:1> and not self._ends_in_cvc(<EOL>word[:-<NUM_LIT:1>]<EOL>):<EOL><INDENT>word = word[:-<NUM_LIT:1>]<EOL><DEDENT><DEDENT>if word[-<NUM_LIT:2>:] == '<STR_LIT>' and self._m_degree(word) > <NUM_LIT:1>:<EOL><INDENT>word = word[:-<NUM_LIT:1>]<EOL><DEDENT>for i in range(len(word)):<EOL><INDENT>if word[i] == '<STR_LIT:Y>':<EOL><INDENT>word = word[:i] + '<STR_LIT:y>' + word[i + <NUM_LIT:1> :]<EOL><DEDENT><DEDENT>return word<EOL>

Return Porter stem.

        Parameters
        ----------
        word : str
            The word to stem
        early_english : bool
            Set to True in order to remove -eth & -est (2nd & 3rd person
            singular verbal agreement suffixes)

        Returns
        -------
        str
            Word stem

        Examples
        --------
        >>> stmr = Porter()
        >>> stmr.stem('reading')
        'read'
        >>> stmr.stem('suspension')
        'suspens'
        >>> stmr.stem('elusiveness')
        'elus'

        >>> stmr.stem('eateth', early_english=True)
        'eat'


return sum(self.values())<EOL>

Return q-grams count.

        Returns
        -------
        int
            The total count of q-grams in a QGrams object

        Examples
        --------
        >>> qg = QGrams('AATTATAT')
        >>> qg.count()
        9

        >>> qg = QGrams('AATTATAT', qval=1, start_stop='')
        >>> qg.count()
        8

        >>> qg = QGrams('AATTATAT', qval=3, start_stop='')
        >>> qg.count()
        6


def dm_soundex(word, max_length=<NUM_LIT:6>, zero_pad=True):

return DaitchMokotoff().encode(word, max_length, zero_pad)<EOL>

Return the Daitch-Mokotoff Soundex code for a word.

    This is a wrapper for :py:meth:`DaitchMokotoff.encode`.

    Parameters
    ----------
    word : str
        The word to transform
    max_length : int
        The length of the code returned (defaults to 6; must be between 6 and
        64)
    zero_pad : bool
        Pad the end of the return value with 0s to achieve a max_length string

    Returns
    -------
    str
        The Daitch-Mokotoff Soundex value

    Examples
    --------
    >>> sorted(dm_soundex('Christopher'))
    ['494379', '594379']
    >>> dm_soundex('Niall')
    {'680000'}
    >>> dm_soundex('Smith')
    {'463000'}
    >>> dm_soundex('Schmidt')
    {'463000'}

    >>> sorted(dm_soundex('The quick brown fox', max_length=20,
    ... zero_pad=False))
    ['35457976754', '3557976754']


def encode(self, word, max_length=-<NUM_LIT:1>, keep_vowels=False, vowel_char='<STR_LIT:*>'):

<EOL>word = unicode_normalize('<STR_LIT>', text_type(word.upper()))<EOL>word = word.replace('<STR_LIT>', '<STR_LIT>')<EOL>word = '<STR_LIT>'.join(c for c in word if c in self._uc_set)<EOL>if word[:<NUM_LIT:3>] in {'<STR_LIT>', '<STR_LIT>', '<STR_LIT>'}:<EOL><INDENT>word = '<STR_LIT>' + word[<NUM_LIT:3>:]<EOL><DEDENT>elif word[:<NUM_LIT:2>] == '<STR_LIT>':<EOL><INDENT>word = '<STR_LIT>' + word[<NUM_LIT:2>:]<EOL><DEDENT>pos = len(word) - <NUM_LIT:2><EOL>while pos > -<NUM_LIT:1>:<EOL><INDENT>if word[pos : pos + <NUM_LIT:2>] in {<EOL>'<STR_LIT>',<EOL>'<STR_LIT>',<EOL>'<STR_LIT>',<EOL>'<STR_LIT>',<EOL>'<STR_LIT>',<EOL>'<STR_LIT>',<EOL>'<STR_LIT>',<EOL>'<STR_LIT>',<EOL>'<STR_LIT>',<EOL>'<STR_LIT>',<EOL>}:<EOL><INDENT>word = word[: pos + <NUM_LIT:1>] + word[pos + <NUM_LIT:2> :]<EOL>pos += <NUM_LIT:1><EOL><DEDENT>pos -= <NUM_LIT:1><EOL><DEDENT>word = word.replace('<STR_LIT:X>', '<STR_LIT>')<EOL>word = word.replace('<STR_LIT>', '<STR_LIT>')<EOL>word = word.replace('<STR_LIT>', '<STR_LIT>')<EOL>word = word.replace('<STR_LIT>', '<STR_LIT>')<EOL>word = word.replace('<STR_LIT>', '<STR_LIT>')<EOL>pos = word.find('<STR_LIT>', <NUM_LIT:1>)<EOL>while pos != -<NUM_LIT:1>:<EOL><INDENT>if word[pos - <NUM_LIT:1> : pos] not in self._uc_vy_set:<EOL><INDENT>word = word[:pos] + '<STR_LIT:S>' + word[pos + <NUM_LIT:1> :]<EOL><DEDENT>pos = word.find('<STR_LIT>', pos + <NUM_LIT:1>)<EOL><DEDENT>word = word.replace('<STR_LIT:C>', '<STR_LIT>')<EOL>word = word.replace('<STR_LIT>', '<STR_LIT:S>')<EOL>word = word.replace('<STR_LIT>', '<STR_LIT:R>')<EOL>word = word.replace('<STR_LIT>', '<STR_LIT>')<EOL>word = word.replace('<STR_LIT>', '<STR_LIT>')<EOL>word = word.replace('<STR_LIT:T>', '<STR_LIT:D>')<EOL>word = word.replace('<STR_LIT>', '<STR_LIT:F>')<EOL>pos = word.find('<STR_LIT>', <NUM_LIT:0>)<EOL>while pos != -<NUM_LIT:1>:<EOL><INDENT>if pos > <NUM_LIT:1> and word[pos - <NUM_LIT:1> : pos] not in self._uc_vy_set | {<EOL>'<STR_LIT:L>',<EOL>'<STR_LIT:N>',<EOL>'<STR_LIT:R>',<EOL>}:<EOL><INDENT>word = word[: pos - <NUM_LIT:1>] + word[pos:]<EOL>pos -= <NUM_LIT:1><EOL><DEDENT>pos = word.find('<STR_LIT>', pos + <NUM_LIT:1>)<EOL><DEDENT>if max_length > <NUM_LIT:0> and word[-<NUM_LIT:1>:] == '<STR_LIT:E>':<EOL><INDENT>word = word[:-<NUM_LIT:1>]<EOL><DEDENT>word = self._delete_consecutive_repeats(word)<EOL>if word[:<NUM_LIT:2>] == '<STR_LIT>':<EOL><INDENT>word = word[<NUM_LIT:1>:]<EOL><DEDENT>if word[-<NUM_LIT:2>:] == '<STR_LIT>':<EOL><INDENT>word = word[:-<NUM_LIT:1>]<EOL><DEDENT>elif word[-<NUM_LIT:2>:] == '<STR_LIT>':<EOL><INDENT>if word[-<NUM_LIT:3>:-<NUM_LIT:2>] in self._uc_vy_set:<EOL><INDENT>word = word[:-<NUM_LIT:2>] + '<STR_LIT:F>'<EOL><DEDENT>else:<EOL><INDENT>word = word[:-<NUM_LIT:2>] + '<STR_LIT>'<EOL><DEDENT><DEDENT>word = word.replace('<STR_LIT>', '<STR_LIT>')<EOL>if max_length > <NUM_LIT:0>:<EOL><INDENT>word = word.replace('<STR_LIT>', '<STR_LIT:F>')<EOL><DEDENT>first = <NUM_LIT:1> + (<NUM_LIT:1> if max_length > <NUM_LIT:0> else <NUM_LIT:0>)<EOL>code = '<STR_LIT>'<EOL>for pos, char in enumerate(word):<EOL><INDENT>if char in self._uc_vy_set:<EOL><INDENT>if first or keep_vowels:<EOL><INDENT>code += vowel_char<EOL>first -= <NUM_LIT:1><EOL><DEDENT><DEDENT>elif pos > <NUM_LIT:0> and char in {'<STR_LIT>', '<STR_LIT:H>'}:<EOL><INDENT>continue<EOL><DEDENT>else:<EOL><INDENT>code += char<EOL><DEDENT><DEDENT>if max_length > <NUM_LIT:0>:<EOL><INDENT>if len(code) > max_length and code[-<NUM_LIT:1>:] == '<STR_LIT:S>':<EOL><INDENT>code = code[:-<NUM_LIT:1>]<EOL><DEDENT>if keep_vowels:<EOL><INDENT>code = code[:max_length]<EOL><DEDENT>else:<EOL><INDENT>code = code[: max_length + <NUM_LIT:2>]<EOL>while len(code) > max_length:<EOL><INDENT>vowels = len(code) - max_length<EOL>excess = vowels - <NUM_LIT:1><EOL>word = code<EOL>code = '<STR_LIT>'<EOL>for char in word:<EOL><INDENT>if char == vowel_char:<EOL><INDENT>if vowels:<EOL><INDENT>code += char<EOL>vowels -= <NUM_LIT:1><EOL><DEDENT><DEDENT>else:<EOL><INDENT>code += char<EOL><DEDENT><DEDENT>code = code[: max_length + excess]<EOL><DEDENT><DEDENT>code += '<STR_LIT:U+0020>' * (max_length - len(code))<EOL><DEDENT>return code<EOL>

r"""Return the Dolby Code of a name.

        Parameters
        ----------
        word : str
            The word to transform
        max_length : int
            Maximum length of the returned Dolby code -- this also activates
            the fixed-length code mode if it is greater than 0
        keep_vowels : bool
            If True, retains all vowel markers
        vowel_char : str
            The vowel marker character (default to \*)

        Returns
        -------
        str
            The Dolby Code

        Examples
        --------
        >>> pe = Dolby()
        >>> pe.encode('Hansen')
        'H*NSN'
        >>> pe.encode('Larsen')
        'L*RSN'
        >>> pe.encode('Aagaard')
        '*GR'
        >>> pe.encode('Braaten')
        'BR*DN'
        >>> pe.encode('Sandvik')
        'S*NVK'
        >>> pe.encode('Hansen', max_length=6)
        'H*NS*N'
        >>> pe.encode('Larsen', max_length=6)
        'L*RS*N'
        >>> pe.encode('Aagaard', max_length=6)
        '*G*R  '
        >>> pe.encode('Braaten', max_length=6)
        'BR*D*N'
        >>> pe.encode('Sandvik', max_length=6)
        'S*NF*K'

        >>> pe.encode('Smith')
        'SM*D'
        >>> pe.encode('Waters')
        'W*DRS'
        >>> pe.encode('James')
        'J*MS'
        >>> pe.encode('Schmidt')
        'SM*D'
        >>> pe.encode('Ashcroft')
        '*SKRFD'
        >>> pe.encode('Smith', max_length=6)
        'SM*D  '
        >>> pe.encode('Waters', max_length=6)
        'W*D*RS'
        >>> pe.encode('James', max_length=6)
        'J*M*S '
        >>> pe.encode('Schmidt', max_length=6)
        'SM*D  '
        >>> pe.encode('Ashcroft', max_length=6)
        '*SKRFD'


def dolby(word, max_length=-<NUM_LIT:1>, keep_vowels=False, vowel_char='<STR_LIT:*>'):

return Dolby().encode(word, max_length, keep_vowels, vowel_char)<EOL>

r"""Return the Dolby Code of a name.

    This is a wrapper for :py:meth:`Dolby.encode`.

    Parameters
    ----------
    word : str
        The word to transform
    max_length : int
        Maximum length of the returned Dolby code -- this also activates the
        fixed-length code mode if it is greater than 0
    keep_vowels : bool
        If True, retains all vowel markers
    vowel_char : str
        The vowel marker character (default to \*)

    Returns
    -------
    str
        The Dolby Code

    Examples
    --------
    >>> dolby('Hansen')
    'H*NSN'
    >>> dolby('Larsen')
    'L*RSN'
    >>> dolby('Aagaard')
    '*GR'
    >>> dolby('Braaten')
    'BR*DN'
    >>> dolby('Sandvik')
    'S*NVK'
    >>> dolby('Hansen', max_length=6)
    'H*NS*N'
    >>> dolby('Larsen', max_length=6)
    'L*RS*N'
    >>> dolby('Aagaard', max_length=6)
    '*G*R  '
    >>> dolby('Braaten', max_length=6)
    'BR*D*N'
    >>> dolby('Sandvik', max_length=6)
    'S*NF*K'

    >>> dolby('Smith')
    'SM*D'
    >>> dolby('Waters')
    'W*DRS'
    >>> dolby('James')
    'J*MS'
    >>> dolby('Schmidt')
    'SM*D'
    >>> dolby('Ashcroft')
    '*SKRFD'
    >>> dolby('Smith', max_length=6)
    'SM*D  '
    >>> dolby('Waters', max_length=6)
    'W*D*RS'
    >>> dolby('James', max_length=6)
    'J*M*S '
    >>> dolby('Schmidt', max_length=6)
    'SM*D  '
    >>> dolby('Ashcroft', max_length=6)
    '*SKRFD'


word = unicode_normalize('<STR_LIT>', text_type(word.upper()))<EOL>for i, j in self._substitutions:<EOL><INDENT>word = word.replace(i, j)<EOL><DEDENT>word = word.translate(self._trans)<EOL>return '<STR_LIT>'.join(<EOL>c<EOL>for c in self._delete_consecutive_repeats(word)<EOL>if c in self._uc_set<EOL>)<EOL>

Return the Phonem code for a word.

        Parameters
        ----------
        word : str
        The word to transform

        Returns
        -------
        str
            The Phonem value

        Examples
        --------
        >>> pe = Phonem()
        >>> pe.encode('Christopher')
        'CRYSDOVR'
        >>> pe.encode('Niall')
        'NYAL'
        >>> pe.encode('Smith')
        'SMYD'
        >>> pe.encode('Schmidt')
        'CMYD'


return StatisticsCanada().encode(word, max_length)<EOL>

Return the Statistics Canada code for a word.

    This is a wrapper for :py:meth:`StatisticsCanada.encode`.

    Parameters
    ----------
    word : str
        The word to transform
    max_length : int
        The maximum length (default 4) of the code to return

    Returns
    -------
    str
        The Statistics Canada name code value

    Examples
    --------
    >>> statistics_canada('Christopher')
    'CHRS'
    >>> statistics_canada('Niall')
    'NL'
    >>> statistics_canada('Smith')
    'SMTH'
    >>> statistics_canada('Schmidt')
    'SCHM'


return Caverphone().encode(word, version)<EOL>

Return the Caverphone code for a word.

    This is a wrapper for :py:meth:`Caverphone.encode`.

    Parameters
    ----------
    word : str
        The word to transform
    version : int
        The version of Caverphone to employ for encoding (defaults to 2)

    Returns
    -------
    str
        The Caverphone value

    Examples
    --------
    >>> caverphone('Christopher')
    'KRSTFA1111'
    >>> caverphone('Niall')
    'NA11111111'
    >>> caverphone('Smith')
    'SMT1111111'
    >>> caverphone('Schmidt')
    'SKMT111111'

    >>> caverphone('Christopher', 1)
    'KRSTF1'
    >>> caverphone('Niall', 1)
    'N11111'
    >>> caverphone('Smith', 1)
    'SMT111'
    >>> caverphone('Schmidt', 1)
    'SKMT11'


def pshp_soundex_last(lname, max_length=<NUM_LIT:4>, german=False):

return PSHPSoundexLast().encode(lname, max_length, german)<EOL>

Calculate the PSHP Soundex/Viewex Coding of a last name.

    This is a wrapper for :py:meth:`PSHPSoundexLast.encode`.

    Parameters
    ----------
    lname : str
        The last name to encode
    max_length : int
        The length of the code returned (defaults to 4)
    german : bool
        Set to True if the name is German (different rules apply)

    Returns
    -------
    str
        The PSHP Soundex/Viewex Coding

    Examples
    --------
    >>> pshp_soundex_last('Smith')
    'S530'
    >>> pshp_soundex_last('Waters')
    'W350'
    >>> pshp_soundex_last('James')
    'J500'
    >>> pshp_soundex_last('Schmidt')
    'S530'
    >>> pshp_soundex_last('Ashcroft')
    'A225'


def encode(self, lname, max_length=<NUM_LIT:4>, german=False):

lname = unicode_normalize('<STR_LIT>', text_type(lname.upper()))<EOL>lname = lname.replace('<STR_LIT>', '<STR_LIT>')<EOL>lname = '<STR_LIT>'.join(c for c in lname if c in self._uc_set)<EOL>if lname[:<NUM_LIT:3>] == '<STR_LIT>' or lname[:<NUM_LIT:3>] == '<STR_LIT>':<EOL><INDENT>lname = lname[<NUM_LIT:3>:].strip()<EOL><DEDENT>if not german:<EOL><INDENT>if lname[:<NUM_LIT:3>] == '<STR_LIT>':<EOL><INDENT>lname = '<STR_LIT:M>' + lname[<NUM_LIT:3>:]<EOL><DEDENT>elif lname[:<NUM_LIT:2>] == '<STR_LIT>':<EOL><INDENT>lname = '<STR_LIT:M>' + lname[<NUM_LIT:2>:]<EOL><DEDENT><DEDENT>if lname[:<NUM_LIT:1>] in {'<STR_LIT:E>', '<STR_LIT:I>', '<STR_LIT:O>', '<STR_LIT>'}:<EOL><INDENT>lname = '<STR_LIT:A>' + lname[<NUM_LIT:1>:]<EOL><DEDENT>elif lname[:<NUM_LIT:2>] in {'<STR_LIT>', '<STR_LIT>', '<STR_LIT>'}:<EOL><INDENT>lname = '<STR_LIT>' + lname[<NUM_LIT:1>:]<EOL><DEDENT>elif lname[:<NUM_LIT:2>] in {'<STR_LIT>', '<STR_LIT>', '<STR_LIT>'}:<EOL><INDENT>lname = '<STR_LIT:S>' + lname[<NUM_LIT:1>:]<EOL><DEDENT>elif lname[:<NUM_LIT:3>] == '<STR_LIT>':<EOL><INDENT>lname = '<STR_LIT>' + lname[<NUM_LIT:1>:]<EOL><DEDENT>elif lname[:<NUM_LIT:1>] == '<STR_LIT:C>' and lname[:<NUM_LIT:2>] != '<STR_LIT>':<EOL><INDENT>lname = '<STR_LIT>' + lname[<NUM_LIT:1>:]<EOL><DEDENT>if lname[:<NUM_LIT:2>] == '<STR_LIT>':<EOL><INDENT>lname = '<STR_LIT:N>' + lname[<NUM_LIT:1>:]<EOL><DEDENT>elif lname[:<NUM_LIT:2>] == '<STR_LIT>':<EOL><INDENT>lname = '<STR_LIT:F>' + lname[<NUM_LIT:1>:]<EOL><DEDENT>elif lname[:<NUM_LIT:3>] in {'<STR_LIT>', '<STR_LIT>'}:<EOL><INDENT>lname = '<STR_LIT>' + lname[<NUM_LIT:1>:]<EOL><DEDENT>if german and lname[:<NUM_LIT:1>] in {'<STR_LIT>', '<STR_LIT:M>', '<STR_LIT:Y>', '<STR_LIT>'}:<EOL><INDENT>lname = {'<STR_LIT>': '<STR_LIT>', '<STR_LIT:M>': '<STR_LIT:N>', '<STR_LIT:Y>': '<STR_LIT>', '<STR_LIT>': '<STR_LIT:S>'}[lname[<NUM_LIT:0>]] + lname[<EOL><NUM_LIT:1>:<EOL>]<EOL><DEDENT>code = lname[:<NUM_LIT:1>]<EOL>if german:  <EOL><INDENT>if lname[-<NUM_LIT:3>:] == '<STR_LIT>':<EOL><INDENT>lname = lname[:-<NUM_LIT:3>]<EOL><DEDENT>elif lname[-<NUM_LIT:2>:] == '<STR_LIT>':<EOL><INDENT>lname = lname[:-<NUM_LIT:2>]<EOL><DEDENT>if lname[-<NUM_LIT:3>:] == '<STR_LIT>':<EOL><INDENT>lname = lname[:-<NUM_LIT:3>]<EOL><DEDENT>elif lname[-<NUM_LIT:2>:] == '<STR_LIT>':<EOL><INDENT>lname = lname[:-<NUM_LIT:2>]<EOL><DEDENT>if lname[-<NUM_LIT:1>:] == '<STR_LIT>':<EOL><INDENT>lname = lname[:-<NUM_LIT:1>]<EOL><DEDENT>elif lname[-<NUM_LIT:2>:] == '<STR_LIT>':<EOL><INDENT>lname = lname[:-<NUM_LIT:2>]<EOL><DEDENT><DEDENT>if lname[-<NUM_LIT:1>:] == '<STR_LIT:R>':<EOL><INDENT>lname = lname[:-<NUM_LIT:1>] + '<STR_LIT:N>'<EOL><DEDENT>elif lname[-<NUM_LIT:2>:] in {'<STR_LIT>', '<STR_LIT>'}:<EOL><INDENT>lname = lname[:-<NUM_LIT:2>]<EOL><DEDENT>if lname[-<NUM_LIT:2>:] == '<STR_LIT>':<EOL><INDENT>lname = lname[:-<NUM_LIT:2>]<EOL><DEDENT>elif lname[-<NUM_LIT:1>:] == '<STR_LIT:S>':<EOL><INDENT>lname = lname[:-<NUM_LIT:1>]<EOL><DEDENT>if not german:<EOL><INDENT>l5_repl = {'<STR_LIT>': '<STR_LIT>', '<STR_LIT>': '<STR_LIT>'}<EOL>l4_repl = {<EOL>'<STR_LIT>': '<STR_LIT>',<EOL>'<STR_LIT>': '<STR_LIT>',<EOL>'<STR_LIT>': '<STR_LIT>',<EOL>'<STR_LIT>': '<STR_LIT>',<EOL>}<EOL>if lname[-<NUM_LIT:5>:] in l5_repl:<EOL><INDENT>lname = lname[:-<NUM_LIT:5>] + l5_repl[lname[-<NUM_LIT:5>:]]<EOL><DEDENT>elif lname[-<NUM_LIT:4>:] in l4_repl:<EOL><INDENT>lname = lname[:-<NUM_LIT:4>] + l4_repl[lname[-<NUM_LIT:4>:]]<EOL><DEDENT><DEDENT>if lname[-<NUM_LIT:2>:] in {'<STR_LIT>', '<STR_LIT>'}:<EOL><INDENT>lname = lname[:-<NUM_LIT:1>]<EOL><DEDENT>if not german and lname[-<NUM_LIT:3>:] in {'<STR_LIT>', '<STR_LIT>'}:<EOL><INDENT>lname = lname[:-<NUM_LIT:3>] + '<STR_LIT:A>' + lname[-<NUM_LIT:2>:]<EOL><DEDENT>lname = lname.replace('<STR_LIT>', '<STR_LIT:C>')<EOL>lname = lname.replace('<STR_LIT>', '<STR_LIT:S>')<EOL>lname = lname.replace('<STR_LIT>', '<STR_LIT:T>')<EOL>lname = lname.replace('<STR_LIT>', '<STR_LIT:N>')<EOL>lname = lname.replace('<STR_LIT>', '<STR_LIT:N>')<EOL>lname = lname.replace('<STR_LIT>', '<STR_LIT:M>')<EOL>lname = lname.replace('<STR_LIT>', '<STR_LIT:M>')<EOL>lname = lname.replace('<STR_LIT>', '<STR_LIT>')<EOL>lname = lname.replace('<STR_LIT>', '<STR_LIT>')<EOL>lname = lname.translate(self._trans)<EOL>lname = self._delete_consecutive_repeats(lname)<EOL>code += lname[<NUM_LIT:1>:]<EOL>code = code.replace('<STR_LIT:0>', '<STR_LIT>')  <EOL>if max_length != -<NUM_LIT:1>:<EOL><INDENT>if len(code) < max_length:<EOL><INDENT>code += '<STR_LIT:0>' * (max_length - len(code))<EOL><DEDENT>else:<EOL><INDENT>code = code[:max_length]<EOL><DEDENT><DEDENT>return code<EOL>

Calculate the PSHP Soundex/Viewex Coding of a last name.

        Parameters
        ----------
        lname : str
            The last name to encode
        max_length : int
            The length of the code returned (defaults to 4)
        german : bool
            Set to True if the name is German (different rules apply)

        Returns
        -------
        str
            The PSHP Soundex/Viewex Coding

        Examples
        --------
        >>> pe = PSHPSoundexLast()
        >>> pe.encode('Smith')
        'S530'
        >>> pe.encode('Waters')
        'W350'
        >>> pe.encode('James')
        'J500'
        >>> pe.encode('Schmidt')
        'S530'
        >>> pe.encode('Ashcroft')
        'A225'


def phonet(word, mode=<NUM_LIT:1>, lang='<STR_LIT>'):

return Phonet().encode(word, mode, lang)<EOL>

Return the phonet code for a word.

    This is a wrapper for :py:meth:`Phonet.encode`.

    Parameters
    ----------
    word : str
        The word to transform
    mode : int
        The ponet variant to employ (1 or 2)
    lang : str
        ``de`` (default) for German, ``none`` for no language

    Returns
    -------
    str
        The phonet value

    Examples
    --------
    >>> phonet('Christopher')
    'KRISTOFA'
    >>> phonet('Niall')
    'NIAL'
    >>> phonet('Smith')
    'SMIT'
    >>> phonet('Schmidt')
    'SHMIT'

    >>> phonet('Christopher', mode=2)
    'KRIZTUFA'
    >>> phonet('Niall', mode=2)
    'NIAL'
    >>> phonet('Smith', mode=2)
    'ZNIT'
    >>> phonet('Schmidt', mode=2)
    'ZNIT'

    >>> phonet('Christopher', lang='none')
    'CHRISTOPHER'
    >>> phonet('Niall', lang='none')
    'NIAL'
    >>> phonet('Smith', lang='none')
    'SMITH'
    >>> phonet('Schmidt', lang='none')
    'SCHMIDT'


def encode(self, word, mode=<NUM_LIT:1>, lang='<STR_LIT>'):

phonet_hash = Counter()<EOL>alpha_pos = Counter()<EOL>phonet_hash_1 = Counter()<EOL>phonet_hash_2 = Counter()<EOL>def _initialize_phonet(lang):<EOL><INDENT>"""<STR_LIT>"""<EOL>if lang == '<STR_LIT:none>':<EOL><INDENT>_phonet_rules = self._rules_no_lang<EOL><DEDENT>else:<EOL><INDENT>_phonet_rules = self._rules_german<EOL><DEDENT>phonet_hash['<STR_LIT>'] = -<NUM_LIT:1><EOL>for j in {<EOL>'<STR_LIT>',<EOL>'<STR_LIT>',<EOL>'<STR_LIT>',<EOL>'<STR_LIT>',<EOL>'<STR_LIT>',<EOL>'<STR_LIT>',<EOL>'<STR_LIT>',<EOL>'<STR_LIT>',<EOL>'<STR_LIT>',<EOL>'<STR_LIT>',<EOL>'<STR_LIT>',<EOL>'<STR_LIT>',<EOL>'<STR_LIT>',<EOL>'<STR_LIT>',<EOL>'<STR_LIT>',<EOL>'<STR_LIT>',<EOL>'<STR_LIT>',<EOL>'<STR_LIT>',<EOL>'<STR_LIT>',<EOL>'<STR_LIT>',<EOL>'<STR_LIT>',<EOL>'<STR_LIT>',<EOL>'<STR_LIT>',<EOL>'<STR_LIT>',<EOL>'<STR_LIT>',<EOL>'<STR_LIT>',<EOL>'<STR_LIT>',<EOL>'<STR_LIT>',<EOL>'<STR_LIT>',<EOL>'<STR_LIT>',<EOL>'<STR_LIT>',<EOL>'<STR_LIT>',<EOL>'<STR_LIT>',<EOL>'<STR_LIT>',<EOL>}:<EOL><INDENT>alpha_pos[j] = <NUM_LIT:1><EOL>phonet_hash[j] = -<NUM_LIT:1><EOL><DEDENT>for i, j in enumerate('<STR_LIT>'):<EOL><INDENT>alpha_pos[j] = i + <NUM_LIT:2><EOL>phonet_hash[j] = -<NUM_LIT:1><EOL><DEDENT>for i in range(<NUM_LIT>):<EOL><INDENT>for j in range(<NUM_LIT>):<EOL><INDENT>phonet_hash_1[i, j] = -<NUM_LIT:1><EOL>phonet_hash_2[i, j] = -<NUM_LIT:1><EOL><DEDENT><DEDENT>for i in range(len(_phonet_rules)):<EOL><INDENT>rule = _phonet_rules[i]<EOL>if rule and i % <NUM_LIT:3> == <NUM_LIT:0>:<EOL><INDENT>k = _phonet_rules[i][<NUM_LIT:0>]<EOL>if phonet_hash[k] < <NUM_LIT:0> and (<EOL>_phonet_rules[i + <NUM_LIT:1>] or _phonet_rules[i + <NUM_LIT:2>]<EOL>):<EOL><INDENT>phonet_hash[k] = i<EOL><DEDENT>if k and alpha_pos[k] >= <NUM_LIT:2>:<EOL><INDENT>k = alpha_pos[k]<EOL>j = k - <NUM_LIT:2><EOL>rule = rule[<NUM_LIT:1>:]<EOL>if not rule:<EOL><INDENT>rule = '<STR_LIT:U+0020>'<EOL><DEDENT>elif rule[<NUM_LIT:0>] == '<STR_LIT:(>':<EOL><INDENT>rule = rule[<NUM_LIT:1>:]<EOL><DEDENT>else:<EOL><INDENT>rule = rule[<NUM_LIT:0>]<EOL><DEDENT>while rule and (rule[<NUM_LIT:0>] != '<STR_LIT:)>'):<EOL><INDENT>k = alpha_pos[rule[<NUM_LIT:0>]]<EOL>if k > <NUM_LIT:0>:<EOL><INDENT>if phonet_hash_1[j, k] < <NUM_LIT:0>:<EOL><INDENT>phonet_hash_1[j, k] = i<EOL>phonet_hash_2[j, k] = i<EOL><DEDENT>if phonet_hash_2[j, k] >= (i - <NUM_LIT:30>):<EOL><INDENT>phonet_hash_2[j, k] = i<EOL><DEDENT>else:<EOL><INDENT>k = -<NUM_LIT:1><EOL><DEDENT><DEDENT>if k <= <NUM_LIT:0>:<EOL><INDENT>if phonet_hash_1[j, <NUM_LIT:0>] < <NUM_LIT:0>:<EOL><INDENT>phonet_hash_1[j, <NUM_LIT:0>] = i<EOL><DEDENT>phonet_hash_2[j, <NUM_LIT:0>] = i<EOL><DEDENT>rule = rule[<NUM_LIT:1>:]<EOL><DEDENT><DEDENT><DEDENT><DEDENT><DEDENT>def _phonet(term, mode, lang):<EOL><INDENT>"""<STR_LIT>"""<EOL>if lang == '<STR_LIT:none>':<EOL><INDENT>_phonet_rules = self._rules_no_lang<EOL><DEDENT>else:<EOL><INDENT>_phonet_rules = self._rules_german<EOL><DEDENT>char0 = '<STR_LIT>'<EOL>dest = term<EOL>if not term:<EOL><INDENT>return '<STR_LIT>'<EOL><DEDENT>term_length = len(term)<EOL>src = term.translate(self._upper_trans)<EOL>i = <NUM_LIT:0><EOL>j = <NUM_LIT:0><EOL>zeta = <NUM_LIT:0><EOL>while i < len(src):<EOL><INDENT>char = src[i]<EOL>pos = alpha_pos[char]<EOL>if pos >= <NUM_LIT:2>:<EOL><INDENT>xpos = pos - <NUM_LIT:2><EOL>if i + <NUM_LIT:1> == len(src):<EOL><INDENT>pos = alpha_pos['<STR_LIT>']<EOL><DEDENT>else:<EOL><INDENT>pos = alpha_pos[src[i + <NUM_LIT:1>]]<EOL><DEDENT>start1 = phonet_hash_1[xpos, pos]<EOL>start2 = phonet_hash_1[xpos, <NUM_LIT:0>]<EOL>end1 = phonet_hash_2[xpos, pos]<EOL>end2 = phonet_hash_2[xpos, <NUM_LIT:0>]<EOL>if (start2 >= <NUM_LIT:0>) and ((start1 < <NUM_LIT:0>) or (start2 < start1)):<EOL><INDENT>pos = start1<EOL>start1 = start2<EOL>start2 = pos<EOL>pos = end1<EOL>end1 = end2<EOL>end2 = pos<EOL><DEDENT>if (end1 >= start2) and (start2 >= <NUM_LIT:0>):<EOL><INDENT>if end2 > end1:<EOL><INDENT>end1 = end2<EOL><DEDENT>start2 = -<NUM_LIT:1><EOL>end2 = -<NUM_LIT:1><EOL><DEDENT><DEDENT>else:<EOL><INDENT>pos = phonet_hash[char]<EOL>start1 = pos<EOL>end1 = <NUM_LIT><EOL>start2 = -<NUM_LIT:1><EOL>end2 = -<NUM_LIT:1><EOL><DEDENT>pos = start1<EOL>zeta0 = <NUM_LIT:0><EOL>if pos >= <NUM_LIT:0>:<EOL><INDENT>while (_phonet_rules[pos] is None) or (<EOL>_phonet_rules[pos][<NUM_LIT:0>] == char<EOL>):<EOL><INDENT>if pos > end1:<EOL><INDENT>if start2 > <NUM_LIT:0>:<EOL><INDENT>pos = start2<EOL>start1 = start2<EOL>start2 = -<NUM_LIT:1><EOL>end1 = end2<EOL>end2 = -<NUM_LIT:1><EOL>continue<EOL><DEDENT>break<EOL><DEDENT>if (_phonet_rules[pos] is None) or (<EOL>_phonet_rules[pos + mode] is None<EOL>):<EOL><INDENT>pos += <NUM_LIT:3><EOL>continue<EOL><DEDENT>matches = <NUM_LIT:1>  <EOL>priority = <NUM_LIT:5>  <EOL>rule = _phonet_rules[pos]<EOL>rule = rule[<NUM_LIT:1>:]<EOL>while (<EOL>rule<EOL>and (len(src) > (i + matches))<EOL>and (src[i + matches] == rule[<NUM_LIT:0>])<EOL>and not rule[<NUM_LIT:0>].isdigit()<EOL>and (rule not in '<STR_LIT>')<EOL>):<EOL><INDENT>matches += <NUM_LIT:1><EOL>rule = rule[<NUM_LIT:1>:]<EOL><DEDENT>if rule and (rule[<NUM_LIT:0>] == '<STR_LIT:(>'):<EOL><INDENT>if (<EOL>(len(src) > (i + matches))<EOL>and src[i + matches].isalpha()<EOL>and (src[i + matches] in rule[<NUM_LIT:1>:])<EOL>):<EOL><INDENT>matches += <NUM_LIT:1><EOL>while rule and rule[<NUM_LIT:0>] != '<STR_LIT:)>':<EOL><INDENT>rule = rule[<NUM_LIT:1>:]<EOL><DEDENT>rule = rule[<NUM_LIT:1>:]<EOL><DEDENT><DEDENT>if rule:<EOL><INDENT>priority0 = ord(rule[<NUM_LIT:0>])<EOL><DEDENT>else:<EOL><INDENT>priority0 = <NUM_LIT:0><EOL><DEDENT>matches0 = matches<EOL>while rule and rule[<NUM_LIT:0>] == '<STR_LIT:->' and matches > <NUM_LIT:1>:<EOL><INDENT>matches -= <NUM_LIT:1><EOL>rule = rule[<NUM_LIT:1>:]<EOL><DEDENT>if rule and rule[<NUM_LIT:0>] == '<STR_LIT:<>':<EOL><INDENT>rule = rule[<NUM_LIT:1>:]<EOL><DEDENT>if rule and rule[<NUM_LIT:0>].isdigit():<EOL><INDENT>priority = int(rule[<NUM_LIT:0>])<EOL>rule = rule[<NUM_LIT:1>:]<EOL><DEDENT>if rule and rule[<NUM_LIT:0>:<NUM_LIT:2>] == '<STR_LIT>':<EOL><INDENT>rule = rule[<NUM_LIT:1>:]<EOL><DEDENT>if (<EOL>not rule<EOL>or (<EOL>(rule[<NUM_LIT:0>] == '<STR_LIT>')<EOL>and ((i == <NUM_LIT:0>) or not src[i - <NUM_LIT:1>].isalpha())<EOL>and (<EOL>(rule[<NUM_LIT:1>:<NUM_LIT:2>] != '<STR_LIT:$>')<EOL>or (<EOL>not (<EOL>src[<EOL>i + matches0 : i + matches0 + <NUM_LIT:1><EOL>].isalpha()<EOL>)<EOL>and (<EOL>src[<EOL>i + matches0 : i + matches0 + <NUM_LIT:1><EOL>]<EOL>!= '<STR_LIT:.>'<EOL>)<EOL>)<EOL>)<EOL>)<EOL>or (<EOL>(rule[<NUM_LIT:0>] == '<STR_LIT:$>')<EOL>and (i > <NUM_LIT:0>)<EOL>and src[i - <NUM_LIT:1>].isalpha()<EOL>and (<EOL>(<EOL>not src[<EOL>i + matches0 : i + matches0 + <NUM_LIT:1><EOL>].isalpha()<EOL>)<EOL>and (<EOL>src[i + matches0 : i + matches0 + <NUM_LIT:1>]<EOL>!= '<STR_LIT:.>'<EOL>)<EOL>)<EOL>)<EOL>):<EOL><INDENT>pos0 = -<NUM_LIT:1><EOL>start3 = <NUM_LIT:0><EOL>start4 = <NUM_LIT:0><EOL>end3 = <NUM_LIT:0><EOL>end4 = <NUM_LIT:0><EOL>if (<EOL>(matches > <NUM_LIT:1>)<EOL>and src[i + matches : i + matches + <NUM_LIT:1>]<EOL>and (priority0 != ord('<STR_LIT:->'))<EOL>):<EOL><INDENT>char0 = src[i + matches - <NUM_LIT:1>]<EOL>pos0 = alpha_pos[char0]<EOL>if pos0 >= <NUM_LIT:2> and src[i + matches]:<EOL><INDENT>xpos = pos0 - <NUM_LIT:2><EOL>pos0 = alpha_pos[src[i + matches]]<EOL>start3 = phonet_hash_1[xpos, pos0]<EOL>start4 = phonet_hash_1[xpos, <NUM_LIT:0>]<EOL>end3 = phonet_hash_2[xpos, pos0]<EOL>end4 = phonet_hash_2[xpos, <NUM_LIT:0>]<EOL>if (start4 >= <NUM_LIT:0>) and (<EOL>(start3 < <NUM_LIT:0>) or (start4 < start3)<EOL>):<EOL><INDENT>pos0 = start3<EOL>start3 = start4<EOL>start4 = pos0<EOL>pos0 = end3<EOL>end3 = end4<EOL>end4 = pos0<EOL><DEDENT>if (end3 >= start4) and (start4 >= <NUM_LIT:0>):<EOL><INDENT>if end4 > end3:<EOL><INDENT>end3 = end4<EOL><DEDENT>start4 = -<NUM_LIT:1><EOL>end4 = -<NUM_LIT:1><EOL><DEDENT><DEDENT>else:<EOL><INDENT>pos0 = phonet_hash[char0]<EOL>start3 = pos0<EOL>end3 = <NUM_LIT><EOL>start4 = -<NUM_LIT:1><EOL>end4 = -<NUM_LIT:1><EOL><DEDENT>pos0 = start3<EOL><DEDENT>if pos0 >= <NUM_LIT:0>:<EOL><INDENT>while (_phonet_rules[pos0] is None) or (<EOL>_phonet_rules[pos0][<NUM_LIT:0>] == char0<EOL>):<EOL><INDENT>if pos0 > end3:<EOL><INDENT>if start4 > <NUM_LIT:0>:<EOL><INDENT>pos0 = start4<EOL>start3 = start4<EOL>start4 = -<NUM_LIT:1><EOL>end3 = end4<EOL>end4 = -<NUM_LIT:1><EOL>continue<EOL><DEDENT>priority0 = -<NUM_LIT:1><EOL>break<EOL><DEDENT>if (_phonet_rules[pos0] is None) or (<EOL>_phonet_rules[pos0 + mode] is None<EOL>):<EOL><INDENT>pos0 += <NUM_LIT:3><EOL>continue<EOL><DEDENT>matches0 = matches<EOL>priority0 = <NUM_LIT:5><EOL>rule = _phonet_rules[pos0]<EOL>rule = rule[<NUM_LIT:1>:]<EOL>while (<EOL>rule<EOL>and (<EOL>src[<EOL>i + matches0 : i + matches0 + <NUM_LIT:1><EOL>]<EOL>== rule[<NUM_LIT:0>]<EOL>)<EOL>and (<EOL>not rule[<NUM_LIT:0>].isdigit()<EOL>or (rule in '<STR_LIT>')<EOL>)<EOL>):<EOL><INDENT>matches0 += <NUM_LIT:1><EOL>rule = rule[<NUM_LIT:1>:]<EOL><DEDENT>if rule and rule[<NUM_LIT:0>] == '<STR_LIT:(>':<EOL><INDENT>if src[<EOL>i + matches0 : i + matches0 + <NUM_LIT:1><EOL>].isalpha() and (<EOL>src[i + matches0] in rule[<NUM_LIT:1>:]<EOL>):<EOL><INDENT>matches0 += <NUM_LIT:1><EOL>while rule and rule[<NUM_LIT:0>] != '<STR_LIT:)>':<EOL><INDENT>rule = rule[<NUM_LIT:1>:]<EOL><DEDENT>rule = rule[<NUM_LIT:1>:]<EOL><DEDENT><DEDENT>while rule and rule[<NUM_LIT:0>] == '<STR_LIT:->':<EOL><INDENT>rule = rule[<NUM_LIT:1>:]<EOL><DEDENT>if rule and rule[<NUM_LIT:0>] == '<STR_LIT:<>':<EOL><INDENT>rule = rule[<NUM_LIT:1>:]<EOL><DEDENT>if rule and rule[<NUM_LIT:0>].isdigit():<EOL><INDENT>priority0 = int(rule[<NUM_LIT:0>])<EOL>rule = rule[<NUM_LIT:1>:]<EOL><DEDENT>if (<EOL>not rule<EOL>or<EOL>(<EOL>(rule[<NUM_LIT:0>] == '<STR_LIT:$>')<EOL>and not src[<EOL>i + matches0 : i + matches0 + <NUM_LIT:1><EOL>].isalpha()<EOL>and (<EOL>src[<EOL>i<EOL>+ matches0 : i<EOL>+ matches0<EOL>+ <NUM_LIT:1><EOL>]<EOL>!= '<STR_LIT:.>'<EOL>)<EOL>)<EOL>):<EOL><INDENT>if matches0 == matches:<EOL><INDENT>pos0 += <NUM_LIT:3><EOL>continue<EOL><DEDENT>if priority0 < priority:<EOL><INDENT>pos0 += <NUM_LIT:3><EOL>continue<EOL><DEDENT>break<EOL><DEDENT>pos0 += <NUM_LIT:3><EOL><DEDENT>if (priority0 >= priority) and (<EOL>(_phonet_rules[pos0] is not None)<EOL>and (_phonet_rules[pos0][<NUM_LIT:0>] == char0)<EOL>):<EOL><INDENT>pos += <NUM_LIT:3><EOL>continue<EOL><DEDENT><DEDENT>if _phonet_rules[pos] and (<EOL>'<STR_LIT:<>' in _phonet_rules[pos][<NUM_LIT:1>:]<EOL>):<EOL><INDENT>priority0 = <NUM_LIT:1><EOL><DEDENT>else:<EOL><INDENT>priority0 = <NUM_LIT:0><EOL><DEDENT>rule = _phonet_rules[pos + mode]<EOL>if (priority0 == <NUM_LIT:1>) and (zeta == <NUM_LIT:0>):<EOL><INDENT>if (<EOL>(j > <NUM_LIT:0>)<EOL>and rule<EOL>and (<EOL>(dest[j - <NUM_LIT:1>] == char)<EOL>or (dest[j - <NUM_LIT:1>] == rule[<NUM_LIT:0>])<EOL>)<EOL>):<EOL><INDENT>j -= <NUM_LIT:1><EOL><DEDENT>zeta0 = <NUM_LIT:1><EOL>zeta += <NUM_LIT:1><EOL>matches0 = <NUM_LIT:0><EOL>while rule and src[i + matches0]:<EOL><INDENT>src = (<EOL>src[<NUM_LIT:0> : i + matches0]<EOL>+ rule[<NUM_LIT:0>]<EOL>+ src[i + matches0 + <NUM_LIT:1> :]<EOL>)<EOL>matches0 += <NUM_LIT:1><EOL>rule = rule[<NUM_LIT:1>:]<EOL><DEDENT>if matches0 < matches:<EOL><INDENT>src = (<EOL>src[<NUM_LIT:0> : i + matches0]<EOL>+ src[i + matches :]<EOL>)<EOL><DEDENT>char = src[i]<EOL><DEDENT>else:<EOL><INDENT>i = i + matches - <NUM_LIT:1><EOL>zeta = <NUM_LIT:0><EOL>while len(rule) > <NUM_LIT:1>:<EOL><INDENT>if (j == <NUM_LIT:0>) or (dest[j - <NUM_LIT:1>] != rule[<NUM_LIT:0>]):<EOL><INDENT>dest = (<EOL>dest[<NUM_LIT:0>:j]<EOL>+ rule[<NUM_LIT:0>]<EOL>+ dest[min(len(dest), j + <NUM_LIT:1>) :]<EOL>)<EOL>j += <NUM_LIT:1><EOL><DEDENT>rule = rule[<NUM_LIT:1>:]<EOL><DEDENT>if not rule:<EOL><INDENT>rule = '<STR_LIT>'<EOL>char = '<STR_LIT>'<EOL><DEDENT>else:<EOL><INDENT>char = rule[<NUM_LIT:0>]<EOL><DEDENT>if (<EOL>_phonet_rules[pos]<EOL>and '<STR_LIT>' in _phonet_rules[pos][<NUM_LIT:1>:]<EOL>):<EOL><INDENT>if char:<EOL><INDENT>dest = (<EOL>dest[<NUM_LIT:0>:j]<EOL>+ char<EOL>+ dest[min(len(dest), j + <NUM_LIT:1>) :]<EOL>)<EOL>j += <NUM_LIT:1><EOL><DEDENT>src = src[i + <NUM_LIT:1> :]<EOL>i = <NUM_LIT:0><EOL>zeta0 = <NUM_LIT:1><EOL><DEDENT><DEDENT>break<EOL><DEDENT>pos += <NUM_LIT:3><EOL>if pos > end1 and start2 > <NUM_LIT:0>:<EOL><INDENT>pos = start2<EOL>start1 = start2<EOL>end1 = end2<EOL>start2 = -<NUM_LIT:1><EOL>end2 = -<NUM_LIT:1><EOL><DEDENT><DEDENT><DEDENT>if zeta0 == <NUM_LIT:0>:<EOL><INDENT>if char and ((j == <NUM_LIT:0>) or (dest[j - <NUM_LIT:1>] != char)):<EOL><INDENT>dest = (<EOL>dest[<NUM_LIT:0>:j] + char + dest[min(j + <NUM_LIT:1>, term_length) :]<EOL>)<EOL>j += <NUM_LIT:1><EOL><DEDENT>i += <NUM_LIT:1><EOL>zeta = <NUM_LIT:0><EOL><DEDENT><DEDENT>dest = dest[<NUM_LIT:0>:j]<EOL>return dest<EOL><DEDENT>_initialize_phonet(lang)<EOL>word = unicode_normalize('<STR_LIT>', text_type(word))<EOL>return _phonet(word, mode, lang)<EOL>

Return the phonet code for a word.

        Parameters
        ----------
        word : str
            The word to transform
        mode : int
            The ponet variant to employ (1 or 2)
        lang : str
            ``de`` (default) for German, ``none`` for no language

        Returns
        -------
        str
            The phonet value

        Examples
        --------
        >>> pe = Phonet()
        >>> pe.encode('Christopher')
        'KRISTOFA'
        >>> pe.encode('Niall')
        'NIAL'
        >>> pe.encode('Smith')
        'SMIT'
        >>> pe.encode('Schmidt')
        'SHMIT'

        >>> pe.encode('Christopher', mode=2)
        'KRIZTUFA'
        >>> pe.encode('Niall', mode=2)
        'NIAL'
        >>> pe.encode('Smith', mode=2)
        'ZNIT'
        >>> pe.encode('Schmidt', mode=2)
        'ZNIT'

        >>> pe.encode('Christopher', lang='none')
        'CHRISTOPHER'
        >>> pe.encode('Niall', lang='none')
        'NIAL'
        >>> pe.encode('Smith', lang='none')
        'SMITH'
        >>> pe.encode('Schmidt', lang='none')
        'SCHMIDT'