/usr/share/perl5/OWL/DirectSemantics.pm is in libowl-directsemantics-perl 0.001-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 | package OWL::DirectSemantics;
BEGIN {
$OWL::DirectSemantics::AUTHORITY = 'cpan:TOBYINK';
$OWL::DirectSemantics::VERSION = '0.001';
};
use 5.008;
use RDF::Trine '0.133';
use RDF::Trine::Serializer::OwlFn;
use OWL::DirectSemantics::Element;
use OWL::DirectSemantics::Translator;
use OWL::DirectSemantics::Writer;
use Module::Pluggable
search_path => 'OWL::DirectSemantics::Element',
sub_name => 'element_modules',
require => 1,
;
use Module::Pluggable
search_path => 'OWL::DirectSemantics::TraitFor::Element',
sub_name => 'element_traits',
require => 1,
;
use Scalar::Util qw[];
BEGIN
{
OWL::DirectSemantics->element_traits;
OWL::DirectSemantics->element_modules;
}
unless(RDF::Trine::Model->can('remove_list'))
{
# Patch current versions of Trine with remove_list
*{'RDF::Trine::Model::remove_list'} = sub
{
my $self = shift;
my $head = shift;
my $rdf = RDF::Trine::Namespace->new('http://www.w3.org/1999/02/22-rdf-syntax-ns#');
my %args = @_;
my %seen;
while (Scalar::Util::blessed($head) and not($head->isa('RDF::Trine::Node::Resource') and $head->uri_value eq $rdf->nil->uri_value)) {
if ($seen{ $head->as_string }++) {
throw RDF::Trine::Error -text => "Loop found during rdf:List traversal";
}
my $stream = $self->get_statements($head, undef, undef);
my %statements;
while (my $st = $stream->next) {
my $statement_type = {
$rdf->first->uri => 'rdf:first',
$rdf->rest->uri => 'rdf:rest',
$rdf->type->uri => 'rdf:type',
}->{$st->predicate->uri} || 'other';
$statement_type = 'other'
if $statement_type eq 'rdf:type' && !$st->object->equal($rdf->List);
push @{$statements{$statement_type}}, $st;
}
if ($args{orphan_check}) {
return $head if defined $statements{other} && scalar(@{ $statements{other} }) > 0;
return $head if $self->count_statements(undef, undef, $head) > 0;
}
unless (scalar(@{ $statements{'rdf:first'} })==1 and scalar(@{ $statements{'rdf:rest'} })==1) {
throw RDF::Trine::Error -text => "Invalid structure found during rdf:List traversal";
}
$self->remove_statement($_)
foreach (@{$statements{'rdf:first'}}, @{$statements{'rdf:rest'}}, @{$statements{'rdf:type'}});
$head = $statements{'rdf:rest'}->[0]->object;
}
return;
}
}
1;
=head1 NAME
OWL::DirectSemantics - representation of the direct semantics of OWL2
=head1 SYNOPSIS
use RDF::Trine;
my $model = RDF::Trine::Model->temporary_model;
RDF::Trine::Mode->parse_url_into_model($url, $model);
use OWL::DirectSemantics;
my $translator = OWL::DirectSemantics::Translator->new;
my $ontology = $translator->translate($model);
foreach my $ax ($ontology->axioms)
{
if ($ax->element_name eq 'ClassAssertion')
{
printf("%s is of type %s.\n", $ax->node, $ax->class);
}
}
print "The following data couldn't be translated to OWL:\n";
print RDF::Trine::Serializer
->new('ntriples')
->serialize_model_to_string($model);
=head1 DESCRIPTION
This distribution provides a basic framework for representing the OWL 2 direct semantics
model, and a translator to build that model from an RDF-based model.
=head1 SEE ALSO
L<OWL::DirectSemantics::Translator>,
L<OWL::DirectSemantics::Element>,
L<RDF::Trine::Serializer::OwlFn>.
L<RDF::Closure>,
L<RDF::Trine::Parser::OwlFn>.
L<RDF::Trine>,
L<RDF::Query>,
L<http://www.perlrdf.org/>.
=head1 AUTHOR
Toby Inkster E<lt>tobyink@cpan.orgE<gt>.
=head1 COPYRIGHT
Copyright 2011-2012 Toby Inkster
This library is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.
=head1 DISCLAIMER OF WARRANTIES
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.
|