Public
Edited
Jan 3, 2024
2 forks
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
import { get_label } from "@pac02/user-level-gender-statistics-for-wikipedia"
Insert cell
label1 = get_label(item1, lang)
Insert cell
label2 = get_label(item2, lang)
Insert cell
query1 = `ASK WHERE { wd:${item1} (wdt:P279*) wd:${item2} . }
`
Insert cell
query2 = `ASK WHERE { wd:${item2} (wdt:P279*) wd:${item1} . }
`
Insert cell
output1 = fetch(
`https://query.wikidata.org/sparql?query=${encodeURIComponent(query1)}`,
{ headers: { accept: "application/sparql-results+json" } }
)
.then((response) => response.json())
.then((d) => d.boolean)
Insert cell
output2 = fetch(
`https://query.wikidata.org/sparql?query=${encodeURIComponent(query2)}`,
{ headers: { accept: "application/sparql-results+json" } }
)
.then((response) => response.json())
.then((d) => d.boolean)
Insert cell
defaults = {
const params = new URL(document.URL).searchParams;
const defaults = {
item1: "Q4830453",
item2: "Q6881511",
lang: "en"
};
if (params.has("item1")) {
defaults.item1 = params.get("item1");
}
if (params.has("item2")) {
defaults.item2 = params.get("item2");
}
if (params.has("lang")) {
defaults.item2 = params.get("lang");
}
return defaults;
}
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more