Public
Edited
Jan 23, 2024
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
badge_labels = get_labels(["Q17437796", "Q17437798"], lang).then((d) =>
d.objects()
)
Insert cell
badge_labels_map = new Map(
badge_labels.map(({ label, qid }) => [label + " (" + qid + ")", qid])
)
Insert cell
claim_labels = get_labels(
[
"P17",
"P21",
"P27",
"P31",
"P106",
"P101",
"P103",
"P1412",
"P6886",
"P140",
"P91",
"P172",
"P69",
"P166",
"P1387",
"P1142",
"P136"
],
lang
).then((d) => d.objects())
Insert cell
labels_map = new Map(
claim_labels.map(({ label, qid }) => [label + " (" + qid + ")", qid])
)
Insert cell
import { get_labels } from "@pac02/what-kind-of-articles-have-you-created"
Insert cell
Insert cell
query = `SELECT ?value ?valueLabel (COUNT(*) AS ?count)
WHERE {
?url schema:isPartOf <https://${wikipedia}/>;
wikibase:badge wd:${badge};
schema:about ?item;
schema:name ?name.
?item wdt:${property} ?value.
?value rdfs:label ?valueLabel.
FILTER(LANG(?valueLabel) = "${lang}" )
}
GROUP BY ?value ?valueLabel
ORDER BY DESC(?count)
`
Insert cell
data = fetch(
`https://query.wikidata.org/sparql?query=${encodeURIComponent(query)}`,
{ headers: { accept: "application/sparql-results+json" } }
).then((response) => response.json())
Insert cell
array = data.results.bindings.map((d) => ({
value: d.value.value,
valueLabel: d.valueLabel.value,
count: parseInt(d.count.value)
}))
Insert cell
df = aq.from(array)
Insert cell
Insert cell
Insert cell
import { wikipedias } from "@pac02/user-level-gender-statistics-for-wikipedia"
Insert cell
import { BubbleChart } from "@d3/bubble-chart"
Insert cell
Insert cell
get_default = () => {
const params = new URL(document.URL).searchParams;
const defaults = {
badge: "Q17437796",
wikipedia: "fr.wikipedia.org",
lang: "en",
property: "P31"
};
if (params.has("badge")) {
defaults.badge = params.get("badge");
}
if (params.has("wikipedia")) {
defaults.wikipedia = params.get("wikipedia");
}
if (params.has("lang")) {
defaults.lang = params.get("lang");
}

if (params.has("property")) {
defaults.lang = params.get("property");
}
return defaults;
}
Insert cell
Insert cell

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more