Scroll to navigation

Catmandu::Importer::RDF(3pm) User Contributed Perl Documentation Catmandu::Importer::RDF(3pm)


Catmandu::Importer::RDF - parse RDF data


Command line client "catmandu":

  catmandu convert RDF --url to YAML
  catmandu convert RDF --file rdfdump.ttl to JSON
  # Parse the input into on JSON document per triplet. This is the
  # most memory efficient (and fastest) way to parse RDF input.
  catmandu convert RDF --triples 1 --file rdfdump.ttl to JSON
  # Transform back into NTriples (conversions to and from triples is the
  # most efficient way to process RDF)
  catmandu convert RDF --triples 1 --file rdfdump.ttl to RDF --type NTriples
  # Query a SPARQL endpoint
  catmandu convert RDF --url
                       --sparql "SELECT ?film WHERE { ?film dct:subject <> }"
  catmandu convert RDF --url --sparql query.rq
  # Query a Linked Data Fragment endpoint
  catmandu convert RDF --url
                       --sparql "SELECT ?film WHERE { ?film dct:subject <> }"

In Perl code:

    use Catmandu::Importer::RDF;
    my $url = "";
    my $rdf = Catmandu::Importer::RDF->new( url => $url )->first;


This Catmandu::Importer can be use to import RDF data from URLs, files or input streams, SPARQL endpoints, and Linked Data Fragment endpoints.

By default an RDF graph is imported as single item in aREF format (see RDF::aREF).


URL to retrieve RDF from.
RDF serialization type (e.g. "ttl" for RDF/Turtle).
Base URL. By default derived from the URL or file name.
Use default namespace prefixes as provided by RDF::NS to abbreviate predicate and datatype URIs. Set to 0 to disable abbreviating URIs. Set to a specific date to get stable namespace prefix mappings.
Import each RDF triple as one aREF subject map (default) or predicate map (option "predicate_map"), if enabled. This is the most efficient way to process large input files. All the processing can be streamed.
Import RDF as aREF predicate map, if possible.
Default configuration options of Catmandu::Importer.
The SPARQL query to be executed on the URL endpoint (currectly only SELECT is supported). The query can be supplied as string or as filename. The importer tries to automatically add missing PREFIX statements from the default namespace prefixes.
Encoding of SPARQL result values. With "aref", query results are encoded in aREF format, with URIs in "<" and ">" (no qNames) and literal nodes appended by "@" and optional language code. By default (value "simple"), all RDF nodes are simplfied to their literal form.
Set to a true value to cache repeated URL responses in a CHI based backend.
Provide the CHI based options for caching result sets. By default a memory store of 1MB size is used. This is equal to:

    Catamandu::Importer::RDF->new( ...,
        cache => 1,
        cache_options => {
            driver => 'Memory',
            global => 1,
            max_size => 1024*1024
If set to a true value, then write RDF file processing speed on the STDERR as number of triples parsed per second.


See Catmandu::Importer.


RDF::Trine::Store, RDF::Trine::Parser

2019-02-19 perl v5.28.1