App-wdq

 view release on metacpan or  search on metacpan

script/wdq  view on Meta::CPAN


=head1 SYNOPSIS

Access L<Wikidata Query Service|https://query.wikidata.org/> via command line
to perform SPARQL queries (C<query> mode), lookup entities (C<lookup>), or
search items and properties (C<search> or C<psearch>):

  wdq -g en solar system        # search 'solar system' in English
  wdq psearch -g es parte       # search property 'parte' in Spanish
  wdq P361 Q544                 # lookup properties and items
  wdq '?c wdt:P361 wd:Q544'     # query parts of the solar system

See the manual for details or get help via C<wdq help>:

  wdq help options              # list and explain command line options
  wdq help modes                # list and explain request modes
  wdq help output               # explain output control
  wdq help formats              # list and explain output formats
  wdq help ontology             # show Wikidata ontology in a nutshell
  wdq help prefixes             # list RDF prefixes allowed in queries
  wdq help version              # show version of wdq

=head1 DESCRIPTION

The command line script C<wdq>, included in CPAN module L<App::wdq>, provides a
tool to access L<Wikidata Query Service|https://query.wikidata.org/>. It
supports formulation and execution of L<SPARQL SELECT
queries|http://www.w3.org/TR/sparql11-query/#select> to extract selected
information from Wikidata or other Wikibase instances.

=head1 INSTALLATION

Perl should already installed at most operating systems. Otherwise
L<get Perl!|https://www.perl.org/get.html>

=head2 FROM CPAN

Install sources from CPAN including all dependencies:

  cpanm App::wdq

First L<install cpanm|https://github.com/miyagawa/cpanminus/#installation> if
missing. If installation of C<App::wdq> fails try cpanm option C<--notest> or
install dependencies as packages as described below.

=head2 PREBUILD PACKAGES

Install dependencies as prebuild packages for your operating system:

  # Debian based systems e.g. Ubuntu (>= 14.04)
  sudo apt-get install libhttp-tiny-perl librdf-query-perl

  # Windows/ActiveState
  ppm install HTTP-Tiny
  ppm install RDF-Query

Then install C<wdq> from CPAN as described above or copy the script to some
place in your C<$PATH>:

  wget https://github.com/nichtich/wdq/raw/master/script/wdq
  chmod +x wdq

The latter method will not install this documentation.


=head1 MODES

Request mode C<query> (default), C<lookup>, C<serch>, or C<psearch> can
explicitly be set via first argument or it's guessed from arguments.

=head2 query

Read SPARQL query from STDIN, option C<--query|-q>, or argument. Namespace
definitions and C<SELECT> clause are added if missing.

  wdq '?c wdt:P361 wd:Q544'
  wdq '{ ?c wdt:P361 wd:Q544 }'                 # equivalent
  wdq 'SELECT * WHERE { ?c wdt:P361 wd:Q544 }'  # equivalent
  wdq < queryfile

=head2 lookup

Read Wikidata entity ids, URLs, or Wikimedia project URLs from STDIN or
arguments. Result fields are C<label>, C<description>, and C<id>:

  wdq Q1
  wdq lookup Q1                                 # equivalent
  echo Q1 | wdq lookup                          # equivalent
  wdq http://de.wikipedia.org/wiki/Universum    # same result

=encoding utf8

=head2 search / psearch

Search for items or properties. Result fields are C<label>, C<id>,
C<description>, and possibly matched C<alias>. Search and result language is
read from environment or option C<--language>/C<-g>:

  wdq search -g sv Pippi LÃ¥ngstrump

Default output format in search mode is C<text>.

=head1 OPTIONS

=over

=item --query|-q QUERY

Query or query file (C<-> for STDIN as default)

=item --format|-f FORMAT|TEMPLATE

Output format or string template. Call C<wdq help formats> for details.

=item --export EXPORTER

Use a L<Catmandu> exporter as output format.

=item --no-header|-H

Exclude header in CSV output or other exporter.



( run in 1.776 second using v1.01-cache-2.11-cpan-cdf2f3d4e48 )