How to use the depccg.tools.ja.keyaki_reader.Atomic function in depccg

To help you get started, we’ve selected a few depccg examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github masashi-y / depccg / depccg / tools / ja / keyaki_reader.py View on Github external
def parse_cat(cat):
    """
    ex. PPo1\.h --> PPo1\(PPs\Sm)
    """
    rule = cat.rfind('.')
    if rule >= 0:
        cat = cat[:rule]
    cat = drop_brackets(cat)
    op_idx = find_non_nested_char(cat, '/\\')
    if op_idx == -1:
        return Atomic(FEATURE_PATTERN.sub('[\\1]', cat))
    else:
        left = parse_cat(cat[:op_idx])
        slash = cat[op_idx:op_idx + 1]
        right = parse_cat(cat[op_idx + 1:])
        return Functor(left, slash, right)
github masashi-y / depccg / depccg / tools / ja / keyaki_reader.py View on Github external
def rec(cat):
            if isinstance(cat, Atomic):
                return str(cat)
            right = rec(cat.right if cat.slash == '\\' else cat.left)
            left = rec(cat.left if cat.slash == '\\' else cat.right)
            return f'({right}{cat.slash}{left})'
        return rec(self)[1:-1]