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

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