Public
Edited
Nov 3, 2022
1 fork
1 star
Insert cell
Insert cell
Insert cell
nlp(`out with the old, in with the nucleus.`).text()
Insert cell
Insert cell
Insert cell
{
let doc = nlp('The children are right to laugh at you, Rälf. ')
let res = {
text: doc.text(),
normal: doc.text('normal'),
clean: doc.text('clean'),
reduced: doc.text('reduced'),
root: doc.text('root')
}
return JSON.stringify(res, null, 2)
}
Insert cell
nlp(`Wayne's World, party-time, excellent!! 🎸`).text()
Insert cell
nlp(`Wayne's World, party-time, excellent!! 🎸`).text('normal')
Insert cell
nlp(`Wayne's World, party-time, excellent!! 🎸`).text('clean')
Insert cell
nlp(`Wayne's World, party-time, excellent!! 🎸`).text('reduced')
Insert cell
Insert cell
nlp(`Wayne's World, party-time, excellent!! 🎸`).compute('root').text('root')
Insert cell
Insert cell
{
const defaults = {
trim: false, // remove leading/trailing whitespace
keepSpace: false, // tabs, double-spaces
unicode: false, // ü → u
case: false, // co-erce everything to lowercase
titlecase: false, // titlecase proper-nouns, acronyms, sentence-starts
keepPunct: false, // '?!' → ?
acronyms: false, // F.B.I. → FBI
abbreviations: false, // Mrs. → Mrs
implicit: false, // didn't → 'did not'
}
}
Insert cell
{
let doc = nlp(`Dr. John Smith-McDonald...? `)
let opts = {
keepPunct: false,
keepSpace: false,
case: false,
}
return doc.text(opts)
}
Insert cell
Insert cell
{
let doc = nlp(`wayne's World, party-time, excellent!! 🎸`)
//just the one's you'd like to use:
doc.normalize({case:true, whitespace:true, possessives:false})
// keep acronyms as uppercase
doc.acronyms().toUpperCase()
//remove parentheses
doc.parentheses().remove()
//...uppercase the first letter of each sentence
doc.terms(0).toTitleCase()
//remove emoticons+emojis
doc.remove('(#Emoticon|#Emoji)')
//boom
return doc.text()
}
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