Closed VladimirAlexiev closed 5 years ago
@VladimirAlexiev – There are a few things wrong here. The primary issue is that you are only passing one line of STDIN with <>
to the SPARQL parser. You need to either join all the input lines into a string, or change the input record separator variable $/
. A few extra use
statements, and a default graph to use for Attean::SimpleQueryEvaluator
gives me a script that runs as expected:
use Attean;
use Attean::RDF qw(iri);
use Attean::SimpleQueryEvaluator;
my $store = Attean->get_store('Memory')->new();
my $model = Attean::TripleModel->new( store => $store );
local($/);
my $algebra = Attean->get_parser('SPARQL')->parse(<>); ###
my $e = Attean::SimpleQueryEvaluator->new( model => $model, default_graph => iri('') );
my $iter = $e->evaluate( $algebra, Attean::IRI->new('http://example.org/') );
while (my $r = $iter->next) {
say $r->as_string;
}
output:
{WD="Q156578", co=<http://www.wikidata.org/entity/Q156578>}
{WD="Q156578", co=<http://www.wikidata.org/entity/Q156578>}
thanks!!
The following query as per https://metacpan.org/pod/Attean::SimpleQueryEvaluator
gets
Expected query type but got (undef) at query.pl line 8.
The query on stdin is