コード例 #1
0
def curr_last(arg_clauses, clause_index, parse_dict):
    # load dict
    dict_curr_last = Implicit_arg2_dict().dict_curr_last
    # feature
    curr_last = dict_util.get_curr_last(arg_clauses, clause_index, parse_dict)

    return get_feature_by_feat(dict_curr_last, curr_last)
コード例 #2
0
def curr_last(arg_clauses, clause_index, parse_dict):
    # load dict
    dict_curr_last = Implicit_arg2_dict().dict_curr_last
    # feature
    curr_last = dict_util.get_curr_last(arg_clauses, clause_index, parse_dict)

    return get_feature_by_feat(dict_curr_last, curr_last)
コード例 #3
0
def _all_features(arg_clauses, clause_index, parse_dict):
    # load dict
    dict_lowercase_verbs = Implicit_arg2_dict().dict_lowercase_verbs
    dict_lemma_verbs = Implicit_arg2_dict().dict_lemma_verbs
    dict_curr_first = Implicit_arg2_dict().dict_curr_first
    dict_curr_last = Implicit_arg2_dict().dict_curr_last
    dict_prev_last = Implicit_arg2_dict().dict_prev_last
    dict_next_first = Implicit_arg2_dict().dict_next_first
    dict_prev_last_curr_first = Implicit_arg2_dict().dict_prev_last_curr_first
    dict_curr_last_next_first = Implicit_arg2_dict().dict_curr_last_next_first
    dict_position = {"left": 1, "middle": 2, "right": 3}
    dict_prev_curr_CP_production_rule = Implicit_arg2_dict().dict_prev_curr_CP_production_rule
    dict_prev2_pos_lemma_verb = Implicit_arg2_dict().dict_prev2_pos_lemma_verb


    # feature
    lowercase_verbs_list = dict_util.get_curr_lowercased_verbs(arg_clauses, clause_index, parse_dict)
    lemma_verbs_list = dict_util.get_curr_lemma_verbs(arg_clauses, clause_index, parse_dict)

    curr_first = dict_util.get_curr_first(arg_clauses, clause_index, parse_dict)
    curr_last = dict_util.get_curr_last(arg_clauses, clause_index, parse_dict)
    prev_last = dict_util.get_prev_last(arg_clauses, clause_index, parse_dict)
    next_first = dict_util.get_next_first(arg_clauses, clause_index, parse_dict)
    prev_last_curr_first = "%s_%s" % (prev_last, curr_first)
    curr_last_next_first = "%s_%s" % (curr_last, next_first)

    # the number of words in current clause
    clause_word_num = len(arg_clauses.clauses[clause_index][0])
    # the position of current clause
    position = dict_util.get_curr_position(arg_clauses, clause_index, parse_dict)
    prev_curr_CP_production_rule = dict_util.get_prev_curr_CP_production_rule(arg_clauses, clause_index, parse_dict)

    prev2_pos_lemma_verb = dict_util.get_2prev_pos_lemma_verb(arg_clauses, clause_index, parse_dict)



    features = []
    features.append(get_feature_by_feat_list(dict_lowercase_verbs, lowercase_verbs_list))
    features.append(get_feature_by_feat_list(dict_lemma_verbs, lemma_verbs_list))

    features.append(get_feature_by_feat(dict_curr_first, curr_first))
    features.append(get_feature_by_feat(dict_curr_last, curr_last))
    features.append(get_feature_by_feat(dict_prev_last, prev_last))
    features.append(get_feature_by_feat(dict_next_first, next_first))
    features.append(get_feature_by_feat(dict_prev_last_curr_first, prev_last_curr_first))
    features.append(get_feature_by_feat(dict_curr_last_next_first, curr_last_next_first))
    features.append(get_feature_by_feat(dict_position, position))
    features.append(Feature("", 1, {"1": clause_word_num}))


    features.append(get_feature_by_feat(dict_prev2_pos_lemma_verb, prev2_pos_lemma_verb))


    ''' production rules '''
    features.append(get_feature_by_feat_list(dict_prev_curr_CP_production_rule, prev_curr_CP_production_rule))


    return util.mergeFeatures(features)
コード例 #4
0
def _all_features(arg_clauses, clause_index, parse_dict):
    # load dict
    dict_lowercase_verbs = Implicit_arg2_dict().dict_lowercase_verbs
    dict_lemma_verbs = Implicit_arg2_dict().dict_lemma_verbs
    dict_curr_first = Implicit_arg2_dict().dict_curr_first
    dict_curr_last = Implicit_arg2_dict().dict_curr_last
    dict_prev_last = Implicit_arg2_dict().dict_prev_last
    dict_next_first = Implicit_arg2_dict().dict_next_first
    dict_prev_last_curr_first = Implicit_arg2_dict().dict_prev_last_curr_first
    dict_curr_last_next_first = Implicit_arg2_dict().dict_curr_last_next_first
    dict_position = {"left": 1, "middle": 2, "right": 3}
    dict_prev_curr_CP_production_rule = Implicit_arg2_dict(
    ).dict_prev_curr_CP_production_rule
    dict_prev2_pos_lemma_verb = Implicit_arg2_dict().dict_prev2_pos_lemma_verb

    # feature
    lowercase_verbs_list = dict_util.get_curr_lowercased_verbs(
        arg_clauses, clause_index, parse_dict)
    lemma_verbs_list = dict_util.get_curr_lemma_verbs(arg_clauses,
                                                      clause_index, parse_dict)

    curr_first = dict_util.get_curr_first(arg_clauses, clause_index,
                                          parse_dict)
    curr_last = dict_util.get_curr_last(arg_clauses, clause_index, parse_dict)
    prev_last = dict_util.get_prev_last(arg_clauses, clause_index, parse_dict)
    next_first = dict_util.get_next_first(arg_clauses, clause_index,
                                          parse_dict)
    prev_last_curr_first = "%s_%s" % (prev_last, curr_first)
    curr_last_next_first = "%s_%s" % (curr_last, next_first)

    # the number of words in current clause
    clause_word_num = len(arg_clauses.clauses[clause_index][0])
    # the position of current clause
    position = dict_util.get_curr_position(arg_clauses, clause_index,
                                           parse_dict)
    prev_curr_CP_production_rule = dict_util.get_prev_curr_CP_production_rule(
        arg_clauses, clause_index, parse_dict)

    prev2_pos_lemma_verb = dict_util.get_2prev_pos_lemma_verb(
        arg_clauses, clause_index, parse_dict)

    features = []
    features.append(
        get_feature_by_feat_list(dict_lowercase_verbs, lowercase_verbs_list))
    features.append(
        get_feature_by_feat_list(dict_lemma_verbs, lemma_verbs_list))

    features.append(get_feature_by_feat(dict_curr_first, curr_first))
    features.append(get_feature_by_feat(dict_curr_last, curr_last))
    features.append(get_feature_by_feat(dict_prev_last, prev_last))
    features.append(get_feature_by_feat(dict_next_first, next_first))
    features.append(
        get_feature_by_feat(dict_prev_last_curr_first, prev_last_curr_first))
    features.append(
        get_feature_by_feat(dict_curr_last_next_first, curr_last_next_first))
    features.append(get_feature_by_feat(dict_position, position))
    features.append(Feature("", 1, {"1": clause_word_num}))

    features.append(
        get_feature_by_feat(dict_prev2_pos_lemma_verb, prev2_pos_lemma_verb))
    ''' production rules '''
    features.append(
        get_feature_by_feat_list(dict_prev_curr_CP_production_rule,
                                 prev_curr_CP_production_rule))

    return util.mergeFeatures(features)