def sim(self, src, tar, min_ss_len=None, left_ext=None, right_ext=None):
if src == tar:<EOL><INDENT>return <NUM_LIT:1.0><EOL><DEDENT>if not src or not tar:<EOL><INDENT>return <NUM_LIT:0.0><EOL><DEDENT>max_len = max(len(src), len(tar))<EOL>if not (min_ss_len and left_ext and right_ext):<EOL><INDENT>if max_len >= <NUM_LIT:7>:<EOL><INDENT>min_ss_len = <NUM_LIT:2><EOL>left_ext = <NUM_LIT:2><EOL>right_ext = <NUM_LIT:2><EOL><DEDENT>else:<EOL><INDENT>min_ss_len = <NUM_LIT:1><EOL>left_ext = <NUM_LIT:0><EOL>right_ext = <NUM_LIT:0><EOL><DEDENT><DEDENT>pos = <NUM_LIT:0><EOL>match_len = <NUM_LIT:0><EOL>while True:<EOL><INDENT>if pos + min_ss_len > len(src):<EOL><INDENT>return match_len / max_len<EOL><DEDENT>hit_len = <NUM_LIT:0><EOL>ix = <NUM_LIT:1><EOL>substring = src[pos : pos + min_ss_len]<EOL>search_begin = pos - left_ext<EOL>if search_begin < <NUM_LIT:0>:<EOL><INDENT>search_begin = <NUM_LIT:0><EOL>left_ext_len = pos<EOL><DEDENT>else:<EOL><INDENT>left_ext_len = left_ext<EOL><DEDENT>if pos + min_ss_len + right_ext >= len(tar):<EOL><INDENT>right_ext_len = len(tar) - pos - min_ss_len<EOL><DEDENT>else:<EOL><INDENT>right_ext_len = right_ext<EOL><DEDENT>if (<EOL>search_begin + left_ext_len + min_ss_len + right_ext_len<EOL>> search_begin<EOL>):<EOL><INDENT>search_val = tar[<EOL>search_begin : (<EOL>search_begin<EOL>+ left_ext_len<EOL>+ min_ss_len<EOL>+ right_ext_len<EOL>)<EOL>]<EOL><DEDENT>else:<EOL><INDENT>search_val = '<STR_LIT>'<EOL><DEDENT>flagged_tar = '<STR_LIT>'<EOL>while substring in search_val and pos + ix <= len(src):<EOL><INDENT>hit_len = len(substring)<EOL>flagged_tar = tar.replace(substring, '<STR_LIT:#>' * hit_len)<EOL>if pos + min_ss_len + ix <= len(src):<EOL><INDENT>substring = src[pos : pos + min_ss_len + ix]<EOL><DEDENT>if pos + min_ss_len + right_ext_len + <NUM_LIT:1> <= len(tar):<EOL><INDENT>right_ext_len += <NUM_LIT:1><EOL><DEDENT>search_val = tar[<EOL>search_begin : (<EOL>search_begin<EOL>+ left_ext_len<EOL>+ min_ss_len<EOL>+ right_ext_len<EOL>)<EOL>]<EOL>ix += <NUM_LIT:1><EOL><DEDENT>if hit_len > <NUM_LIT:0>:<EOL><INDENT>tar = flagged_tar<EOL><DEDENT>match_len += hit_len<EOL>pos += ix<EOL><DEDENT>
Return the Baystat similarity.

        Parameters
        ----------
        src : str
            Source string for comparison
        tar : str
            Target string for comparison
        min_ss_len : int
            Minimum substring length to be considered
        left_ext :int
            Left-side extension length
        right_ext :int
            Right-side extension length

        Returns
        -------
        float
            The Baystat similarity

        Examples
        --------
        >>> cmp = Baystat()
        >>> round(cmp.sim('cat', 'hat'), 12)
        0.666666666667
        >>> cmp.sim('Niall', 'Neil')
        0.4
        >>> round(cmp.sim('Colin', 'Cuilen'), 12)
        0.166666666667
        >>> cmp.sim('ATCG', 'TAGC')
        0.0