% This LaTeX document was generated using the LaTeX backend of PlDoc, % The SWI-Prolog documentation system \section{library(semweb/rdf_ntriples): Process files in the RDF N-Triples format} \label{sec:rdfntriples} \begin{tags} \tag{See also} \url{http://www.w3.org/TR/n-triples/} \tag{To be done} Sync with RDF 1.1. specification. \end{tags} The \file{library(semweb/rdf_ntriples)} provides a fast reader for the RDF N-Triples and N-Quads format. N-Triples is a simple format, originally used to support the W3C RDF test suites. The current format has been extended and is a subset of the Turtle format (see \file{library(semweb/turtle)}). The API of this library is almost identical to \file{library(semweb/turtle)}. This module provides a plugin into \predref{rdf_load}{2}, making this predicate support the format \const{ntriples} and \const{nquads}.\vspace{0.7cm} \begin{description} \predicate[det]{read_ntriple}{2}{+Stream, -Triple} Read the next triple from \arg{Stream} as \arg{Triple}. \arg{Stream} must have UTF-8 encoding. \begin{arguments} \arg{Triple} & is a term \verb$triple(Subject,Predicate,Object)$. Arguments follow the normal conventions of the RDF libraries. NodeID elements are mapped to \verb$node(Id)$. If end-of-file is reached, \arg{Triple} is unified with \verb$end_of_file$. \\ \end{arguments} \begin{tags} \tag{Errors} \verb$syntax_error(Message)$ on syntax errors \end{tags} \predicate[det]{read_nquad}{2}{+Stream, -Quad} Read the next quad from \arg{Stream} as \arg{Quad}. \arg{Stream} must have UTF-8 encoding. \begin{arguments} \arg{Quad} & is a term \verb$quad(Subject,Predicate,Object,Graph)$. Arguments follow the normal conventions of the RDF libraries. NodeID elements are mapped to \verb$node(Id)$. If end-of-file is reached, \arg{Quad} is unified with \verb$end_of_file$. \\ \end{arguments} \begin{tags} \tag{Errors} \verb$syntax_error(Message)$ on syntax errors \end{tags} \predicate[det]{read_ntuple}{2}{+Stream, -Tuple} Read the next triple or quad from \arg{Stream} as \arg{Tuple}. \arg{Tuple} is one of the terms below. See \predref{read_ntriple}{2} and \predref{read_nquad}{2} for details. \begin{shortlist} \item \verb$triple(Subject,Predicate,Object)$ \item \verb$quad(Subject,Predicate,Object,Graph)$. \end{shortlist} \predicate[det]{rdf_read_ntriples}{3}{+Input, -Triples, +Options} \nodescription \predicate[det]{rdf_read_nquads}{3}{+Input, -Quads, +Options} True when \arg{Triples}/\arg{Quads} is a list of triples/quads from \arg{Input}. \arg{Options}: \begin{description} \termitem{anon_prefix}{+AtomOrNode} Prefix nodeIDs with this atom. If \arg{AtomOrNode} is the term \verb$node(_)$, bnodes are returned as \verb$node(Id)$. \termitem{base_uri}{+Atom} Defines the default anon_prefix as _\Smapselect{}baseuri$>$_ \termitem{on_error}{Action} One of \const{warning} (default) or \const{error} \termitem{error_count}{-Count} If \verb$on_error$ is \const{warning}, unify \arg{Count} with th number of errors. \termitem{graph}{+Graph} For \predref{rdf_read_nquads}{3}, this defines the graph associated to \textit{triples} loaded from the input. For \predref{rdf_read_ntriples}{3} this opion is ignored. \end{description} \begin{arguments} \arg{Triples} & is a list of \verb$rdf(Subject, Predicate, Object)$ \\ \arg{Quads} & is a list of \verb$rdf(Subject, Predicate, Object, Graph)$ \\ \end{arguments} \predicate{rdf_process_ntriples}{3}{+Input, :CallBack, +Options} Call-back interface, compatible with the other triple readers. In addition to the options from \predref{rdf_read_ntriples}{3}, this processes the option \verb$graph(Graph)$. \begin{arguments} \arg{CallBack} & is called as \verb$call(CallBack, Triples, Graph)$, where Triples is a list holding a single \verb$rdf(S,P,O)$ triple. Graph is passed from the \const{graph} option and unbound if this option is omitted. \\ \end{arguments} \qpredicate[semidet,multifile]{rdf_db}{rdf_load_stream}{3}{+Format, +Stream, :Options}Plugin rule that supports loading the \const{ntriples} and \const{nquads} formats. \qpredicate[multifile]{rdf_db}{rdf_file_type}{2}{+Extension, -Format}Bind the ntriples reader to files with the extensions \const{nt}, \const{ntriples} and \const{nquads}. \end{description}