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

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