RDF::aREF(3pm)

πŸ“¦
version 0.28 Β· 3 versions
, in debian bookworm, debian trixie, ubuntu noble, ubuntu questing

πŸ’– RDF::aREF πŸ’–

okay bestie, gather round, because we're talking about RDF::aREF β€” that's Another RDF Encoding Form, from the User Contributed Perl Documentation ✨


✨ NAME ✨

RDF::aREF β€” Another RDF Encoding Form. yes, that's the whole name, and yes, it's iconic πŸŽ€


🌸 SYNOPSIS 🌸

here's the vibe, no cap:

use RDF::aREF;

my $rdf = {
  _id       => 'http://example.com/people#alice',
  foaf_name => 'Alice Smith',
  foaf_age  => '42^xsd_integer',
  foaf_homepage => [
     {
       _id => 'http://personal.example.org/',
       dct_modified => '2010-05-29^xsd_date',
     },
    'http://work.example.com/asmith/',
  ],
  foaf_knows => {
    dct_description => 'a nice guy@en',
  },
};

decode_aref( $rdf,
    callback => sub {
        my ($subject, $predicate, $object, $language, $datatype) = @_;
        ...
    }
);

my @lastmod = aref_query $rdf, 'foaf_homepage.dct_modified^';

my $model = RDF::Trine::Model->new;
decode_aref( $rdf, callback => $model );
print RDF::Trine::Serializer->new('Turtle')->serialize_model_to_string($model);

my $model = RDF::Trine::Model->new;
RDF::Trine::Parser->parse_url_into_model($url, $model);
my $aref = encode_aref $model;

like… the whole graph in one little hash?? the way that just works πŸ’…


πŸ¦‹ DESCRIPTION πŸ¦‹

aREF β€” short for another RDF Encoding Form (<http://gbv.github.io/aREF/>) β€” is a whole encoding of RDF graphs in the form of arrays, hashes, and Unicode strings. so like, your triples but make it cozy 🫢

This module hands you the methods for:

  • decoding from aREF data to RDF triples β€” that's RDF::aREF::Decoder
  • encoding RDF data in aREF β€” that's RDF::aREF::Encoder
  • querying parts of an RDF graph β€” that's RDF::aREF::Query

three icons, one module, periodt ✨


πŸ’€ WARNING πŸ’€

okay bestie, sit down, we need to talk. 😭

aREF has been an attempt to solve problems that meanwhile have largely been solved by JSON-LD (<https://json-ld.org/>). Despite aRef having its own benefits, please consider using a more established technology (JSON-LD) instead!

fr fr, this is a real warning. aREF is a cute little vibe but JSON-LD is the main character now. use it. πŸ™ˆ

πŸ‘‘ EXPORTED FUNCTIONS πŸ‘‘

The following functions are exported by default. so you don't even gotta ask, they just show up 🌈

πŸŽ€ decode_aref $aref [, %options ]

Decodes an aREF document given as a hash reference, using RDF::aREF::Decoder. πŸ’–

Equivalent to:

RDF::aREF::Decoder->new(%options)->decode($aref)

πŸŽ€ encode_aref $graph [, %options ]

Construct an aREF subject map from an RDF graph. 🌸

The RDF::aREF::Encoder for possible options. (yes, go look at that one for your options, bestie β€” this is your sign ✨)

The $graph can be supplied as:

  • instance of RDF::Trine::Model
  • instance of RDF::Trine::Model::Iterator
  • an URL or a filename (only if RDF::Trine is installed)
  • instance of Attean::API::TripleIterator (experimental)
  • instance of Attean::API::TripleStore (experimental)
  • hash reference with RDF/JSON format (<http://www.w3.org/TR/rdf-json/>) β€” as returned by method as_hashref in RDF::Trine::Model
not me listing six whole formats like a menu πŸ“ two of them are experimental, iykyk πŸ‘€

πŸŽ€ aref_query $graph, [ $origin ], @queries

Query parts of an aREF data structure by aREF query expressions (<http://gbv.github.io/aREF/aREF.html#aref-query>) and return a list. πŸ¦‹

See RDF::aREF::Query for details.

πŸŽ€ aref_query_map( $graph, [ $origin ], $query_map )

Map parts of an aREF data structure to a flat key-value structure. so tidy. so clean. we love a flat structure πŸ’œ


🌈 SEE ALSO 🌈

  • aREF is specified at <http://github.com/gbv/aREF>. πŸ“–
  • See Catmandu::RDF for an application of this module. πŸ“
  • See RDF::Trine for more elaborated handling of RDF data in Perl. πŸ’…
  • See RDF::YAML for a similar (outdated) RDF encoding in YAML. πŸ™ˆ

Copyright Jakob Voss, 2014- ⭐

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. πŸ‘‘


and that's the whole page bestie!! πŸŽ€βœ¨ this one shipped as part of perl v5.36.0, dated 2022-12-07 β€” yeah it's giving vintage but it still ate πŸ’…πŸ«Ά go forth and encode responsibly, mwah πŸ’–

πŸ“¦ where this page comes from