Beispiel #1
0
 def add_coref(self, coref_id, match_np, np, np_set):
     coref_id_list = self.inverse_coref_dict.setdefault(match_np, [])
     if np != match_np: 
         alter_coref_id_list = self.inverse_coref_dict.setdefault(np, [])
         if alter_coref_id_list and coref_id_list:
             competing_coref = alter_coref_id_list[0]
             if int(competing_coref) < int(coref_id_list[0]):
                 coref_id_list.append(competing_coref)
                 coref_id_list.sort(key = lambda x: sort_function(x))
             for each_coref_id in coref_id_list[1:]:
                 self.ref_dict[each_coref_id] = coref_id_list[0]
     if coref_id_list:
         if coref_id != coref_id_list[0]:
             self.ref_dict[coref_id] = coref_id_list[0]
     else:
         new_id = self.gen_new_id()
         coref_id_list.append(new_id)
         self.ref_dict[coref_id] = new_id
         coref_id_list.sort(key = lambda x : sort_function(x))
         for each_coref_id in coref_id_list[1:]:
             self.ref_dict[each_coref_id] = coref_id_list[0]
     np_set.add(np)
Beispiel #2
0
 def add_coref(self, coref_id, match_np, np, np_set):
     coref_id_list = self.inverse_coref_dict.setdefault(match_np, [])
     if np != match_np:
         alter_coref_id_list = self.inverse_coref_dict.setdefault(np, [])
         if alter_coref_id_list and coref_id_list:
             competing_coref = alter_coref_id_list[0]
             if int(competing_coref) < int(coref_id_list[0]):
                 coref_id_list.append(competing_coref)
                 coref_id_list.sort(key=lambda x: sort_function(x))
             for each_coref_id in coref_id_list[1:]:
                 self.ref_dict[each_coref_id] = coref_id_list[0]
     if coref_id_list:
         if coref_id != coref_id_list[0]:
             self.ref_dict[coref_id] = coref_id_list[0]
     else:
         new_id = self.gen_new_id()
         coref_id_list.append(new_id)
         self.ref_dict[coref_id] = new_id
         coref_id_list.sort(key=lambda x: sort_function(x))
         for each_coref_id in coref_id_list[1:]:
             self.ref_dict[each_coref_id] = coref_id_list[0]
     np_set.add(np)
Beispiel #3
0
 def final_ref_dict(self):
     for np, coref_id_list in self.inverse_coref_dict.iteritems():
         coref_id_list.sort(key = lambda x: sort_function(x))
         for each_coref_id in coref_id_list[1:]:
             self.ref_dict[each_coref_id] = coref_id_list[0]
Beispiel #4
0
 def final_ref_dict(self):
     for np, coref_id_list in self.inverse_coref_dict.iteritems():
         coref_id_list.sort(key=lambda x: sort_function(x))
         for each_coref_id in coref_id_list[1:]:
             self.ref_dict[each_coref_id] = coref_id_list[0]