/usr/bin/rdf2owl is in libowl-directsemantics-perl 0.001-2.
This file is owned by root:root, with mode 0o755.
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 | #!/usr/bin/perl
eval 'exec /usr/bin/perl -S $0 ${1+"$@"}'
if 0; # not running under some shell
exit(OWL::DirectSemantics::rdf2owl->run(@ARGV)) unless (caller);
package OWL::DirectSemantics::rdf2owl;
use RDF::Trine;
use OWL::DirectSemantics;
use LWP::UserAgent;
use URI::file;
sub run
{
my ($class, @args) = @_;
my ($input, $in_type) = (STDIN, 0);
if (@args and !ref($args[0]) and $args[0] ne '-')
{
$input = shift @args;
$in_type = ($input =~ m/^[A-Za-z0-9+\.]{1,12}:/i) ? 2 : 1;
}
my ($output, $out_type) = (*STDOUT, 0);
if (@args and !ref($args[0]) and $args[0] ne '-')
{
$output = shift @args;
$out_type = ($output =~ m/^[A-Za-z0-9+\.]{1,12}:/i) ? 2 : 1;
}
my $input_model = $class->build_model($input, $input_type);
my $ontology = OWL::DirectSemantics::Translator
->new
->translate($input_model);
return $class->output($ontology->fs, $output, $out_type);
}
sub build_model
{
my ($class, $input, $input_type) = @_;
my $model = RDF::Trine::Model->temporary_model;
if ($input_type == 2) # URL
{
RDF::Trine::Parser->parse_url_into_model($input, $model);
}
elsif ($input_type == 1) # File
{
my $base_uri = $class->filename_to_uri($input);
RDF::Trine::Parser->parse_file_into_model($base_uri, $input, $model);
}
elsif ($input_type == 0) # Handle
{
my $base_uri = $class->filename_to_uri($^O eq 'MSWin32' ? 'CON' : '/dev/stdin');
RDF::Trine::Parser->parse_file_into_model($base_uri, $input, $model);
}
return $model;
}
sub filename_to_uri
{
my ($class, $filename) = @_;
return URI::file->new($filename)->as_string;
}
sub output
{
my ($class, $string, $destination, $dest_type) = @_;
if ($dest_type == 1)
{
my $fn = $destination;
undef($destination);
open $destination, '>', $fn;
$dest_type--;
}
if ($dest_type == 0)
{
print $destination $string;
return 0;
}
elsif ($dest_type == 2)
{
my $ua = LWP::UserAgent->new(
agent => sprintf('%s/%s ', __PACKAGE__, $VERSION),
);
my $resp = $ua->simple_request(
HTTP::Request->new(
PUT => $destination,
HTTP::Headers->new(
'Content-Type' => 'text/owl-functional',
),
$string,
),
);
return 0 if $resp->is_success;
die($resp->status_line . "\n");
}
}
1;
|