Debian Codegraph @

README

raw
1 NAME
2 RDF::Closure - pure Perl RDF inferencing
3
4 SYNOPSIS
5 use RDF::Trine::Iterator qw[sgrep];
6 use RDF::Closure qw[iri mk_filter FLT_NONRDF FLT_BORING];
7
8 my $data = iri('http://bloggs.example.com/foaf.rdf');
9 my $foaf = iri('http://xmlns.com/foaf/0.1/index.rdf');
10
11 my $model = RDF::Trine::Model->temporary_model;
12 my $p = 'RDF::Trine::Parser';
13 $p->parse_url_into_model($data->uri, $model, context => $data->uri);
14 $p->parse_url_into_model($foaf->uri, $model, context => $foaf->uri);
15
16 my $cl = RDF::Closure::Engine->new('rdfs', $model);
17 $cl->closure;
18
19 my $filter = mk_filter(FLT_NONRDF|FLT_BORING, [$foaf]);
20 my $output = &sgrep($filter, $model->as_stream);
21
22 print RDF::Trine::Serializer
23 ->new('RDFXML')
24 ->serialize_iterator_to_string($output);
25
26 DESCRIPTION
27 This distribution is a pure Perl RDF inference engine designed as an
28 add-in for RDF::Trine. It is largely a port of Ivan Herman's Python
29 RDFClosure library, though there has been some restructuing, and there
30 are a few extras thrown in.
31
32 Where one of the Perl modules has a direct equivalent in Ivan's library,
33 this is noted in the POD.
34
35 Functions
36 This package inherits from RDF::Trine and exports the same functions,
37 plus:
38
39 * "mk_filter($basic_filters, $ignore_contexts)"
40
41 Creates a filter (coderef) suitable for use with "sgrep" from
42 RDF::Trine::Iterator.
43
44 $basic_filters is an integer which can be assembled by
45 bitwise-OR-ing the constants "FLT_NONRDF" and "FLT_BORING".
46
47 $ignore_contexts is an arrayref of RDF::Trine::Node objects, each of
48 which represents a context that should be filtered out.
49
50 use RDF::Trine::Iterator qw[sgrep];
51 use RDF::Closure qw[iri mk_filter FLT_NONRDF FLT_BORING];
52
53 my $foaf = iri('http://xmlns.com/foaf/0.1/index.rdf');
54 my $filter = mk_filter(FLT_NONRDF|FLT_BORING, [$foaf]);
55
56 my $remaining = &sgrep($filter, $model->as_stream);
57
58 # $remaining is now an iterator which will return all triples
59 # from $model except: those in the FOAF named graph, those which
60 # are non-RDF (e.g. literal subject) and those which are boring.
61
62 Which triples are boring? Any triple of the form { ?x owl:sameAs ?x
63 .}, { ?x owl:equivalentProperty ?x .}, { ?x owl:equivalentClass ?x
64 .}, { ?x rdfs:subPropertyOf ?x .} or { ?x rdfs:subClassOf ?x .} is
65 boring (i.e. where these statements have the same term in subject
66 and object position). Any triple where the subject, predicate and
67 object nodes are all in the RDF, RDFS, OWL or XSD namespaces is
68 boring. Other triples are not boring.
69
70 For convenience, "RDF::Closure" also exports variables called $RDF,
71 $RDFS, $OWL and $XSD which are RDF::Trine::Namespace objects.
72
73 SEE ALSO
74 RDF::Closure::Engine, RDF::Closure::Model, RDF::Trine::Parser::OwlFn.
75
76 RDF::Trine, RDF::Query.
77
78 <http://www.perlrdf.org/>.
79
80 <http://www.ivan-herman.net/Misc/2008/owlrl/>.
81
82 AUTHOR
83 Toby Inkster <[email protected]>.
84
85 COPYRIGHT
86 Copyright 2011-2012 Toby Inkster
87
88 This library is free software; you can redistribute it and/or modify it
89 under any of the following licences:
90
91 * The Artistic License 1.0
92 <http://www.perlfoundation.org/artistic_license_1_0>.
93
94 * The GNU General Public License Version 1
95 <http://www.gnu.org/licenses/old-licenses/gpl-1.0.txt>, or (at your
96 option) any later version.
97
98 * The W3C Software Notice and License
99 <http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231
100 >.
101
102 * The Clarified Artistic License
103 <http://www.ncftp.com/ncftp/doc/LICENSE.txt>.
104
105 DISCLAIMER OF WARRANTIES
106 THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED
107 WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
108 MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
109