/usr/share/doc/librdf-trin3-perl/examples/microturtle.pl is in librdf-trin3-perl 0.204-1.
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 | #!/usr/bin/perl
# -*- coding: utf-8 -*-
use 5.010;
use utf8;
use RDF::TriN3;
use RDF::Trine qw[iri blank literal statement];
use RDF::Trine::Namespace qw[rdf rdfs owl xsd];
my $foaf = RDF::Trine::Namespace->new('http://xmlns.com/foaf/0.1/');
my $tags = RDF::Trine::Namespace->new('http://www.holygoat.co.uk/owl/redwood/0.1/tags/');
my $n3 = <<'NOTATION3';
<> tagged #bar .
##foo gist #baz .
@tai says "Phooey" ; ❤ @alci ; :born 1980-06-01 .
NOTATION3
{
my (%person, %hashtag);
sub cb_person
{
my ($lit, $cb) = @_;
if ($lit->literal_value =~ /^\@(.+)$/)
{
my $nick = literal($1);
unless (defined $person{$1})
{
$person{$1} = blank();
$cb->(statement($person{$1}, $rdf->type, $foaf->Person));
$cb->(statement($person{$1}, $foaf->nick, $nick));
}
return $person{$1};
}
return;
}
sub cb_hashtag
{
my ($lit, $cb) = @_;
if ($lit->literal_value =~ /^\#(.+)$/)
{
my $label = literal($1);
unless (defined $hashtag{$1})
{
$hashtag{$1} = blank();
$cb->(statement($hashtag{$1}, $rdf->type, $tags->Tag));
$cb->(statement($hashtag{$1}, $tags->name, $label));
}
return $hashtag{$1};
}
return;
}
}
my $parser = RDF::Trine::Parser::ShorthandRDF->new(
profile => '@import <http://buzzword.org.uk/2009/microturtle/profile.n3x> .',
datatype_callback => {
'http://buzzword.org.uk/2009/microturtle/person' => \&cb_person,
'http://buzzword.org.uk/2009/microturtle/hashtag' => \&cb_hashtag,
});
$parser->parse('http://example.org/', $n3, sub {say $_[0]->sse});
|