Public
Edited
Jan 8, 2024
1 fork
2 stars
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
import { get_pagescreated } from "@pac02/look-at-your-list-of-created-articles-with-the-xtools-page-ap"
Insert cell
data = {
let result = [];
let offset = "";
while (offset !== undefined) {
let data = await get_pagescreated({
username: username,
wikipedia: wikipedia,
offset: offset
});
offset = data.continue;
result = result.concat(aq.from(Object.values(data.pages[0])));
yield result;
}
return result;
}
Insert cell
df = data[0].union(data)
Insert cell
page_title_split = df.array("page_title").reduce((all,one,i) => {
const ch = Math.floor(i/50);
all[ch] = [].concat((all[ch]||[]),one);
return all
}, [])
Insert cell
alldata = await Promise.all(page_title_split.map(d => fetch(wdk.getEntitiesFromSitelinks({titles: d, sites: get_shortwikipedianame(wikipedia)}))
.then(d => d.json())
.then(wdk.parse.wb.entities)
.then(d => Object.values(d).map(q => get_claim(q, claim, get_shortwikipedianame(wikipedia))))
.then(d => aq.from([ { article: "", qvalue: ""}])
.union(d.map(q => aq.from(q)))
.filter(aq.escape(p => p.article != "")))
)
)
Insert cell
df_alldata = aq.from([{article: "", qvalue: ""}])
.union(alldata.map(d => aq.from(d)))
.filter(aq.escape(d => d.article != ""))
Insert cell
df_alldata2 = df_alldata
.spread({ key: d => op.split(d.qvalue, ',') }, { as: ['latitude', 'longitude'] })
.select(["article", "latitude", "longitude"])
Insert cell
dots = bertin.table2geo(df_alldata2.objects(), "latitude", "longitude")
Insert cell
Insert cell
bertin = require("bertin@0.3.1/dist/index.min.js")
Insert cell
viz = require("geoviz@0.4.4")
Insert cell
d3 = require("d3@7", "d3-geo-projection@4")
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
import { wikipedias } from "@pac02/user-level-gender-statistics-for-wikipedia"
Insert cell
Insert cell
get_default = () => {
const params = new URL(document.URL).searchParams;
const defaults = {
username: "PAC2",
wikipedia: "fr.wikipedia.org"
};
if (params.has("username")) {
defaults.username = params.get("username");
}
if (params.has("wikipedia")) {
defaults.wikipedia = params.get("wikipedia");
}
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