{"id":43696607,"url":"https://github.com/semanticarts/rdfhash","last_synced_at":"2026-02-05T04:14:24.611Z","repository":{"id":37638557,"uuid":"506071899","full_name":"semanticarts/rdfhash","owner":"semanticarts","description":"RDF Graph Compression Tool. Hash RDF subjects based on a checksum of their triples, effectively consolidating together subjects that contain identical definitions. Reduce time taken to mint URIs. Use Blank Nodes to your Advantage","archived":false,"fork":false,"pushed_at":"2025-09-09T17:52:19.000Z","size":157,"stargazers_count":14,"open_issues_count":2,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2026-01-14T09:34:19.204Z","etag":null,"topics":["compression","deduplication","hashing","md5","rdf","sha256"],"latest_commit_sha":null,"homepage":"http://rdfhash.com","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/semanticarts.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2022-06-22T02:32:02.000Z","updated_at":"2025-09-09T16:30:45.000Z","dependencies_parsed_at":"2025-09-16T21:49:13.528Z","dependency_job_id":null,"html_url":"https://github.com/semanticarts/rdfhash","commit_stats":null,"previous_names":["neilgraham/rdfhash"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/semanticarts/rdfhash","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/semanticarts%2Frdfhash","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/semanticarts%2Frdfhash/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/semanticarts%2Frdfhash/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/semanticarts%2Frdfhash/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/semanticarts","download_url":"https://codeload.github.com/semanticarts/rdfhash/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/semanticarts%2Frdfhash/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29111246,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-05T03:44:17.043Z","status":"ssl_error","status_checked_at":"2026-02-05T03:44:12.077Z","response_time":65,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["compression","deduplication","hashing","md5","rdf","sha256"],"created_at":"2026-02-05T04:14:24.018Z","updated_at":"2026-02-05T04:14:24.607Z","avatar_url":"https://github.com/semanticarts.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# rdfhash: RDF Graph Hashing/Compression Tool\n\n`rdfhash` is a utility for RDF graph compression that works by hashing RDF subjects based on a checksum of their triples, effectively minimizing the size of RDF graphs by consolidating subjects that have identical definitions.\n\n## Installation\n\nYou can install `rdfhash` using `pip`, a package manager for Python. Ensure [`python`](https://www.python.org/downloads/) and [`pip`](https://pip.pypa.io/en/stable/installation/#installation) are properly installed on your system, then run the following command:\n\n```bash\npip install rdfhash\n```\n\n## Usage\n\n### Command Line Interface (CLI)\n\n#### **Basic Usage**\n\nBy default, all blank nodes in a `text/turtle` file or string are replaced by their hashed definition:\n\n```bash\nrdfhash '\n@prefix hash: \u003chttp://rdfhash.com/ontology/\u003e .\n\n[ ] a hash:Attribute ;\n    hash:unit hash:unit:Centimeters ;\n    hash:value 5.38 .'\n```\n\nOutput:\n\n```yaml\n@prefix hash: \u003chttp://rdfhash.com/ontology/\u003e .\n\n\u003csha256:960891b4b1856b4d2c24b977f75d497e4da9e6f147a292524ae51db5fd0e864e\u003e \n    a hash:Attribute ;\n    hash:unit \u003chttp://rdfhash.com/ontology/unit:Centimeters\u003e ;\n    hash:value 5.38 .\n```\n\n#### **Advanced Usage**\n\nThe `rdfhash` tool is highly customizable and can be tailored to fit the requirements of any organization:\n\n```bash\nrdfhash '\n@prefix hash: \u003chttp://rdfhash.com/ontology/\u003e .\n@prefix md5: \u003chttp://rdfhash.com/instances/md5/\u003e .\n\n[ ] a hash:Contact ;\n    hash:phone \"487-538-2824\" ;\n    hash:email \"johnsmith@example.com\" ;\n    hash:name [ \n        a hash:LegalName ;\n        hash:firstName \"John\" ;\n        hash:lastName \"Smith\" ;\n    ] ;\n    hash:address [ \n        a hash:Address ;\n        hash:street \"4567 Mountain Peak Way\" ;\n        hash:city \"Denver\" ;\n        hash:state \"CO\" ;\n        hash:zip \"80202\" ;\n        hash:country \"USA\" ;\n    ] ;\n.' \\\n--method md5 \\\n--template 'http://rdfhash.com/instances/{method}/{value}' \\\n--sparql '\nprefix hash: \u003chttp://rdfhash.com/ontology/\u003e\nselect ?s where { \n    ?s a ?type . \n    VALUES ?type {\n        hash:Contact\n        hash:LegalName\n        hash:Address\n    }\n}'\n```\n- `--method` specifies the hashing algorithm to use. The default is `sha256`.\n- `--template` specifies the URI template to use for hashed subjects. The default is `{method}:{value}`.\n- `--sparql` specifies the SPARQL query to use for selecting subjects to hash. The default is `SELECT ?s WHERE { ?s ?p ?o . FILTER(isBlank(?s))}` (Selecting all Blank Node subjects).\n- Run `rdfhash --help` for more information on available parameters.\n\nOutput:\n\n```yaml\n@prefix hash: \u003chttp://rdfhash.com/ontology/\u003e .\n@prefix md5: \u003chttp://rdfhash.com/instances/md5/\u003e .\n\nmd5:8fc18e400ff531e5cbe02fef751662ba \n    a hash:Contact ;\n    hash:phone \"487-538-2824\" ;\n    hash:email \"johnsmith@example.com\" ;\n    hash:name md5:5fd42f2c072c80e3db760c3fc69b91b8 ;\n    hash:address md5:9a3e3ce644e2c5271015d9665675a8e5 .\n\nmd5:5fd42f2c072c80e3db760c3fc69b91b8 \n    a hash:LegalName ;\n    hash:firstName \"John\" ;\n    hash:lastName \"Smith\" .\n\nmd5:9a3e3ce644e2c5271015d9665675a8e5 \n    a hash:Address ;\n    hash:street \"4567 Mountain Peak Way\" ;\n    hash:city \"Denver\" ;\n    hash:state \"CO\" ;\n    hash:zip \"80202\" ;\n    hash:country \"USA\" .\n```\n\n### Import as a Python Module\n\n```python\nfrom rdfhash import hash_subjects\n\ndata = '''\n@prefix hash: \u003chttp://rdfhash.com/ontology/\u003e .\n@prefix sha1: \u003chttp://rdfhash.com/instances/sha1/\u003e .\n\n\u003chttp://rdfhash.com/instances/Meaning-of-Life\u003e\n    a hash:Attribute ;\n    hash:value 42 .\n'''\n\ngraph, subjects_replaced = hash_subjects(\n    data,\n    method='sha1',\n    template='http://rdfhash.com/instances/{method}/{value}',\n    sparql_select_subjects='''\n    prefix hash: \u003chttp://rdfhash.com/ontology/\u003e\n    SELECT ?s WHERE { ?s a hash:Attribute. }\n    '''\n)\n\nprint(graph.serialize(format='turtle'))\n```\n\nOutput:\n\n```yaml\n@prefix hash: \u003chttp://rdfhash.com/ontology/\u003e .\n@prefix sha1: \u003chttp://rdfhash.com/instances/sha1/\u003e .\n\nsha1:4afe716d630b17d5a5d06f0901800e16f3e8c9a4\n    a hash:Attribute ;\n    hash:value 42 .\n```\n\n## Limitations\n\nIt's important to note where `rdfhash` is limited in its functionality. These limitations are expected to be addressed in future versions.\n\n- The `rdfhash` tool does not yet fully support Named Graphs (e.g. `text/trig` or `application/n-quads`)\n  - Users can still attempt to pass RDF data containing Named Graphs, although the expected output has not yet been tested.\n- Circular dependencies between selected subjects are currently not allowed. (e.g. Inverse properties). A [Directed Acyclic Graph (DAG)](https://en.wikipedia.org/wiki/Directed_acyclic_graph) is required at the moment.\n  - Best practice to follow is prioritizing broader-to-narrower relationships. (e.g. A person `Contact` points to `LegalName` and `Address` and not inversely. Multiple contacts can point to the same `LegalName` or `Address`.)\n  - Future `rdfhash` versions will support ignoring specific properties used in a subject's hash, allowing the use of inverse properties.\n- Currently, selected subjects are expected to be fully defined in the input graph.\n  - Future `rdfhash` versions will support connections to a SPARQL endpoint to fetch full context for hashing.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsemanticarts%2Frdfhash","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsemanticarts%2Frdfhash","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsemanticarts%2Frdfhash/lists"}