% SWI Prolog querying of Wikidata

% This is slightly expanded code of Figure 16.6 and Examples 16.7 in Section 16.1.3 of
% Poole and Mackworth, Artificial Intelligence: foundations of
% computational agents, 3rd Edition, Cambridge, 2023

% Copyright (c) 2023 David Poole and Alan Mackworth. This program is released under
% CC Attribution-NonCommercial-ShareAlike  License http://creativecommons.org/licenses/by-nc-sa/4.0/

:- use_module(library(semweb/rdf_http_plugin)).
:- use_module(library(semweb/rdf_db)).

% Load the appropriate files:
%:- rdf_load('http://www.wikidata.org/wiki/Special:EntityData/Q262802.rdf'). % Christine Sinclair
%:- rdf_load('http://www.wikidata.org/wiki/Special:EntityData/Q499946.rdf'). % Canada women's national soccer team
%:- rdf_load('http://www.wikidata.org/wiki/Special:EntityData/P54.rdf').    % member of sports team
%:- rdf_load('http://www.wikidata.org/wiki/Special:EntityData/P27.rdf').    % country of citizenship

% Somoe other files to try:
%:- rdf_load('http://www.wikidata.org/wiki/Special:EntityData/Q11571.rdf'). % Cristiano Ronaldo
%:- rdf_load('http://www.wikidata.org/wiki/Special:EntityData/Q1255625.rdf'). % Samuel Eto'o
%:- rdf_load('http://www.wikidata.org/wiki/Special:EntityData/Q34086.rdf').   % Justin Bieber
%:- rdf_load('http://www.wikidata.org/wiki/Special:EntityData/Q17198340.rdf').   % Shawn Mendez
%:- rdf_load('http://www.wikidata.org/wiki/Special:EntityData/P25.rdf').   % mother property


% Some example Queries
%?- rdf(S,P,O).
%?- rdf('http://www.wikidata.org/entity/Q262802','http://schema.org/name',N).
%?- rdf('http://www.wikidata.org/entity/Q262802','http://schema.org/name',literal(lang(ko,N))).  % Korean
%?- rdf('http://www.wikidata.org/entity/Q262802', 'http://www.wikidata.org/prop/direct/P27',C),rdf(C,'http://schema.org/name',N).  % CS's citizenship
%?- rdf('http://www.wikidata.org/entity/P27','http://schema.org/name',N).
%?- rdf('http://www.wikidata.org/entity/Q262802', 'http://www.wikidata.org/prop/P54',M).
%?- rdf('http://www.wikidata.org/entity/Q262802', 'http://www.wikidata.org/prop/P54',M),rdf(M, 'http://www.wikidata.org/prop/statement/P54',E), rdf(E,'http://schema.org/name',literal(lang(en,N))).
% What other properties are true of the M in the previous query?
% What are the names of the countries of the teams that Christine Sinclair has played for?



