Public
Edited
Apr 1, 2024
Insert cell
Insert cell
{
nlp.addWords({ 'shoe in': 'Noun' }) //normal lexicon
nlp.addWords({ 'dr who': 'Person' }, true) //stronger lexicon

let doc = nlp('the dr who threw a shoe in the car.')
return {
Person:doc.people().out('array'), //kept 'dr who'
Nouns: doc.match('#Noun+').out('array') // didn't keep 'shoe in'
}
}
Insert cell
Insert cell
{
nlp.plugin({
frozen: {
'mr plow': 'Frozen',
},
})
let doc = nlp('that name again is Mr Plow..')
// here 'mr plow' is not frozen anymore
doc.compute('frozen') // re-freeze it
return doc.match('@isFrozen').text()
}
Insert cell
Insert cell
{
nlp.addTags({RomCom: {is: 'Film'}})
nlp.addWords({'drop dead fred':'Film'})
let doc = nlp('stores drop drop dead fred, featuring Carrie Fisher')
//freeze the films
let films = doc.match('#Film+').freeze()
doc.match('drop').tag('Verb') // applies to other 'drop'
doc.match('fred').tag('FirstName') // does nothing.

films.tag('RomCom') // this works
films.tag('Foobar') // this works, too

}
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