Public
Edited
Jul 27, 2024
2 stars
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
doc = await wtf.fetch(article, lang)
Insert cell
Insert cell
doc.json()
Insert cell
Insert cell
The article includes :

* ${doc.paragraphs().length} paragraphs
* ${doc.sentences().length} sentences
* ${doc.sections().length} sections
* ${doc.links().length} links
* ${doc.references().length} references
* ${doc.templates().length} templates
* ${doc.images().length} images
* ${doc.tables().length} tables
Insert cell
Insert cell
doc.templates().map((d) => d.wikitext())
Insert cell
doc.templates().map((d) => d.json())
Insert cell
Insert cell
doc.sentences().length
Insert cell
doc.sentences()[1].text()
Insert cell
doc.sentences()[1].wikitext()
Insert cell
doc.sentences()[1].html()
Insert cell
html`${doc.sentences()[1].html()} `
Insert cell
Insert cell
doc.sections()[1].title()
Insert cell
doc.sections().map((p) => p.title())
Insert cell
Insert cell
doc.paragraphs().length
Insert cell
html`${doc.paragraph(1).text()}`
Insert cell
html`${doc.paragraph(1).html()}`
Insert cell
doc
.paragraph(1)
.links()
.map((l) => l.page())
Insert cell
Insert cell
doc.categories()
Insert cell
printList(doc.categories())
Insert cell
doc.categories()
Insert cell
Insert cell
doc
.section(0)
.links()
.map((p) => p.page())
Insert cell
Insert cell
doc.infoboxes()
Insert cell
html`${doc.infoboxes().map((t) => t.html())}`
Insert cell
### References
Insert cell
doc.references().map((d) => d.links())
Insert cell
doc.references().map((d) => d.json())
Insert cell
Insert cell
doc.tables()
Insert cell
html`${doc.tables()[3].html()}`
Insert cell
doc.tables()[3].wikitext()
Insert cell
doc.tables()[3].json()
Insert cell
Insert cell
import { SearchForm } from "@floatingpurr/input-autocomplete"
Insert cell
import { printList } from "@spencermountain/wtf_wikipedia"
Insert cell
import { wikipedias } from "@pac02/user-level-gender-statistics-for-wikipedia"
Insert cell
lang = wikipedia.replace(".wikipedia.org", "")
Insert cell
get_default = () => {
const params = new URL(document.URL).searchParams;
const defaults = {
wikipedia: "en.wikipedia.org",
article: "Climate change"
};
if (params.has("wikipedia")) {
defaults.wikipedia = params.get("wikipedia");
}
if (params.has("article")) {
defaults.article = params.get("article");
}
return defaults;
}
Insert cell
wtf = {
let nlp = await require('wtf_wikipedia@latest')
let plugin = await require('wtf-plugin-html')
nlp.extend(plugin)
return nlp
}

Insert cell
wtf.version
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