At least with the version of librdf I was using the context
graph really slowed adding tripes down.
return term_s.replace(namespace._prefix, "")
return term_s.replace(namespace._prefix, "")
-def get_model(model_name=None, directory=None):
+def get_model(model_name=None, directory=None, use_contexts=True):
if directory is None:
directory = os.getcwd()
if directory is None:
directory = os.getcwd()
+ contexts = 'yes' if use_contexts else 'no'
+
- storage = RDF.MemoryStorage(options_string="contexts='yes'")
+ storage = RDF.MemoryStorage(options_string="contexts='{}'".format(contexts))
logger.info("Using RDF Memory model")
else:
logger.info("Using RDF Memory model")
else:
- options = "contexts='yes',hash-type='bdb',dir='{0}'".format(directory)
+ options = "contexts='{0}',hash-type='bdb',dir='{1}'".format(contexts, directory)
storage = RDF.HashStorage(model_name,
options=options)
logger.info("Using {0} with options {1}".format(model_name, options))
storage = RDF.HashStorage(model_name,
options=options)
logger.info("Using {0} with options {1}".format(model_name, options))
except RDF.RedlandError, e:
errmsg = "RDF.RedlandError: {0} {1} tries remaining"
logger.error(errmsg.format(str(e), retries))
except RDF.RedlandError, e:
errmsg = "RDF.RedlandError: {0} {1} tries remaining"
logger.error(errmsg.format(str(e), retries))
if not succeeded:
logger.warn("Unable to download %s", url)
if not succeeded:
logger.warn("Unable to download %s", url)
for s in statements:
conditionally_add_statement(model, s, ns)
for s in statements:
conditionally_add_statement(model, s, ns)