This file is indexed.

/usr/share/perl5/Attean/TermMap.pm is in libattean-perl 0.017-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
 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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
use v5.14;
use warnings;

=head1 NAME

Attean::TermMap - Mapping terms to new terms

=head1 VERSION

This document describes Attean::TermMap version 0.017

=head1 SYNOPSIS

  use v5.14;
  use Attean;
  my $m = Attean::TermMap->short_blank_map;
  my $new_blank = $m->map( Attean::Blank->new('abcdefg') );
  say $new_blank->ntriples_string; # _:a

=head1 DESCRIPTION

The Attean::TermMap class represents a one-way mapping process from and to
L<Attean::API::Term> objects. This mapping may rename the blank identifiers,
skolemize nodes, or map the nodes in some other, custom way.

It conforms to the L<Attean::API::Mapper> role.

=head1 ATTRIBUTES

=over 4

=item C<< mapper >>

A CODE reference that will map L<Attean::API::Term> objects to (possibly different)
term objects.

=back

=head1 CLASS METHODS

=over 4

=cut

package Attean::TermMap 0.017 {
	use Moo;
	use Types::Standard qw(CodeRef);
	use Attean::API::Binding;
	use Data::UUID;
	use namespace::clean;
	
	with 'Attean::Mapper';
	has 'mapper'	=> (is => 'ro', isa => CodeRef, default => sub { shift }, required => 1);
	
	around BUILDARGS => sub {
		my $orig 	= shift;
		my $class	= shift;
		if (scalar(@_) == 1) {
			return $class->$orig(mapper => shift);
		}
		return $class->$orig(@_);
	};

=item C<< canonicalization_map >>

Returns a new L<Attean::TermMap> that canonicalizes recognized typed
L<Attean::API::Literal> values.

=cut

	sub canonicalization_map {
		my $class	= shift;
		my %map;
		return $class->new(mapper => sub {
			my $term	= shift;
			return $term unless ($term->does('Attean::API::Literal'));
			
			if ($term->does('Attean::API::NumericLiteral')) {
				return $term->canonicalized_term;
			}
			
			return $term;
		});
	}

=item C<< uuid_blank_map >>

Returns a new L<Attean::TermMap> that renames blank nodes with UUID values.

=cut

	sub uuid_blank_map {
		my $class	= shift;
		my %map;
		return $class->new(mapper => sub {
			my $term	= shift;
			return $term unless ($term->does('Attean::API::Blank'));
			my $id		= $term->value;
			return $map{$id} if (defined($map{$id}));
			
			my $uuid	= Data::UUID->new->create_hex;
			my $new		= Attean::Blank->new( $uuid );
			$map{$id}	= $new;
			return $new;
		});
	}

=item C<< short_blank_map >>

Returns a new L<Attean::TermMap> that renames blank nodes with short
alphabetic names (e.g. _:a, _:b).

=cut

	sub short_blank_map {
		my $class	= shift;
		my %map;
		my $next	= 'a';
		return $class->new(mapper => sub {
			my $term	= shift;
			return $term unless ($term->does('Attean::API::Blank'));
			my $id		= $term->value;
			if (defined(my $t = $map{$id})) {
				return $t;
			} else {
				my $new		= Attean::Blank->new( $next++ );
				$map{$id}	= $new;
				return $new;
			}
		});
	}

=item C<< rewrite_map( \%map ) >>

Given C<< %map >> whose keys are term C<< as_string >> serializations, and
objects are L<Attean::API::Term> objects, returns a new term map object that
maps terms matching entries in C<< %map >>, and all other terms to themselves.

=cut

	sub rewrite_map {
		my $class	= shift;
		my $map		= shift;
		return $class->new(mapper => sub {
			my $term	= shift;
			return $map->{ $term->as_string } if (exists $map->{ $term->as_string });
			return $term;
		});
	}

=back

=head1 METHODS

=over 4

=item C<< map( $term ) >>

Returns the term that is mapped to by the supplied C<< $term >>.

=cut

	sub map {
		my $self	= shift;
		my $term	= shift;
		return $self->mapper->( $term );
	}

=item C<< binding_mapper >>

Returns a mapping function reference that maps L<Attean::API::Binding>
objects by mapping their constituent mapped L<Attean::API::Term> objects.

=cut

	sub binding_mapper {
		my $self	= shift;
		return sub {
			my $binding	= shift;
			return $binding->apply_map($self);
		}
	}
}

1;

__END__

=back

=head1 BUGS

Please report any bugs or feature requests to through the GitHub web interface
at L<https://github.com/kasei/attean/issues>.

=head1 SEE ALSO

L<http://www.perlrdf.org/>

=head1 AUTHOR

Gregory Todd Williams  C<< <gwilliams@cpan.org> >>

=head1 COPYRIGHT

Copyright (c) 2014--2016 Gregory Todd Williams.
This program is free software; you can redistribute it and/or modify it under
the same terms as Perl itself.

=cut