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

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