NAME

WQS::SPARQL::Query::Count - Simple SPARQL count query.

SYNOPSIS

use WQS::SPARQL::Query::Count;

my $obj = WQS::SPARQL::Query::Count->new;
my $sparql = $obj->count_item($property, $item);
my $sparql = $obj->count_value($property, $value);

METHODS

new

my $obj = WQS::SPARQL::Query::Count->new;

Constructor.

Returns instance of class.

count_item

my $sparql = $obj->count_item($property, $item);

Construct SPARQL command and return it.

Returns string.

count_value

my $sparql = $obj->count_value($property, $value);

Construct SPARQL command and return it.

Returns string.

ERRORS

new():
        From Class::Utils::set_params():
                Unknown parameter '%s'.

count_item():
        Bad item '%s'.
        Bad property '%s'.

count_value():
        Bad property '%s'.

EXAMPLE1

use strict;
use warnings;

use WQS::SPARQL::Query::Count;

my $obj = WQS::SPARQL::Query::Count->new;

my $property = 'P957';
my $item = 'Q62098524';
my $sparql = $obj->count_item($property, $item);

print "Property: $property\n";
print "Item: $item\n";
print "SPARQL:\n";
print $sparql;

# Output:
# Property: P957
# ISBN: 80-239-7791-1
# SPARQL:
# SELECT (COUNT(?item) as ?count) WHERE {
#   ?item wdt:P957 wd:Q62098524
# }

EXAMPLE2

use strict;
use warnings;

use WQS::SPARQL::Query::Count;

my $obj = WQS::SPARQL::Query::Count->new;

my $property = 'P957';
my $isbn = '80-239-7791-1';
my $sparql = $obj->count_value($property, $isbn);

print "Property: $property\n";
print "ISBN: $isbn\n";
print "SPARQL:\n";
print $sparql;

# Output:
# Property: P957
# ISBN: 80-239-7791-1
# SPARQL:
# SELECT (COUNT(?item) as ?count) WHERE {
#   ?item wdt:P957 '80-239-7791-1'
# }

DEPENDENCIES

Class::Utils, Error::Pure.

SEE ALSO

WQS::SPARQL::Query

Useful Wikdata Query Service SPARQL queries.

WQS::SPARQL::Query::Select

Simple SPARQL select query.

REPOSITORY

https://github.com/michal-josef-spacek/WQS-SPARQL-Query

AUTHOR

Michal Josef Špaček mailto:skim@cpan.org

http://skim.cz

LICENSE AND COPYRIGHT

© 2020-2023 Michal Josef Špaček

BSD 2-Clause License

VERSION

0.01