def _universal_abbrev(iri): global _next_abb abb = _int_base_62(_next_abb) _next_abb += 1 _universal_abbrev_2_iri[abb] = iri _universal_iri_2_abbrev[iri] = abb return abb
def abbreviate(self, iri): r = self.execute("SELECT storid FROM resources WHERE iri=? LIMIT 1", (iri,)).fetchone() if r: return r[0] self.current_resource += 1 storid = _int_base_62(self.current_resource) self.execute("INSERT INTO resources VALUES (?,?)", (storid, iri)) return storid
def abbreviate(iri): storid = abbrevs.get(iri) if not storid is None: return storid self.parent.current_resource += 1 storid = _int_base_62(self.parent.current_resource) new_abbrevs.append((storid, iri)) abbrevs[iri] = storid return storid
def abbreviate_dict(self, iri): storid = self.abbreviate_d.get(iri) if storid is None: self.current_resource += 1 storid = self.abbreviate_d[iri] = _int_base_62( self.current_resource) self.unabbreviate_d[storid] = iri self.execute("INSERT INTO resources VALUES (?,?)", (storid, iri)) return storid
def abbreviate(iri): # Re-implement for speed storid = abbrevs.get(iri) if not storid is None: return storid r = self.execute("SELECT storid FROM resources WHERE iri=? LIMIT 1", (iri,)).fetchone() if r: abbrevs[iri] = r[0] return r[0] self.parent.current_resource += 1 storid = _int_base_62(self.parent.current_resource) new_abbrevs.append((storid, iri)) abbrevs[iri] = storid return storid
def new_blank_node(self): self.current_blank += 1 return "_%s" % _int_base_62(self.current_blank)