tossi/coda.py
def filter_only_significant(word):
    """Gets a word which removes insignificant letters at the end of the given
    word::

    >>> pick_significant(u'넥슨(코리아)')
    넥슨
    >>> pick_significant(u'메이플스토리...')
    메이플스토리

    """
    if not word:
        return word
    # Unwrap a complete parenthesis.
    if word.startswith(u'(') and word.endswith(u')'):
        return filter_only_significant(word[1:-1])
    x = len(word)
    while x > 0:
        x -= 1
        c = word[x]
        # Skip a complete parenthesis.
        if c == u')':
            m = INSIGNIFICANT_PARENTHESIS_PATTERN.search(word[:x + 1])
            if m is not None:
                x = m.start()
            continue
        # Skip unreadable characters such as punctuations.
        unicode_category = unicodedata.category(c)
        if not SIGNIFICANT_UNICODE_CATEGORY_PATTERN.match(unicode_category):
            continue
        break
    return word[:x + 1]
def filter_only_significant(word):
    """Gets a word which removes insignificant letters at the end of the given
    word::

    >>> pick_significant(u'넥슨(코리아)')
    넥슨
    >>> pick_significant(u'메이플스토리...')
    메이플스토리

    """
    if not word:
        return word
    # Unwrap a complete parenthesis.
    if word.startswith(u'(') and word.endswith(u')'):
        return filter_only_significant(word[1:-1])
    x = len(word)
    while x > 0:
        x -= 1
        c = word[x]
        # Skip a complete parenthesis.
        if c == u')':
            m = INSIGNIFICANT_PARENTHESIS_PATTERN.search(word[:x + 1])
            if m is not None:
                x = m.start()
            continue
        # Skip unreadable characters such as punctuations.
        unicode_category = unicodedata.category(c)
        if not SIGNIFICANT_UNICODE_CATEGORY_PATTERN.match(unicode_category):
            continue
        break
    return word[:x + 1]
Gets a word which removes insignificant letters at the end of the given
    word::

    >>> pick_significant(u'넥슨(코리아)')
    넥슨
    >>> pick_significant(u'메이플스토리...')
    메이플스토리