Ejemplo n.º 1
0
    def extract_dependency_rules(self, relation):
        """
        extract dependency rules
        :param relation:
        :return:
        """
        res1 = defaultdict(int)
        res2 = defaultdict(int)
        DepTree.get_dependency_rules(res1, relation.arg1_leaves, False, True)
        DepTree.get_dependency_rules(res2, relation.arg2_leaves, False, True)

        feat_vec = []
        for k in self.dep_dict:
            a1 = k in res1
            a2 = k in res2
            if a1: feat_vec.append(k + ":1")
            if a2: feat_vec.append(k + ":2")
            if a1 and a2: feat_vec.append(k + ":12")

        return feat_vec
Ejemplo n.º 2
0
    def extract_dependency_rules(self, relation):
        """
        extract dependency rules
        :param relation:
        :return:
        """
        res1 = defaultdict(int)
        res2 = defaultdict(int)
        DepTree.get_dependency_rules(res1, relation.arg1_leaves, False, True)
        DepTree.get_dependency_rules(res2, relation.arg2_leaves, False, True)

        feat_vec = []
        for k in self.dep_dict:
            a1 = k in res1
            a2 = k in res2
            if a1: feat_vec.append(k + ":1")
            if a2: feat_vec.append(k + ":2")
            if a1 and a2: feat_vec.append(k + ":12")

        return feat_vec
Ejemplo n.º 3
0
 def get_dependency_rule(self, rule_dict, with_leaf=False, with_label=True):
     DepTree.get_dependency_rules(rule_dict, self.arg1_leaves, with_leaf,
                                  with_label)
     DepTree.get_dependency_rules(rule_dict, self.arg2_leaves, with_leaf,
                                  with_label)
Ejemplo n.º 4
0
 def get_dependency_rule(self, rule_dict, with_leaf=False, with_label=True):
     DepTree.get_dependency_rules(rule_dict, self.arg1_leaves, with_leaf, with_label)
     DepTree.get_dependency_rules(rule_dict, self.arg2_leaves, with_leaf, with_label)