Public
Edited
May 26, 2022
4 stars
Insert cell
Insert cell
Insert cell
{
var doc = nlp("Björk, the singer-songwriter, plays at seven...")
doc.normalize()
return doc.out('text')
}
Insert cell
Insert cell
{
// default params:
return {
// remove hyphens, newlines, and force one space between words
whitespace: true,
// keep only first-word, and 'entity' titlecasing
case: true,
// remove commas, semicolons - but keep sentence-ending punctuation
punctuation: true,
// visually romanize/anglicize 'Björk' into 'Bjork'.
unicode: true,
// turn "isn't" to "is not"
contractions: true,
//remove periods from acronyms, like 'F.B.I.'
acronyms:true,

//---these ones don't run unless you want them to---
//remove words inside brackets (like these)
parentheses: false,
// turn "Google's tax return" to "Google tax return"
possessives: false,
// turn "batmobiles" into "batmobile"
plurals: false,
// turn all verbs into Infinitive form - "I walked" → "I walk"
verbs: false,
//turn 'Vice Admiral John Smith' to 'John Smith'
honorifics: false,
}
}
Insert cell
Insert cell
Insert cell
nlp('so... you like DONUTS? have all the donuts in the WORLD!!!').normalize({nouns:true}).out()
Insert cell
nlp('the so-called group of seven').normalize({numbers:true}).out()
Insert cell
Insert cell
Insert cell
{
//get the wikipedia plaintext with wtf_wikipedia
let text = await wtf.fetch(article).then(doc=>doc.plaintext())
//get all the nouns from the text
let nouns = nlp(text).normalize({plurals:true, parentheses:true, possessives:true, honorifics:true}).nouns()
//sort them by frequency
return JSON.stringify(nouns.out('topk'), null, 2)
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
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