Exemple #1
0
    def add_string(self, head, relation, concept):
        current_amr_in_triples = self.amr.anchored_triples()
        current_top = self.amr.top

        new_amr = current_amr_in_triples + [penman.Triple(head, relation, concept)]
        temp_amr = self.codec.triples_to_graph(new_amr, top=current_top)
        self.amr = temp_amr
        self.allvariables = [str(x.source) for x in self.amr.anchored_triples() if x.relation =='instance']
Exemple #2
0
    def add_concept(self, head, relation, concept):
        current_amr_in_triples = self.amr.anchored_triples()
        current_top = self.amr.top
        
        new_variable = self.newvariable(concept)

        new_amr = current_amr_in_triples + [penman.Triple(head, relation, new_variable), penman.Triple(new_variable, "instance", concept)]
        temp_amr = self.codec.triples_to_graph(new_amr, top=current_top)
        str(temp_amr)
        self.amr = temp_amr
        self.allvariables = [str(x.source) for x in self.amr.anchored_triples() if x.relation =='instance']
        return new_variable
Exemple #3
0
    def addsense(self, variable, senselabel):
        triplebox = self.amr.anchored_triples()
        current_top = self.amr.top
        temp_amr2 = []
        print(variable, senselabel)
        for triple in triplebox:
            if triple.source == variable and triple.relation =='instance':
                triple = penman.Triple(variable, 'instance', triple.target + "-"+senselabel)
                #triple.concept = triple.concept + "-"+senselabel
            temp_amr2.append(triple)

        temp_amr = self.codec.triples_to_graph(temp_amr2, top=current_top)
        str(temp_amr)
        self.amr = temp_amr
        self.allvariables = [str(x.source) for x in self.amr.anchored_triples() if x.relation =='instance']
Exemple #4
0
 def rename_instance(self, old_head, concept):
     current_amr_in_triples = self.amr.anchored_triples()
     current_top = self.amr.top
     new_amr = [x for x in current_amr_in_triples if not (x.relation == 'instance' and x.source== old_head)] + [penman.Triple(old_head, "instance", concept)]
     print(new_amr, current_top)
     print(current_amr_in_triples)
     input("###")
     temp_amr = self.codec.triples_to_graph(new_amr, top=current_top)
     str(temp_amr)
     self.amr = temp_amr
     self.allvariables = [str(x.source) for x in self.amr.anchored_triples() if x.relation =='instance']