Attean

 view release on metacpan or  search on metacpan

Changes  view on Meta::CPAN

 - (Update) Added ground_blanks attribute to Attean::SimpleQueryEvaluator.
 - (Update) Fixed bug in AtteanX::API::Lexer that caused infinite recursion
   when finding EOF in the middle of an escape sequence.
 - (Update) Updates to use namespace types, available in Types::Attean
   (#129, #137 from @kjetilk).

0.024  2019-04-30

 - (Addition) Add a simple factory for temporary models (#132 from
   @kjetilk).
 - (Update) Document how to check whether a term looks like the head of an
   rdf:List (#133 from @kjetilk).
 - (Update) Removed the deprecated parse_term_from_string method from
   NTuples and Turtle parsers (#131).

0.022  2019-03-21

 - (Addition) Add Attean::API::TermOrVariable->is_bound method (#129 from
   @kjetilk).
 - (Addition) Added statement matching functionality for iterators.

inc/Module/Install.pm  view on Meta::CPAN

	my $who  = $self->_caller;
	my $cwd  = Cwd::getcwd();
	my $sym  = "${who}::AUTOLOAD";
	$sym->{$cwd} = sub {
		my $pwd = Cwd::getcwd();
		if ( my $code = $sym->{$pwd} ) {
			# Delegate back to parent dirs
			goto &$code unless $cwd eq $pwd;
		}
		unless ($$sym =~ s/([^:]+)$//) {
			# XXX: it looks like we can't retrieve the missing function
			# via $$sym (usually $main::AUTOLOAD) in this case.
			# I'm still wondering if we should slurp Makefile.PL to
			# get some context or not ...
			my ($package, $file, $line) = caller;
			die <<"EOT";
Unknown function is found at $file line $line.
Execution of $file aborted due to runtime errors.

If you're a contributor to a project, you may need to install
some Module::Install extensions from CPAN (or other repository).

lib/Attean/API/Term.pm  view on Meta::CPAN

	}
}

package Attean::API::CanonicalizingLiteral 0.035 {
	use Moo::Role;
	requires 'canonicalized_term';
	requires 'canonicalized_term_strict';
}

package Attean::API::BooleanLiteral 0.035 {
	use Scalar::Util qw(blessed looks_like_number);

	use Moo::Role;

	sub canonicalized_term_strict {
		my $self	= shift;
		my $value	= $self->value;
		if ($value =~ m/^(true|false|0|1)$/) {
			return ($value eq 'true' or $value eq '1')
				? Attean::Literal->true
				: Attean::Literal->false;

lib/Attean/API/Term.pm  view on Meta::CPAN

				? Attean::Literal->true
				: Attean::Literal->false;
		} else {
			return $self;
		}
	}
	with 'Attean::API::Literal', 'Attean::API::CanonicalizingLiteral';
}

package Attean::API::NumericLiteral 0.035 {
	use Scalar::Util qw(blessed looks_like_number);

	use Moo::Role;

	sub equals {
		my ($a, $b)	= @_;
		return 0 unless ($b->does('Attean::API::NumericLiteral'));
		return $a->numeric_value == $b->numeric_value;
	}

	sub compare {

lib/Attean/API/Term.pm  view on Meta::CPAN

	}
	
	sub ebv {
		my $self	= shift;
		return ($self->numeric_value != 0);
	}

	sub numeric_value {
		my $self	= shift;
		my $v		= $self->value;
		return (looks_like_number($v)) ? eval $v : undef;
	}

	{
		my %type_hierarchy	= (
			'integer'				=> 'decimal',
			'nonPositiveInteger'	=> 'integer',
			'negativeInteger'		=> 'nonPositiveInteger',
			'long'					=> 'integer',
			'int'					=> 'long',
			'short'					=> 'int',

lib/Attean/Plan.pm  view on Meta::CPAN

package Attean::Plan::Extend 0.035 {
	use Moo;
	use Encode;
	use UUID::Tiny ':std';
	use URI::Escape;
	use Data::Dumper;
	use I18N::LangTags;
	use POSIX qw(ceil floor);
	use Digest::SHA;
	use Digest::MD5 qw(md5_hex);
	use Scalar::Util qw(blessed looks_like_number);
	use List::Util qw(uniq all);
	use Types::Standard qw(ConsumerOf ArrayRef InstanceOf HashRef);
	use namespace::clean;

	with 'MooX::Log::Any';
	with 'Attean::API::BindingSubstitutionPlan', 'Attean::API::UnaryQueryTree';
	has 'expressions' => (is => 'ro', isa => HashRef[ConsumerOf['Attean::API::Expression']], required => 1);
	has 'active_graphs' => (is => 'ro', isa => ArrayRef[ConsumerOf['Attean::API::IRI']], required => 1);
	
	sub plan_as_string {

lib/Attean/Plan.pm  view on Meta::CPAN

						my ($v) = "$value";
						$v		=~ s/[.].*$//;
						$value	= int($v);
					}
					$num	= $value;
				} elsif ($datatype eq 'http://www.w3.org/2001/XMLSchema#decimal') {
					if ($term->datatype->value eq 'http://www.w3.org/2001/XMLSchema#boolean') {
						$value	= ($value eq 'true') ? '1' : '0';
					} elsif ($term->does('Attean::API::NumericLiteral')) {
						$value	= $term->numeric_value;
					} elsif (looks_like_number($value)) {
						if ($value =~ /[eE]/) {	# double
							die "cannot cast to xsd:decimal as precision would be lost";
						}
						$value = +$value;
					}
					$num	= "$value";
					$num	=~ s/[.]0+$/.0/;
					$num	=~ s/[.](\d+)0*$/.$1/;
				} elsif ($datatype =~ m<^http://www.w3.org/2001/XMLSchema#(float|double)$>) {
					my $typename	= $1;
					if ($term->datatype->value eq 'http://www.w3.org/2001/XMLSchema#boolean') {
						$value	= ($value eq 'true') ? '1.0' : '0.0';
					} elsif ($term->does('Attean::API::NumericLiteral')) {
						# no-op
					} elsif (looks_like_number($value)) {
						$value	= +$value;
					} else {
						die "cannot cast unrecognized value '$value' to xsd:$typename";
					}
					$num	= sprintf("%e", $value);
				}
				my $c	= Attean::Literal->new(value => $num, datatype => $expr->datatype);
				if (my $term = $c->canonicalized_term_strict()) {
					return $term;
				} else {

lib/Attean/Plan.pm  view on Meta::CPAN

package Attean::Plan::Unfold 0.032 {
	use Moo;
	use Encode;
	use UUID::Tiny ':std';
	use URI::Escape;
	use Data::Dumper;
	use I18N::LangTags;
	use POSIX qw(ceil floor);
	use Digest::SHA;
	use Digest::MD5 qw(md5_hex);
	use Scalar::Util qw(blessed looks_like_number);
	use List::Util qw(uniq all);
	use Types::Standard qw(ConsumerOf ArrayRef InstanceOf HashRef);
	use namespace::clean;

	with 'MooX::Log::Any';
	with 'Attean::API::BindingSubstitutionPlan', 'Attean::API::UnaryQueryTree';
	
	has 'variables' => (is => 'ro', isa => ArrayRef[ConsumerOf['Attean::API::Variable']], required => 1);
	has 'expression' => (is => 'ro', isa => ConsumerOf['Attean::API::Expression'], required => 1);
	has 'active_graphs' => (is => 'ro', isa => ArrayRef[ConsumerOf['Attean::API::IRI']], required => 1);

lib/AtteanX/Functions/CompositeLists.pm  view on Meta::CPAN

			"${CDT_BASE}listAgg" => {
				start		=> \&listCreate_agg_start,
				process		=> \&listCreate_agg_process,
				finalize	=> \&listCreate_agg_finalize,
			},
		);
	}
}

package AtteanX::Functions::CompositeLists::ListLiteral {
	use Scalar::Util qw(blessed looks_like_number);

	use Moo::Role;
	use List::Util qw(min);

	sub equals {
		my $lhs	= shift;
		my $rhs	= shift;
# 		warn "LIST EQUALS?";
# 		warn "- " . $lhs->as_string . "\n";
# 		warn "- " . $rhs->as_string . "\n";

lib/AtteanX/Functions/CompositeMaps.pm  view on Meta::CPAN

			"${CDT_BASE}mapAgg" => {
				start		=> \&mapCreate_agg_start,
				process		=> \&mapCreate_agg_process,
				finalize	=> \&mapCreate_agg_finalize,
			},
		);
	}
}

package AtteanX::Functions::CompositeMaps::MapLiteral {
	use Scalar::Util qw(blessed looks_like_number);
	use List::Util qw(min);

	use Moo::Role;

	sub equals {
		my $lhs	= shift;
		my $rhs	= shift;
# 		warn "MAP EQUALS?";
# 		warn "- " . $lhs->as_string . "\n";
# 		warn "- " . $rhs->as_string . "\n";

lib/AtteanX/Parser/SPARQL.pm  view on Meta::CPAN

no warnings 'redefine';
use Carp qw(cluck confess croak);

use Attean;
use Data::Dumper;
use URI::NamespaceMap;
use List::Util qw(mesh);
use AtteanX::Parser::SPARQLLex;
use AtteanX::SPARQL::Constants;
use Types::Standard qw(ConsumerOf InstanceOf HashRef ArrayRef Bool Str Int);
use Scalar::Util qw(blessed looks_like_number reftype refaddr);

######################################################################

use Moo;

has 'lexer' 		=> (is => 'rw', isa => InstanceOf['AtteanX::Parser::SPARQLLex::Iterator']);
has 'args'			=> (is => 'ro', isa => HashRef);
has 'build'			=> (is => 'rw', isa => HashRef);
has 'update'		=> (is => 'rw', isa => Bool);
has 'baseURI'		=> (is => 'rw');

meta/changes.ttl  view on Meta::CPAN



my:v_0-023
	a					:Version ;
	dc:issued			"2019-04-30"^^xsd:date ;
	:revision			"0.024" ;
	dcterms:replaces	my:v_0-022 ;
	dcs:changeset [
		dcs:item
			[ a dcs:Addition ; rdfs:label "Add a simple factory for temporary models (#132 from @kjetilk)." ],
			[ a dcs:Update ; rdfs:label "Document how to check whether a term looks like the head of an rdf:List (#133 from @kjetilk)." ],
			[ a dcs:Update ; rdfs:label "Removed the deprecated parse_term_from_string method from NTuples and Turtle parsers (#131)." ]
	]
	.


my:v_0-022
	a					:Version ;
	dc:issued			"2019-03-21"^^xsd:date ;
	:revision			"0.022" ;
	dcterms:replaces	my:v_0-021 ;



( run in 0.480 second using v1.01-cache-2.11-cpan-64827b87656 )