hash_triple

hash_triple(converter: Converter, triple: Triple, *, negate: bool = False) str[source]

Encode a triple with URL-safe base64 encoding.

Parameters:
  • converter – A converter

  • triple – A triple of CURIE objects

  • negate – If true, considers the triple as “negative” and postpends a ~ to the hash

Returns:

An encoded triple of URIs

>>> import curies
>>> from curies.triples import Triple
>>> converter = curies.load_prefix_map(
...     {
...         "mesh": "http://id.nlm.nih.gov/mesh/",
...         "skos": "http://www.w3.org/2004/02/skos/core#",
...         "CHEBI": "http://purl.obolibrary.org/obo/CHEBI_",
...     }
... )
>>> triple = Triple(subject="mesh:C000089", predicate="skos:exactMatch", object="CHEBI:28646")
>>> hash_triple(converter, triple)
'36a1f9244ea7641a90987c82f33c25c0c13712ee8f48207b2a0825f8a4e4e26a'
>>> hash_triple(converter, triple, negate=True)
'36a1f9244ea7641a90987c82f33c25c0c13712ee8f48207b2a0825f8a4e4e26a~'