| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
4
|
|
|
4
|
|
11738
|
use v5.14; |
|
|
4
|
|
|
|
|
16
|
|
|
2
|
4
|
|
|
4
|
|
22
|
use warnings; |
|
|
4
|
|
|
|
|
9
|
|
|
|
4
|
|
|
|
|
211
|
|
|
3
|
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
=head1 NAME |
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
AtteanX::Parser::SPARQLTSV - SPARQL Results TSV Parser |
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
=head1 VERSION |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
This document describes AtteanX::Parser::SPARQLTSV version 0.032 |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
use Attean; |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
... |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=over 4 |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=item C<< canonical_media_type >> |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=item C<< media_types >> |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=item C<< file_extensions >> |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=back |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=head1 METHODS |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=over 4 |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=cut |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
use utf8; |
|
39
|
4
|
|
|
4
|
|
21
|
use Moo; |
|
|
4
|
|
|
|
|
11
|
|
|
|
4
|
|
|
|
|
35
|
|
|
40
|
4
|
|
|
4
|
|
92
|
use Attean; |
|
|
4
|
|
|
|
|
8
|
|
|
|
4
|
|
|
|
|
30
|
|
|
41
|
4
|
|
|
4
|
|
1384
|
use Encode; |
|
|
4
|
|
|
|
|
11
|
|
|
|
4
|
|
|
|
|
30
|
|
|
42
|
4
|
|
|
4
|
|
19
|
use Encode qw(decode); |
|
|
4
|
|
|
|
|
10
|
|
|
|
4
|
|
|
|
|
363
|
|
|
43
|
4
|
|
|
4
|
|
25
|
use List::MoreUtils qw(zip); |
|
|
4
|
|
|
|
|
9
|
|
|
|
4
|
|
|
|
|
148
|
|
|
44
|
4
|
|
|
4
|
|
23
|
use namespace::clean; |
|
|
4
|
|
|
|
|
11
|
|
|
|
4
|
|
|
|
|
48
|
|
|
45
|
4
|
|
|
4
|
|
3620
|
|
|
|
4
|
|
|
|
|
45
|
|
|
|
4
|
|
|
|
|
40
|
|
|
46
|
|
|
|
|
|
|
|
|
47
|
1
|
|
|
1
|
1
|
1040
|
return [qw(text/tab-separated-values)]; |
|
48
|
|
|
|
|
|
|
} |
|
49
|
|
|
|
|
|
|
|
|
50
|
4
|
|
|
4
|
1
|
15
|
|
|
51
|
|
|
|
|
|
|
with 'Attean::API::ResultParser', 'Attean::API::PullParser', 'Attean::API::Parser'; |
|
52
|
|
|
|
|
|
|
|
|
53
|
4
|
|
|
4
|
1
|
17
|
=item C<< parse_iter_from_bytes( $data ) >> |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
Returns an iterator of L<Attean::API::Binding> objects that result from parsing |
|
56
|
|
|
|
|
|
|
the data read from the UTF-8 encoded byte string C<< $data >>. |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=cut |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
my $self = shift; |
|
61
|
|
|
|
|
|
|
my $data = shift; |
|
62
|
|
|
|
|
|
|
open(my $fh, '<:encoding(UTF-8)', \$data); |
|
63
|
|
|
|
|
|
|
return $self->parse_iter_from_io($fh); |
|
64
|
|
|
|
|
|
|
} |
|
65
|
1
|
|
|
1
|
1
|
3
|
|
|
66
|
1
|
|
|
|
|
3
|
=item C<< parse_iter_from_io( $fh ) >> |
|
67
|
1
|
|
|
1
|
|
9
|
|
|
|
1
|
|
|
1
|
|
3
|
|
|
|
1
|
|
|
|
|
10
|
|
|
|
1
|
|
|
|
|
939
|
|
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
4
|
|
|
|
1
|
|
|
|
|
53
|
|
|
68
|
1
|
|
|
|
|
1072
|
Returns an iterator of L<Attean::API::Binding> objects that result from parsing |
|
69
|
|
|
|
|
|
|
the data read from the L<IO::Handle> object C<< $fh >>. |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=cut |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
my $self = shift; |
|
74
|
|
|
|
|
|
|
my $fh = shift; |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
my $parser = Attean->get_parser('Turtle')->new(lazy_iris => $self->lazy_iris); |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
my $line = <$fh>; |
|
79
|
2
|
|
|
2
|
1
|
4
|
unless (defined($line)) { |
|
80
|
2
|
|
|
|
|
4
|
die "undefined header line in SPARQL/TSV parser"; |
|
81
|
|
|
|
|
|
|
} |
|
82
|
2
|
|
|
|
|
14
|
|
|
83
|
|
|
|
|
|
|
chomp($line); |
|
84
|
2
|
|
|
|
|
143
|
my @vars; |
|
85
|
2
|
50
|
|
|
|
17
|
foreach my $v (split("\t", $line)) { |
|
86
|
0
|
|
|
|
|
0
|
unless (substr($v, 0, 1) eq '?') { |
|
87
|
|
|
|
|
|
|
Carp::confess "Bad variable syntax in SPARQL TSV data: '$v'"; |
|
88
|
|
|
|
|
|
|
} |
|
89
|
2
|
|
|
|
|
6
|
push(@vars, substr($v, 1)); |
|
90
|
2
|
|
|
|
|
5
|
} |
|
91
|
2
|
|
|
|
|
12
|
|
|
92
|
8
|
50
|
|
|
|
22
|
my $gen = sub { |
|
93
|
0
|
|
|
|
|
0
|
my $line = <$fh>; |
|
94
|
|
|
|
|
|
|
return unless defined($line); |
|
95
|
8
|
|
|
|
|
19
|
chomp($line); |
|
96
|
|
|
|
|
|
|
my @strings = split("\t", $line); |
|
97
|
|
|
|
|
|
|
my %binding; |
|
98
|
|
|
|
|
|
|
foreach my $i (0 .. $#vars) { |
|
99
|
5
|
|
|
5
|
|
22
|
my $string = $strings[$i]; |
|
100
|
5
|
100
|
|
|
|
27
|
if (length($string)) { |
|
101
|
3
|
|
|
|
|
9
|
my $var = $vars[$i]; |
|
102
|
3
|
|
|
|
|
32
|
my $bytes = encode('UTF-8', $string, Encode::FB_CROAK); |
|
103
|
3
|
|
|
|
|
8
|
my $term = $parser->parse_term_from_bytes($bytes); |
|
104
|
3
|
|
|
|
|
11
|
if ($term) { |
|
105
|
10
|
|
|
|
|
19
|
$binding{ $var } = $term; |
|
106
|
10
|
100
|
|
|
|
48
|
} |
|
107
|
9
|
|
|
|
|
17
|
} |
|
108
|
9
|
|
|
|
|
56
|
} |
|
109
|
9
|
|
|
|
|
349
|
return Attean::Result->new( bindings => \%binding ); |
|
110
|
9
|
50
|
|
|
|
26
|
}; |
|
111
|
9
|
|
|
|
|
30
|
return Attean::CodeIterator->new( |
|
112
|
|
|
|
|
|
|
generator => $gen, |
|
113
|
|
|
|
|
|
|
item_type => $self->handled_type->role, |
|
114
|
|
|
|
|
|
|
variables => \@vars, |
|
115
|
3
|
|
|
|
|
54
|
); |
|
116
|
2
|
|
|
|
|
14
|
} |
|
117
|
2
|
|
|
|
|
13
|
|
|
118
|
|
|
|
|
|
|
} |
|
119
|
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
1; |
|
121
|
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=back |
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=head1 BUGS |
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
Please report any bugs or feature requests to through the GitHub web interface |
|
128
|
|
|
|
|
|
|
at L<https://github.com/kasei/perlrdf/issues>. |
|
129
|
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=head1 AUTHOR |
|
131
|
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
Gregory Todd Williams C<< <gwilliams@cpan.org> >> |
|
133
|
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=head1 COPYRIGHT |
|
135
|
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
Copyright (c) 2014--2022 Gregory Todd Williams. This |
|
137
|
|
|
|
|
|
|
program is free software; you can redistribute it and/or modify it under |
|
138
|
|
|
|
|
|
|
the same terms as Perl itself. |
|
139
|
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=cut |