{"id":26013714,"url":"https://github.com/wouterbeek/prolog_rdf","last_synced_at":"2026-04-02T02:07:47.181Z","repository":{"id":17151747,"uuid":"19918526","full_name":"wouterbeek/prolog_rdf","owner":"wouterbeek","description":"Advanced support for working with RDF in Prolog.","archived":false,"fork":false,"pushed_at":"2024-08-31T21:08:37.000Z","size":4655,"stargazers_count":19,"open_issues_count":0,"forks_count":3,"subscribers_count":8,"default_branch":"master","last_synced_at":"2026-03-08T19:42:43.489Z","etag":null,"topics":["linked-data","prolog","rdf","semantic-web","swi-prolog"],"latest_commit_sha":null,"homepage":"","language":"Prolog","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/wouterbeek.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","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":"2014-05-18T19:06:47.000Z","updated_at":"2026-02-20T22:05:39.000Z","dependencies_parsed_at":"2022-09-24T13:44:36.067Z","dependency_job_id":null,"html_url":"https://github.com/wouterbeek/prolog_rdf","commit_stats":null,"previous_names":[],"tags_count":17,"template":false,"template_full_name":null,"purl":"pkg:github/wouterbeek/prolog_rdf","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wouterbeek%2Fprolog_rdf","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wouterbeek%2Fprolog_rdf/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wouterbeek%2Fprolog_rdf/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wouterbeek%2Fprolog_rdf/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wouterbeek","download_url":"https://codeload.github.com/wouterbeek/prolog_rdf/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wouterbeek%2Fprolog_rdf/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31294398,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-02T01:43:37.129Z","status":"online","status_checked_at":"2026-04-02T02:00:08.535Z","response_time":89,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["linked-data","prolog","rdf","semantic-web","swi-prolog"],"created_at":"2025-03-06T01:54:34.148Z","updated_at":"2026-04-02T02:07:47.154Z","avatar_url":"https://github.com/wouterbeek.png","language":"Prolog","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Prolog-based RDF library\n\nThis library provides advanced support for working with RDF in Prolog.\n\n## Installation\n\n1. Install [SWI-Prolog](https://www.swi-prolog.org).\n\n2. Install the [Prolog Library\nCollection](https://github.com/wouterbeek/prolog_library_collection).\n\n3. Clone this repo, and add the following line to your\n`$HOME/.config/swi-prolog/init.pl` file:\n\n   ```prolog\n   user:file_search_path(library, '/your/path/to/prolog_rdf/prolog').\n   ```\n\n## Use\n\nYou can now load the libraries from this repo in the following way:\n\n```prolog\n:- [library(semweb/rdf_term)].\n```\n\n## RDF-specific Prolog types\n\nThis library uses the following extended Prolog types in the\ndocumentation headers of predicates:\n\n| **Type**      | **Definition**                                                                       |\n| ------------- | ------------------------------------------------------------------------------------ |\n| `rdf_bnode`   | An atom that starts with `_:`.                                                       |\n| `rdf_graph`   | Either a term of type `iri` or the atom `default`.                                   |\n| `rdf_iri`     | An atom that can be decomposed with `uri_components/2` from `library(uri)`.          |\n| `rdf_literal` | A compound term of the form `literal(type(iri,atom))` or `literal(lang(atom,atom))`. |\n| `rdf_name`    | An RDF name (IRI or literal).                                                        |\n| `rdf_quad`    | A compound term of the form `rdf(rdf_nonliteral,iri,rdf_term,rdf_graph)`.            |\n| `rdf_term`    | An RDF term (blank node, IRI, or literal).                                           |\n| `rdf_triple`  | A compound term of the form `rdf(rdf_nonliteral,iri,rdf_term)`.                      |\n| `rdf_tuple`   | A term of type `rdf_quad` or `rdf_triple`.                                           |\n\n## Modules\n\nThis section enumerates the various modules that are included in this\nlibrary.\n\n### `library(rdf_clean)`\n\nThis module contains data cleaning predicates that were previously\npart of [LOD Laundromat](http://lodlaundromat.org).  They can be used\nto clean RDF tuples that are streamed from an RDF source.  See module\n[[semweb/rdf_deref]] for creating streams over RDF sources.\n\nIn order to use this module, library\n[`prolog_uriparser`](https://github.com/wouterbeek/prolog_uriparser)\nmust be installed.\n\n#### Blank node cleaning\n\nThe parsers in the Semantic Web standard library emit blank node\nlabels that contain characters that are not allowed in\nstandards-compliant output formats (e.g., forward slashes).  This is\nunfortunate, since writing the data into standard-compliant formats\nrequires maintaining a state that ensures that Prolog internal blank\nnode labels are consistently emitted by the same standard-compliant\nexternal blank node label.  See [this Github\nissue](https://github.com/SWI-Prolog/packages-semweb/issues/68) for\ncontext.\n\nBesides the above considerations, blank nodes form a scalability issue\nin general.  Since blank node labels are only guaranteed to be unique\nwithin the context of an RDF document, combining data from multiple\ndocuments requires a check of all blank node labels in the to be\ncombined documents.  Furthermore, all blank node labels that appear in\nmore than one RDF document must be consistently renamed prior to\ncombining the data.\n\nSince Pro-RDF focusses on scalability, it cannot rely on maintaining\nan internal state that consistently maps internal Prolog blank node\nlabels to external standards-compliant blank node labels.  For the\nsame reasons, it also cannot rely on full document inspection and\nblank node relabeling approaches.  For these reasons, the data\ncleaning prediates in `library(rdf_clean)` replace blank nodes with\nwell-known IRIs, in line with the RDF 1.1 standard.  This means that\nevery data cleaning predicate must bind a valid well-known IRI to the\n`BNodePrefix` argument.  It also means that Prolog internal blank node\nlabels are hashed using the MD5 algorithm to provide the local names\nfor the generated well-known IRIs.  The latter ensures consistent\nrelabeling without maintaining an internal state.\n\n#### Graph cleaning\n\nThe parsers from the Semantic Web standard library denote the default\ngraph with atom `user`.  This is translated to atom `default`.  For\nnamed graphs, this library checks whether they are well-formed IRIs.\n\n#### IRI cleaning\n\nIRI cleaning is the most difficult part of syntactic RDF data\ncleaning.  To date, the IRI grammar ([RFC\n3987](https://tools.ietf.org/html/rfc3987)) has not yet been\nimplemented.  Since this grammar was published over a decade ago, we\nmust anticipate a future in which the main syntactic component of the\nSemantic Web cannot be validated.\n\nWhile there are implementations of the URI grammar ([RFC\n3986](https://tools.ietf.org/html/rfc3986)), the one provided by the\nSWI-Prolog standard library (`library(uri)`) is incorrect.\n\nBecause of the above two reasons we currently only check the following:\n\n  - Whether an IRI can be decomposed into scheme, authority, path,\n    query, and fragment components using the Prolog standard library\n    grammar (`uri_components/2`).\n\n  - Whether the scheme, authority, and path components are non-empty.\n\n  - Whether the scheme components conforms to the IRI grammar.\n\n#### Literal cleaning\n\nFor language-tagged strings, cleaning involves downcasing the language\ntag.  While there are implementations of the language tag grammar\n([RFC 5646](https://tools.ietf.org/html/rfc5646)), we are not yet\nusing these.\n\nSimple literals, i.e., literals with neither language tag not datatype\nIRI, are translated to typed literals with datatype IRI `xsd:string`.\n\nFor typed literals, cleaning involves:\n\n  - Cleaning the datatype IRI (see [[IRI cleaning]]).\n\n  - Making sure the datatype IRI is not `rdf:langString`.\n\n  - Cleaning the lexical form according to the datatype IRI.  Lexical\n    form cleaning is the most involved step, since there are many\n    different datatype IRIs.  Since it is impractical to implement\n    lexical form cleaning for all datatype IRIs, we focus on those\n    that are most widely used.  For this we use `rdf_literal_value/3`,\n    which is part of library `library(semweb/rdf_term)`.\n\n#### Predicates\n\nThis module provides the following predicates.\n\n##### `rdf_clean_quad(+Site:uri, +Dirty:rdf_quad, -Clean:rdf_quad)`\n\nCleans quadruple compound terms.\n\n##### `rdf_clean_triple(+Site:uri, +Dirty:rdf_triple, -Clean:rdf_triple)`\n\nCleans triple compound terms.\n\n##### `rdf_clean_tuple(+Site:uri, +Dirty:rdf_tuple, -Clean:rdf_tuple)`\n\nCleans quadruple and/or triple compound terms.\n\n### `library(rdf_deref)`\n\nThis module implements RDF dereferencing, i.e., the act of obtaining\ninterpreted RDF statements based on a given RDF document, stream, or\nHTTP(S) URI.\n\n#### Predicates\n\nThis library provides the following predicates.\n\n##### `rdf_deref_file/[2,3]`\n\nCalls RDF dereferencing on local RDF documents.  Uses heuristics in\norder to determine the RDF serialization of the file.\n\n##### `rdf_deref_stream/[3,4]`\n\nPerforms RDF dereferencing on an input stream containing one of the\nstandardized RDF serialization formats.\n\n##### `rdf_dered_uri/[2,3]`\n\nPerforms RDF dereferencing on a URI, typically an HTTP(S) URI.  Uses\nheuristics in order to determine the RDF serialization of the reply\nbody.\n\n### `library(rdf_dot)`\n\nThis library provides primitives for generating GraphViz DOT exports\nof RDF terms and tuples.\n\nThis module requires library\n[`prolog_graphviz`](https://github.com/wouterbeek/prolog_graphviz) to\nbe installed.\n\n### `library(rdf_export)`\n\nThis module writes RDF data in a simple and standards-compliant\nserialization format.  It contains the following predicates:\n\n  - `rdf_write_iri/2`\n  - `rdf_write_literal/2`\n  - `rdf_write_name/2`\n  - `rdf_write_quad/[2,3,5]`\n  - `rdf_write_triple/[2,4]`\n  - `rdf_write_tuple/2`\n\n### `library(rdf_guess)`\n\nThis module peeks at the beginning of a file, stream, or string in\norder to heuristically guesstimate the RDF serialization formats (if\nany) containing in that input:\n\n  - `rdf_guess_file/3`\n  - `rdf_guess_stream/3`\n  - `rdf_guess_string/2`\n\n### `library(rdf_media_type)`\n\nThis module provides support for the standardized RDF serialization\nformat Media Types:\n\n#### `rdf_file_name_media_type/2`\n\nGuesses the RDF serialization format based on the file name extension\nalone.\n\n#### `rdf_media_type/1`\n\nEnumerates all standardized RDF Media Types.\n\n#### `'rdf_media_type_\u003e'/2`\n\nSucceeds if the former argument is an RDF Media Type that\nsyntactically encompasses the latter argument (e.g., TriG \u003e Turtle \u003e\nN-Triples, N-Quads \u003e N-Triples).\n\n#### `rdf_media_type_extension`\n\nGives a standard file name extension for RDF serializations that are\nnot RDFa (which is part of HTML or XHTML content).\n\n#### `rdfa_media_type/1`\n\nSucceeds for RDFa Media Types.\n\n### `library(rdf_prefix)`\n\nThis module provides extended support for working with RDF prefix\ndeclarations:\n\n##### `rdf_prefix/[1,2]`\n\nEnumerates the currently declared RDF prefix declarations.\n\n#### `rdf_prefix_any/2`\n\n#### `rdf_prefix_append/[2,3]`\n\n#### `rdf_prefix_iri/[2,3]`\n\nSucceeds for (alias,local-name) pairs and full IRIs.\n\n#### `rdf_prefix_maplist/[2,3]`\n\n#### `rdf_prefix_member/2`\n\n#### `rdf_prefix_memberchk/2`\n\nProvide the corresponding popular Prolog predicates, but apply RDF\nprefix notation expansion on their arguments.\n\nRDF prefix expansion must be specifically declared for arguments in\npredicates.  In the SWI-Prolog standard libraries, such declarations\nhave only been added for predicates in the Semantic Web libraries, but\nnot for predicates in other standard libraries.  For example, the\nfollowing will not check whether `P` is bound to either of the four\nRDFS properties, because the prefix notation is not expanded:\n\n```pl\nmemberchk(P, [rdfs:domain,rdfs:range,rdfs:subClassOf,rdfs:subPropertyOf]),\n```\n\nWith the SWI-Prolog standard library, the above call must be spelled\nout using `rdf_equal/2` in the following way:\n\n```pl\n(   rdf_equal(P, rdfs:domain)\n-\u003e  true\n;   rdf_equal(P, rdfs:range)\n-\u003e  true\n;   rdf_equal(P, rdfs:subClassOf)\n-\u003e  true\n;   rdf_equal(P, rdfs:subPropertyOf)\n-\u003e  true\n)\n```\n\nWhen `library(rdf_prefix)` is loaded, the above can be written as\nfollows:\n\n```pl\nrdf_prefix_memberchk(P, [rdfs:domain,rdfs:range,rdfs:subClassOf,rdfs:subPropertyOf]),\n```\n\n#### `rdf_prefix_selectchk/3`\n\n#### `rdf_prefix_term/2`\n\n#### `rdf_register_prefix/[1-3]`\n\n#### `rdf_register_prefixes/0`\n\n### `library(rdf_print)`\n\nThis module provides DCG rules for printing RDF terms and tuples.\n\n### `library(rdf_term)`\n\nThis module provides advanced support for composing, decomposing,\nparsing, and generating RDF terms.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwouterbeek%2Fprolog_rdf","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwouterbeek%2Fprolog_rdf","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwouterbeek%2Fprolog_rdf/lists"}