RDF::Closure(3pm)
π RDF::Closure β the manual, but make it make sense π
okay bestie, so this is the page for RDF::Closure(3pm), which lives in the User Contributed Perl Documentation corner of your system. it's about inferencing, it's pure Perl, and honestly? it eats. let's go πΈ
β¨ NAME β¨
RDF::Closure β pure Perl RDF inferencing. that's it, that's the whole vibe. π
π¦ SYNOPSIS π¦
here's the whole thing in action, copy it exactly bestie, don't freestyle:
use RDF::Trine::Iterator qw[sgrep];
use RDF::Closure qw[iri mk_filter FLT_NONRDF FLT_BORING];
my $data = iri('http://bloggs.example.com/foaf.rdf');
my $foaf = iri('http://xmlns.com/foaf/0.1/index.rdf');
my $model = RDF::Trine::Model->temporary_model;
my $p = 'RDF::Trine::Parser';
$p->parse_url_into_model($data->uri, $model, context => $data->uri);
$p->parse_url_into_model($foaf->uri, $model, context => $foaf->uri);
my $cl = RDF::Closure::Engine->new('rdfs', $model);
$cl->closure;
my $filter = mk_filter(FLT_NONRDF|FLT_BORING, [$foaf]);
my $output = &sgrep($filter, $model->as_stream);
print RDF::Trine::Serializer
->new('RDFXML')
->serialize_iterator_to_string($output);
π DESCRIPTION π
so this distribution is a pure Perl RDF inference engine, designed as an add-in for RDF::Trine. no cap, it's largely a port of Ivan Herman's Python RDFClosure library β though there's been some restructuing along the way, and there are a few extras thrown in for funsies. π
where one of the Perl modules has a direct equivalent in Ivan's library, that's noted in the POD. iykyk. π
π§ Functions
this package inherits from RDF::Trine and exports the same functions, plus this one absolute icon:
mk_filter($basic_filters, $ignore_contexts)β creates a filter (coderef) that's suitable for use withsgrepfromRDF::Trine::Iterator. yes, a coderef. we love a callback. π
$basic_filters is an integer, and you build it up by bitwise-OR-ing the constants FLT_NONRDF and FLT_BORING together. bitwise-OR? iconic. π«Ά
$ignore_contexts is an arrayref of RDF::Trine::Node objects β each one represents a context that should be filtered out. bye girl, not you. π
like, for example:
use RDF::Trine::Iterator qw[sgrep];
use RDF::Closure qw[iri mk_filter FLT_NONRDF FLT_BORING];
my $foaf = iri('http://xmlns.com/foaf/0.1/index.rdf');
my $filter = mk_filter(FLT_NONRDF|FLT_BORING, [$foaf]);
my $remaining = &sgrep($filter, $model->as_stream);
# $remaining is now an iterator which will return all triples
# from $model except: those in the FOAF named graph, those which
# are non-RDF (e.g. literal subject) and those which are boring.
so $remaining comes back as an iterator that hands you every triple from $model except:
- the ones in the FOAF named graph πΈ
- the ones that are non-RDF (like, a literal subject? girl.) π
- and the ones that are just plain boring π
which triples are boring, you ask? ok so listen. any triple shaped like { ?x owl:sameAs ?x .}, { ?x owl:equivalentProperty ?x .}, { ?x owl:equivalentClass ?x .}, { ?x rdfs:subPropertyOf ?x .} or { ?x rdfs:subClassOf ?x .} is boring β that means the same term is sitting in both subject and object position. also, any triple where the subject, predicate and object nodes are all hanging out in the RDF, RDFS, OWL or XSD namespaces? boring. everything else is not boring. those are the rules, periodt. β
and for convenience, RDF::Closure also exports variables called $RDF, $RDFS, $OWL and $XSD β they're RDF::Trine::Namespace objects. little gifts. π
π SEE ALSO π
RDF::Closure::EngineRDF::Closure::ModelRDF::Trine::Parser::OwlFn
also: RDF::Trine, RDF::Query.
and the links, bestie:
π AUTHOR π
Toby Inkster <tobyink@cpan.org>. king behavior, honestly. π
π COPYRIGHT π
Copyright 2011-2012 Toby Inkster
This library is free software; you can redistribute it and/or modify it under any of the following licences β yes, any of them, pick your fighter:
- The Artistic License 1.0 <http://www.perlfoundation.org/artistic_license_1_0>.
- The GNU General Public License Version 1 <http://www.gnu.org/licenses/old-licenses/gpl-1.0.txt>, or (at your option) any later version.
- The W3C Software Notice and License <http://www.consortium/Legal/2002/copyright-software-20021231>. β wait no bestie, exact link: <http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231>.
- The Clarified Artistic License <http://www.ncftp.com/ncftp/doc/LICENSE.txt>.
π DISCLAIMER OF WARRANTIES π
ok so this is the part where we yell. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
like. no promises. none. zero. nada. it's giving "you're on your own but with love". π
and that's the whole page, bestie! this wasperl v5.32.1, dated2021-09-24, and it's theRDF::Closure(3pm)manual. go forth and infer. slay. β¨ππ
π¦ where this page comes from
- debian bookworm: librdf-closure-perl 0.001-5 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: librdf-closure-perl 0.001-5 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu jammy: librdf-closure-perl 0.001-5 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: librdf-closure-perl 0.001-5 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: librdf-closure-perl 0.001-5 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: librdf-closure-perl 0.001-5 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms