コード例 #1
0
def decode_tactic_structure(stem_embedding: SimpleEmbedding,
                            struct: TacticStructure, hyps: List[str]) -> str:
    stem_idx, arg_hyp_idxs = struct
    return " ".join([stem_embedding.decode_token(stem_idx)] + [
        serapi_instance.get_first_var_in_hyp(hyps[hyp_idx - TOKEN_START])
        for hyp_idx in arg_hyp_idxs
    ])
コード例 #2
0
def decode_tactic_structure(term_tokenizer: Tokenizer,
                            stem_embedding: SimpleEmbedding,
                            struct: TacticStructure, hyps: List[str]) -> str:
    def get_var(idx: int) -> str:
        if idx == 0:
            return "UNKNOWN"
        else:
            return serapi_instance.get_first_var_in_hyp(hyps[idx - 1])

    stem_idx, arg_hyp_idxs = struct
    return " ".join([stem_embedding.decode_token(stem_idx)] + [
        get_var(hyp_idx)
        for hyp_idx in takewhile(lambda idx: idx > 0, arg_hyp_idxs)
    ])