SWI-Prolog Semantic Web Library
Abstract
The semweb library provides a Prolog library based on foreign-language extensions for storing and manipulating RDF triples. It can handle quite large sets of triples only limited by available memory. One million triples requires about 80MB memory, so a fully equiped 32-bit machine can handle about 25 million triples. A 64-bit machine with 32Gb memory (just a few thousand euros in june 2009) can handle up to 150 million triples.
Prerequisites
This library depends on the RDF parser library which in turn depends on the XML parser provided by the sgml package.
Further info
This library defines the semantic web infrastructure for SWI-Prolog. The library is documented in semweb.pdf or the equivalent semweb.html. If your installation does not include this file, please visit http://www.swi-prolog.org/packages/
Staying up-to-date
This library is under active development. The recent version can be accessed from the GIT repository under the directory pl/packages/semweb. See http://www.swi-prolog.org/git.html for details on the central GIT repository and instructions for browsing the repository online.
Prolog files
rdf11.pl -- RDF 1.1 API | ||
---|---|---|
rdf_bnode/1 | True if BNode is a currently known blank node. | |
rdf_canonical_literal/2 | Transform a relaxed literal specification as allowed for rdf_assert/3 into its canonical form. | |
rdf_compare/3 | True if the RDF terms Left and Right are ordered according to the comparison operator Diff. | |
rdf_create_bnode/1 | Create a new BNode. | |
rdf_estimate_complexity/4 | ||
rdf_iri/1 | True if IRI is a current IRI. | |
rdf_is_bnode/1 | True if Term is an RDF blank node identifier. | |
rdf_is_iri/1 | True if IRI is an RDF IRI term. | |
rdf_is_literal/1 | True if Term is an RDF literal term. | |
rdf_is_name/1 | True if Term is an RDF Name, i.e., an IRI or literal. | |
rdf_is_object/1 | True if Term can appear in the object position of a triple. | |
rdf_is_predicate/1 | True if Term can appear in the predicate position of a triple. | |
rdf_is_subject/1 | True if Term can appear in the subject position of a triple. | |
rdf_is_term/1 | True if Term can be used as an RDF term, i.e., if Term is either an IRI, a blank node or an RDF literal. | |
rdf_last/2 | True when Last is the last element of RDFList. | |
rdf_length/2 | True when Length is the number of cells in RDFList. | |
rdf_lexical_form/2 | True when Lexical is the lexical form for the literal Literal. | |
rdf_list/1 | True if RDFTerm is a proper RDF list. | |
rdf_list/2 | True when PrologList represents the rdf:first objects for all cells in RDFList. | |
rdf_literal/1 | True if Term is a known literal. | |
rdf_member/2 | True when Member is a member of RDFList. | |
rdf_name/1 | True if Name is a current IRI or literal. | |
rdf_node/1 | True when T appears in the subject or object position of a known triple, i.e., is a node in the RDF graph. | |
rdf_object/1 | True when O is a currently known object, i.e. | |
rdf_predicate/1 | True when P is a currently known predicate, i.e. | |
rdf_retract_list/1 | Retract the rdf:first, rdf:rest and rdf:type=rdf:'List' triples from all nodes reachable through rdf:rest. | |
rdf_subject/1 | True when S is a currently known subject, i.e. | |
rdf_term/1 | True if Term appears in the RDF database. | |
rdf/3 | True if an RDF triple <S,P,O> exists, optionally in the graph G. | |
rdf_assert/3 | Assert a new triple. | |
rdf_assert_list/2 | Create an RDF list from the given Prolog List. | |
rdf_default_graph/1 | Query/set the notion of the default graph. | |
rdf_has/3 | Similar to rdf/3 and rdf/4, but P matches all predicates that are defined as an rdfs:subPropertyOf of P. | |
rdf_nextto/2 | True if Y directly follows X in RdfList. | |
rdf_nth0/3 | True when X is the Index-th element (0-based or 1-based) of RDFList. | |
rdf_reachable/3 | True when O can be reached from S using the transitive closure of P. | |
rdf_retractall/3 | Remove all matching triples from the database. | |
rdf_update/4 | Replaces one of the three fields on the matching triples depending on Action:. | |
{}/1 | Formulate constraints on RDF terms, notably literals. | |
rdf_cache.pl -- Cache RDF triples | ||
rdf_cache_file/3 | File is the cache file for URL. | |
rdf_set_cache_options/1 | Change the cache policy. | |
rdf_db.pl -- Core RDF database | ||
lang_equal/2 | True if two RFC language specifiers denote the same language. | |
lang_matches/2 | True if Lang matches Pattern. | |
ns/2 | Dynamic and multifile predicate that maintains the registered namespace aliases. | |
rdf/3 | Elementary query for triples. | |
rdf/4 | As rdf/3 but in addition query the graph to which the triple belongs. | |
rdf_active_transaction/1 | True if Id is the identifier of a transaction in the context of which this call is executed. | |
rdf_assert/3 | Assert a new triple into the database. | |
rdf_assert/4 | As rdf_assert/3, adding the predicate to the indicated named graph. | |
rdf_atom_md5/3 | Computes the MD5 hash from Text, which is an atom, string or list of character codes. | |
rdf_bnode/1 | Generate a unique anonymous identifier for a subject. | |
rdf_compare/3 | Compare two object terms. | |
rdf_create_graph/1 | Create an RDF graph without triples. | |
rdf_current_literal/1 | True when Literal is a currently known literal. | |
rdf_current_ns/2 | ||
rdf_current_predicate/1 | True when Predicate is a currently known predicate. | |
rdf_current_prefix/2 | Query predefined prefixes and prefixes defined with rdf_register_prefix/2 and local prefixes defined with rdf_prefix/2. | |
rdf_current_snapshot/1 | True when Term is a currently known snapshot. | |
rdf_debug/1 | Set debugging to Level. | |
rdf_delete_literal_map/2 | Delete Key and all associated values from the map. | |
rdf_delete_literal_map/3 | Delete the association between Key and Value from the map. | |
rdf_delete_snapshot/1 | Delete a snapshot as obtained from rdf_snapshot/1. | |
rdf_destroy_literal_map/1 | Destroy a literal map. | |
rdf_equal/2 | Simple equality test to exploit goal-expansion. | |
rdf_estimate_complexity/4 | Return the number of alternatives as indicated by the database internal hashed indexing. | |
rdf_file_type/2 | True if Format is the format belonging to the given file extension. | |
rdf_find_literal_map/3 | Unify ValueList with an ordered set of values associated to all keys from KeyList. | |
rdf_gc/0 | Run the RDF-DB garbage collector until no garbage is left and all tables are fully optimized. | |
rdf_generation/1 | True when Generation is the current generation of the database. | |
rdf_global_id/2 | Convert between Prefix:Local and full IRI (an atom). | |
rdf_global_object/2 | Same as rdf_global_id/2, but intended for dealing with the object part of a triple, in particular the type for typed literals. | |
rdf_global_term/2 | Performs rdf_global_id/2 on predixed IRIs and rdf_global_object/2 on RDF literals, by recursively analysing the term. | |
rdf_graph/1 | True when Graph is an existing graph. | |
rdf_graph_property/2 | True when Property is a property of Graph. | |
rdf_has/3 | Succeeds if the triple rdf(Subject, Predicate, Object) is true exploiting the rdfs:subPropertyOf predicate as well as inverse predicates declared using rdf_set_predicate/2 with the inverse_of property. | |
rdf_has/4 | Same as rdf_has/3, but RealPredicate is unified to the actual predicate that makes this relation true. | |
rdf_insert_literal_map/3 | Add a relation between Key and Value to the map. | |
rdf_insert_literal_map/4 | As rdf_insert_literal_map/3. | |
rdf_is_bnode/1 | Tests if a resource is a blank node (i.e. | |
rdf_is_literal/1 | True if Term is an RDF literal object. | |
rdf_is_resource/1 | True if Term is an RDF resource. | |
rdf_keys_in_literal_map/3 | Realises various queries on the key-set:. | |
rdf_literal_value/2 | True when value is the appropriate Prolog representation of Literal in the RDF value space. | |
rdf_load/1 | Same as rdf_load(FileOrList, []) . | |
rdf_load/2 | Load RDF data. | |
rdf_load_db/1 | Load triples from a file created using rdf_save_db/2. | |
rdf_load_stream/3 | Load RDF data from Stream. | |
rdf_make/0 | Reload all loaded files that have been modified since the last time they were loaded. | |
rdf_match_label/3 | True if Label matches Pattern according to How. | |
rdf_md5/2 | True when MD5 is the MD5 hash for all triples in graph. | |
rdf_member_property/2 | Deal with the rdf:_1, ... properties. | |
rdf_meta/1 | This directive defines the argument types of the named predicates, which will force compile time namespace expansion for these predicates. | |
rdf_monitor/2 | Call Goal if specified actions occur on the database. | |
rdf_new_literal_map/1 | Create a new literal map, returning an opaque handle. | |
rdf_node/1 | Generate a unique blank node identifier for a subject. | |
rdf_predicate_property/2 | Query properties of a defined predicate. | |
rdf_prefix/2 | Register a local prefix. | |
rdf_reachable/3 | Is true if Object can be reached from Subject following the transitive predicate Predicate or a sub-property thereof, while repecting the symetric(true) or inverse_of(P2) properties. | |
rdf_reachable/5 | Same as rdf_reachable/3, but in addition, MaxD limits the number of edges expanded and D is unified with the `distance' between Subject and Object. | |
rdf_reset_db/0 | Remove all triples from the RDF database and reset all its statistics. | |
rdf_reset_literal_map/1 | Delete all content from the literal map. | |
rdf_resource/1 | True when Resource is a resource used as a subject or object in a triple. | |
rdf_retractall/3 | Remove all matching triples from the database. | |
rdf_retractall/4 | As rdf_retractall/3, also matching Graph. | |
rdf_save/1 | Same as rdf_save(Out, []) . | |
rdf_save/2 | Write RDF data as RDF/XML. | |
rdf_save_footer/1 | Finish XML generation and write the document footer. | |
rdf_save_header/2 | Save XML document header, doctype and open the RDF environment. | |
rdf_save_subject/3 | Save the triples associated to Subject to Out. | |
rdf_set/1 | Set properties of the RDF store. | |
rdf_set_graph/2 | Set properties of Graph. | |
rdf_set_predicate/2 | Define a property of the predicate. | |
rdf_snapshot/1 | Take a snapshot of the current state of the RDF store. | |
rdf_source/1 | True if Source is a loaded source. | |
rdf_source/2 | True if named Graph is loaded from SourceURL. | |
rdf_source_location/2 | True when triples for Subject are loaded from Location. | |
rdf_split_url/3 | Split/join a URL. | |
rdf_statistics/1 | Obtain statistics on the RDF database. | |
rdf_statistics_literal_map/2 | Query some statistics of the map. | |
rdf_subject/1 | True if Resource appears as a subject. | |
rdf_transaction/1 | Same as rdf_transaction(Goal, user, []) . | |
rdf_transaction/2 | Same as rdf_transaction(Goal, Id, []) . | |
rdf_transaction/3 | Run Goal in an RDF transaction. | |
rdf_unload/1 | Identify the graph loaded from Source and use rdf_unload_graph/1 to erase this graph. | |
rdf_unload_graph/1 | Remove Graph from the RDF store. | |
rdf_update/4 | Replaces one of the three fields on the matching triples depending on Action:. | |
rdf_update/5 | As rdf_update/4 but allows for specifying the graph. | |
rdf_update_duplicates/0 | Update the duplicate administration of the RDF store. | |
rdf_update_duplicates/0 | Update the duplicate administration. | |
rdf_url_namespace/2 | Namespace is the namespace of URL. | |
rdf_version/1 | True when Version is the numerical version-id of this library. | |
rdf_warm_indexes/0 | Warm all indexes. | |
rdf_warm_indexes/1 | Create the named indexes. | |
rdf_graph_prefixes/2 | List is a sorted list of prefixes (namepaces) in Graph. | |
rdf_register_ns/2 | Register an RDF prefix. | |
rdf_register_prefix/2 | Register Prefix as an abbreviation for URI. | |
rdf_save_db/1 | Save triples into File in a quick-to-load binary format. | |
rdf_http_plugin.pl -- RDF HTTP Plugin | ||
rdf_open_hook/8 | Load hook implementation for HTTP(S) URLs. | |
rdf_content_type/3 | Quality values are intended to be used in accordance with RFC 2616. | |
rdf_library.pl -- RDF Library Manager | ||
rdf_attach_library/1 | Attach manifest from Source. | |
rdf_current_manifest/1 | True if URL is the URL of a currently loaded manifest file. | |
rdf_library_index/2 | Query the content of the library. | |
rdf_library_source/2 | True of Source is the URL that is part of the given library Id. | |
rdf_list_library/0 | Prints known RDF library identifiers to current output. | |
rdf_list_library/1 | Print library dependency tree to the terminal. | |
rdf_load_library/1 | Load ontologies from the library. | |
rdf_litindex.pl -- Search literals | ||
rdf_delete_literal_index/1 | Fully delete a literal index. | |
rdf_literal_index/2 | True when Index is a literal map containing the index of Type. | |
rdf_set_literal_index_option/1 | Set options for the literal package. | |
rdf_stopgap_token/1 | True when Token is a stopgap token. | |
rdf_token_expansions/2 | Determine which extensions of a token contribute to finding literals. | |
rdf_tokenize_literal/2 | Tokenize a literal. | |
rdf_find_literal/2 | Find literals in the RDF database matching Spec. | |
rdf_ntriples.pl -- Process files in the RDF N-Triples format | ||
rdf_file_type/2 | Bind the ntriples reader to files with the extensions nt , ntriples and nquads . | |
rdf_load_stream/3 | Plugin rule that supports loading the ntriples and nquads formats. | |
rdf_process_ntriples/3 | Call-back interface, compatible with the other triple readers. | |
read_nquad/2 | Read the next quad from Stream as Quad. | |
read_ntriple/2 | Read the next triple from Stream as Triple. | |
read_ntuple/2 | Read the next triple or quad from Stream as Tuple. | |
rdf_read_ntriples/3 | True when Triples/Quads is a list of triples/quads from Input. | |
rdf_persistency.pl -- RDF persistency plugin | ||
property_of_graph/2 | Extend rdf_graph_property/2 with new properties. | |
rdf_attach_db/2 | Start persistent operations using Directory as place to store files. | |
rdf_current_db/1 | True if Dir is the current RDF persistent database. | |
rdf_db_to_file/2 | Translate between database encoding (often an file or URL) and the name we store in the directory. | |
rdf_detach_db/0 | Detach from the current database. | |
rdf_flush_journals/1 | Flush dirty journals. | |
rdf_journal_file/2 | True if File the name of the existing journal file for Graph. | |
rdf_persistency/2 | Specify whether a database is persistent. | |
rdf_persistency_property/1 | True when Property is a property of the current persistent database. | |
rdf_snapshot_file/2 | True if File the name of the existing snapshot file for Graph. | |
rdf_turtle_write.pl -- Turtle - Terse RDF Triple Language writer | ||
rdf_save_canonical_trig/2 | Save triples in a canonical format. | |
rdf_save_canonical_turtle/2 | Save triples in a canonical format. | |
rdf_save_ntriples/2 | Save RDF using ntriples format. | |
rdf_save_trig/2 | Save multiple RDF graphs into a TriG file. | |
rdf_save_turtle/2 | Save an RDF graph as Turtle. | |
rdf_zlib_plugin.pl -- RDF compressed-data plugin | ||
rdfs.pl -- RDFS handling | ||
rdfs_class_property/2 | Enumerate the properties in the domain of Class. | |
rdfs_find/5 | Search all classes below Domain for a literal property with that matches String. | |
rdfs_individual_of/2 | Generate resources belonging to a class or classes a resource belongs to. | |
rdfs_label/2 | Convert between class and label. | |
rdfs_label/3 | Resource has Label in Lang. | |
rdfs_list_to_prolog_list/2 | Convert ann RDFS list (result from parseType=Collection) into a Prolog list of elements. | |
rdfs_member/2 | As Prolog member on sets. | |
rdfs_subclass_of/2 | Generate sub/super classes. | |
rdfs_subproperty_of/2 | Query the property hierarchy. | |
rdfs_assert_list/2 | Create an RDF list from the given Resources. | |
rdfs_ns_label/2 | Present label with namespace indication. | |
sparql_client.pl -- SPARQL client library | ||
sparql_query/3 | Execute a SPARQL query on an HTTP SPARQL endpoint. | |
sparql_read_json_result/2 | The returned Result term is of the format:. | |
sparql_read_xml_result/2 | Specs from http://www.w3.org/TR/rdf-sparql-XMLres/. | |
sparql_set_server/1 | Set sparql server default options. | |
turtle.pl -- Turtle: Terse RDF Triple Language | ||
rdf_load_stream/3 | (Turtle clauses). | |
rdf_load_turtle/3 | ||
rdf_process_turtle/3 | Streaming Turtle parser. | |
rdf_read_turtle/3 | Read a stream or file into a set of triples or quadruples (if faced with TRiG input) of the format. |