line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
=head1 NAME |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
AtteanX::Parser::NTriples - N-Triples Parser |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=head1 VERSION |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
This document describes AtteanX::Parser::NTriples version 0.032 |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 SYNOPSIS |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
use Attean; |
12
|
|
|
|
|
|
|
my $parser = Attean->get_parser('NTriples')->new(); |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
# Parse data from a file-handle and handle triples in the 'handler' callback |
15
|
|
|
|
|
|
|
$parser->parse_cb_from_io( $fh ); |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
# Parse the given byte-string, and return an iterator of triples |
18
|
|
|
|
|
|
|
my $iter = $parser->parse_iter_from_bytes('<http://example.org/subject> <tag:example.org:predicate> "object" .'); |
19
|
|
|
|
|
|
|
while (my $triple = $iter->next) { |
20
|
|
|
|
|
|
|
print $triple->as_string; |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=head1 DESCRIPTION |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
This module implements a parser for the N-Triples format. |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=head1 ROLES |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
This class consumes L<Attean::API::Parser>, L<Attean::API::PullParser> |
30
|
|
|
|
|
|
|
and <Attean::API::TripleParser>. |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=head1 METHODS |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=over 4 |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=cut |
37
|
|
|
|
|
|
|
|
38
|
5
|
|
|
5
|
|
11291
|
use v5.14; |
|
5
|
|
|
|
|
18
|
|
39
|
5
|
|
|
5
|
|
33
|
use warnings; |
|
5
|
|
|
|
|
9
|
|
|
5
|
|
|
|
|
205
|
|
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
use utf8; |
42
|
5
|
|
|
5
|
|
28
|
|
|
5
|
|
|
|
|
18
|
|
|
5
|
|
|
|
|
30
|
|
43
|
|
|
|
|
|
|
use Attean; |
44
|
5
|
|
|
5
|
|
115
|
use Moo; |
|
5
|
|
|
|
|
11
|
|
|
5
|
|
|
|
|
27
|
|
45
|
5
|
|
|
5
|
|
27
|
extends 'AtteanX::Parser::NTuples'; |
|
5
|
|
|
|
|
11
|
|
|
5
|
|
|
|
|
27
|
|
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=item C<< canonical_media_type >> |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
Returns the canonical media type for N-Triples: application/n-triples. |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=cut |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
|
54
|
1
|
|
|
1
|
1
|
597
|
=item C<< media_types >> |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
Returns a list of media types that may be parsed with the N-Triples parser: |
57
|
|
|
|
|
|
|
application/n-triples. |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=cut |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
return [qw(application/n-triples)]; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
5
|
|
|
5
|
1
|
19
|
=item C<< file_extensions >> |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
Returns a list of file extensions that may be parsed with the parser. |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=cut |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
with 'Attean::API::TripleParser'; |
72
|
|
|
|
|
|
|
with 'Attean::API::PullParser'; |
73
|
12
|
|
|
12
|
1
|
45
|
with 'Attean::API::Parser'; |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
my $self = shift; |
76
|
|
|
|
|
|
|
my $nodes = shift; |
77
|
|
|
|
|
|
|
my $lineno = shift; |
78
|
|
|
|
|
|
|
if (scalar(@$nodes) == 3) { |
79
|
|
|
|
|
|
|
return Attean::Triple->new(@$nodes); |
80
|
19
|
|
|
19
|
|
35
|
} else { |
81
|
19
|
|
|
|
|
27
|
die qq[Not valid N-Triples data at line $lineno]; |
82
|
19
|
|
|
|
|
30
|
} |
83
|
19
|
50
|
|
|
|
49
|
} |
84
|
19
|
|
|
|
|
348
|
} |
85
|
|
|
|
|
|
|
|
86
|
0
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
1; |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=back |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=head1 BUGS |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
Please report any bugs or feature requests to through the GitHub web interface |
95
|
|
|
|
|
|
|
at L<https://github.com/kasei/perlrdf/issues>. |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=head1 AUTHOR |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
Gregory Todd Williams C<< <gwilliams@cpan.org> >> |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=head1 COPYRIGHT |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
Copyright (c) 2014--2022 Gregory Todd Williams. This |
104
|
|
|
|
|
|
|
program is free software; you can redistribute it and/or modify it under |
105
|
|
|
|
|
|
|
the same terms as Perl itself. |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=cut |