示例#1
0
    def add_input(self, subj, pred, objc, prev=None, author=None):
        self.normalize_input(subj, pred, objc)
        self.inverse_normalize_input(objc, pred, subj)
        if not dbutils.exists_in_ontology(subj, pred, objc):
            if self._validation:
                self.validate(subj, pred, objc)

            self._input_list.append({
                'subject': subj,
                'predicate': pred,
                'object': objc,
                'fact_id': Common.generate_id(None)
            })
        return self
示例#2
0
 def add_templatized_id_map(self, temp_id):
     '''
     create the templatized_id to tofler_id map, if not exists
     returns the tofler_id
     if the temp_id is not a throw away id, look for it in eternity
     if found, cache the mapping, else create a new id
     '''
     if temp_id not in self._templatized_id_map:
         stored_id = []
         if templatizedid.is_keep_id(temp_id):
             stored_id = dbutils.get_inverse_predicate_value(
                 temp_id, 'to:templatizedId', level=1)
         if len(stored_id):
             tofler_id = stored_id[0]
             self._templatized_id_map[temp_id] = tofler_id
         else:
             tofler_id = Common.generate_id(None)
             self._templatized_id_map[temp_id] = tofler_id
             self._new_templatized_id.append(temp_id)
     return self._templatized_id_map[temp_id]
示例#3
0
    def add_input(self, subj, pred, objc, prev=None):
        self._fact_tuple = (subj, pred, objc)
        subj = self.handle_templatized_id(subj)
        pred = self.handle_templatized_id(pred)
        objc = self.handle_templatized_id(
            objc,
            additional_check=self.is_templatized_object,
            additional_check_args=(subj, pred, objc))
        if self._ignore_duplicate and \
                eternity_dbutils.tuple_exists_in_eternity(subj, pred, objc):
            return self

        self.normalize_input(subj, pred, objc)
        if self._validation and not self.is_valid(subj, pred, objc):
            self.delete_normalize_input(subj, pred, objc)
            return self
        self._fact_id = Common.generate_id(None)

        self.create_eternity_input(subj, pred, objc, prev)
        self.create_snapshot_input(subj, pred, objc)
        return self