def encode(self, word):
def _after(word, pos, letters):<EOL><INDENT>"""<STR_LIT>"""<EOL>return pos > <NUM_LIT:0> and word[pos - <NUM_LIT:1>] in letters<EOL><DEDENT>def _before(word, pos, letters):<EOL><INDENT>"""<STR_LIT>"""<EOL>return pos + <NUM_LIT:1> < len(word) and word[pos + <NUM_LIT:1>] in letters<EOL><DEDENT>sdx = '<STR_LIT>'<EOL>word = unicode_normalize('<STR_LIT>', text_type(word.upper()))<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>word = '<STR_LIT>'.join(c for c in word if c in self._uc_set)<EOL>if not word:<EOL><INDENT>return sdx<EOL><DEDENT>for i in range(len(word)):<EOL><INDENT>if word[i] in self._uc_v_set:<EOL><INDENT>sdx += '<STR_LIT:0>'<EOL><DEDENT>elif word[i] == '<STR_LIT:B>':<EOL><INDENT>sdx += '<STR_LIT:1>'<EOL><DEDENT>elif word[i] == '<STR_LIT:P>':<EOL><INDENT>if _before(word, i, {'<STR_LIT:H>'}):<EOL><INDENT>sdx += '<STR_LIT:3>'<EOL><DEDENT>else:<EOL><INDENT>sdx += '<STR_LIT:1>'<EOL><DEDENT><DEDENT>elif word[i] in {'<STR_LIT:D>', '<STR_LIT:T>'}:<EOL><INDENT>if _before(word, i, {'<STR_LIT:C>', '<STR_LIT:S>', '<STR_LIT>'}):<EOL><INDENT>sdx += '<STR_LIT>'<EOL><DEDENT>else:<EOL><INDENT>sdx += '<STR_LIT:2>'<EOL><DEDENT><DEDENT>elif word[i] in {'<STR_LIT:F>', '<STR_LIT>', '<STR_LIT>'}:<EOL><INDENT>sdx += '<STR_LIT:3>'<EOL><DEDENT>elif word[i] in {'<STR_LIT>', '<STR_LIT>', '<STR_LIT>'}:<EOL><INDENT>sdx += '<STR_LIT:4>'<EOL><DEDENT>elif word[i] == '<STR_LIT:C>':<EOL><INDENT>if _after(word, i, {'<STR_LIT:S>', '<STR_LIT>'}):<EOL><INDENT>sdx += '<STR_LIT>'<EOL><DEDENT>elif i == <NUM_LIT:0>:<EOL><INDENT>if _before(<EOL>word, i, {'<STR_LIT:A>', '<STR_LIT:H>', '<STR_LIT>', '<STR_LIT:L>', '<STR_LIT:O>', '<STR_LIT>', '<STR_LIT:R>', '<STR_LIT>', '<STR_LIT:X>'}<EOL>):<EOL><INDENT>sdx += '<STR_LIT:4>'<EOL><DEDENT>else:<EOL><INDENT>sdx += '<STR_LIT>'<EOL><DEDENT><DEDENT>elif _before(word, i, {'<STR_LIT:A>', '<STR_LIT:H>', '<STR_LIT>', '<STR_LIT:O>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT:X>'}):<EOL><INDENT>sdx += '<STR_LIT:4>'<EOL><DEDENT>else:<EOL><INDENT>sdx += '<STR_LIT>'<EOL><DEDENT><DEDENT>elif word[i] == '<STR_LIT:X>':<EOL><INDENT>if _after(word, i, {'<STR_LIT:C>', '<STR_LIT>', '<STR_LIT>'}):<EOL><INDENT>sdx += '<STR_LIT>'<EOL><DEDENT>else:<EOL><INDENT>sdx += '<STR_LIT>'<EOL><DEDENT><DEDENT>elif word[i] == '<STR_LIT:L>':<EOL><INDENT>sdx += '<STR_LIT:5>'<EOL><DEDENT>elif word[i] in {'<STR_LIT:M>', '<STR_LIT:N>'}:<EOL><INDENT>sdx += '<STR_LIT>'<EOL><DEDENT>elif word[i] == '<STR_LIT:R>':<EOL><INDENT>sdx += '<STR_LIT>'<EOL><DEDENT>elif word[i] in {'<STR_LIT:S>', '<STR_LIT>'}:<EOL><INDENT>sdx += '<STR_LIT>'<EOL><DEDENT><DEDENT>sdx = self._delete_consecutive_repeats(sdx)<EOL>if sdx:<EOL><INDENT>sdx = sdx[:<NUM_LIT:1>] + sdx[<NUM_LIT:1>:].replace('<STR_LIT:0>', '<STR_LIT>')<EOL><DEDENT>return sdx<EOL>
Return the Kölner Phonetik (numeric output) code for a word.

        While the output code is numeric, it is still a str because 0s can lead
        the code.

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

        Returns
        -------
        str
            The Kölner Phonetik value as a numeric string

        Example
        -------
        >>> pe = Koelner()
        >>> pe.encode('Christopher')
        '478237'
        >>> pe.encode('Niall')
        '65'
        >>> pe.encode('Smith')
        '862'
        >>> pe.encode('Schmidt')
        '862'
        >>> pe.encode('Müller')
        '657'
        >>> pe.encode('Zimmermann')
        '86766'