get_people = ({
occupation = "Q33999",
citizenship = "Q142",
birthyear = 1970
}) => {
const query = `PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX schema: <http://schema.org/>
PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
SELECT DISTINCT ?item ?itemLabel ?year ?gender ?genderLabel ?father ?mother ?fatherLabel ?motherLabel WHERE {
?item wdt:P31 wd:Q5;
wdt:P21 ?gender;
wdt:P106/wdt:P279* wd:${occupation};
wdt:P27 wd:${citizenship};
wdt:P569 ?birthdate;
rdfs:label ?itemLabel
FILTER(lang(?itemLabel) = "fr") .
?sitelink schema:about ?item;
schema:isPartOf <https://fr.wikipedia.org/>.
?gender rdfs:label ?genderLabel FILTER(lang(?genderLabel) = "fr") .
FILTER(YEAR( ?birthdate ) >= ${birthyear} )
BIND(YEAR(?birthdate) AS ?year)
OPTIONAL {
?item wdt:P25 ?mother.
?motherlink schema:about ?mother;
schema:isPartOf <https://fr.wikipedia.org/>.
?mother rdfs:label ?motherLabel.
FILTER(lang(?motherLabel) = "fr")
}
OPTIONAL {
?item wdt:P22 ?father.
?fatherlink schema:about ?father;
schema:isPartOf <https://fr.wikipedia.org/>.
?father rdfs:label ?fatherLabel.
FILTER(lang(?fatherLabel) = "fr")
}
}`;
return fetch(
`https://qlever.cs.uni-freiburg.de/api/wikidata?query=${encodeURIComponent(
query
)}`,
{ headers: { accept: "application/sparql-results+json" } }
)
.then((response) => response.json())
.then((res) =>
aq
.from(
res.results.bindings.map((d) => ({
item: d.item.value,
itemLabel: d.itemLabel.value,
year: d.year.value,
gender: d.gender?.value,
genderLabel: d.genderLabel?.value,
father: d.father?.value,
fatherLabel: d.fatherLabel?.value,
mother: d.mother?.value,
motherLabel: d.motherLabel?.value
}))
)
.derive({
number_of_parents: (d) =>
1 * (d.father !== undefined) + 1 * (d.mother !== undefined)
})
);
}