Public
Edited
Feb 12, 2024
Insert cell
Insert cell
Insert cell
nlp('hello neighbour!').replace('neighbour','neighbourino').text()
Insert cell
Insert cell
{
let doc = nlp('No, my son is also named Bart.')
doc.match('bart').replaceWith('bort', { keepCase: false })
return doc.text()
}
Insert cell
Insert cell
{
let doc = nlp('Spencer is very cool.')
doc.match('spencer').replaceWith('jogging', { keepTags: true })
return doc.firstTerm().out('tags')[0].jogging
}
Insert cell
Insert cell
nlp('hello').replaceWith('a hoy hoy').text()
Insert cell
Insert cell
nlp("The summer wind came blowin' in").insertAfter('from across the sea').text()
Insert cell
Insert cell
nlp("back to Winnipeg!").insertBefore('That\'s it,').text()
Insert cell
Insert cell
Insert cell
{
let all = nlp(`your older, balder son`).adjectives()
let more = nlp('fatter')
all.concat(more)
return all.out('array')
}
Insert cell
Insert cell
{
let doc = nlp(`..and that's how I got the vending machine contract for the kremlin`)
doc.match('for the kremlin').remove()
return doc.text('trim')
}
Insert cell
Insert cell
{
let doc = nlp('before one two three after')
let m = doc.numbers() // 'one two three'
m = m.not('two')
return m.out('array') // 'one', 'three'
}
Insert cell
Insert cell
{
let doc = nlp("springfield, springfield, it's a hell of a town.")
// child one
let a = doc.match('a hell of a town')
// child two
let b = a.match('a hell of a')
// transform the second child
b.replace('hell of a', 'reasonable')
//all views have changed
return {
a:a.text(),
b:b.text(),
doc:doc.text()
}
}
Insert cell
Insert cell
{
let doc = nlp("before one two three after")
// keep a 'dangling' child document
let m = doc.match('one two three')
// transform the parent document
doc.replace('one two three', 'new')
//dangling document is updated? ❌
return m.text()
}
Insert cell
Insert cell
Insert cell
{
let doc = nlp('i walked downtown').compute('root')
doc.swap('walk', 'stroll') //use root-forms
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