Example #1
0
def _get_dep_noun(tag: Token) -> str:
    f: Dict[str, Any] = tag._.knp_morph_tag._.knp_tag_element.features
    if "係" not in f:
        return "dep"
    k = f["係"] if f["係"] != "未格" or "解析格" not in f else f["解析格"] + "格"
    x = {
        "隣": "nmod",
        "文節内": "compound",
        "ガ格": "nsubj",
        "ヲ格": "obj",
        "ガ2格": "dislocated",
    }
    if k in x:
        return x[k]
    elif k == "ノ格":
        if tag.head.pos in {VERB, ADJ}:
            return "nsubj"
        elif tag.pos in {DET, PRON}:
            tag.pos = DET
            return "det"
        else:
            return "nummod" if tag.pos == NUM else "nmod"
    elif "並列タイプ" in f:
        if tag.head.pos in {VERB, ADJ}:
            return "obl"
        else:
            return "conj"
    return "obl"
Example #2
0
def _get_child_dep(tag: Token) -> str:
    p, pp = tag.pos, tag.head.pos
    if p == AUX:
        return "aux" if pp in {VERB, ADJ} else "cop"
    elif p == ADP:
        return "mark" if pp in {VERB, ADJ} else "case"
    elif p in {VERB, ADJ}:
        if pp == NOUN:
            tag.head.pos = VERB
        tag.pos = AUX
        return "aux"
    elif p == PART:
        return "mark"
    elif p == PUNCT:
        return "punct"
    else:
        return "clf" if pp == NUM else "flat"