Published
Edited
Mar 23, 2022
Insert cell
Insert cell
Insert cell
{
let doc = nlp("I'm looking for Amanda Hugginkiss")
// (doc is already cached)
doc.prepend('Hey everybody,')
//(doc is no longer cached!)
// this will be a little slower now:
console.time('slow')
doc.match('#Person+')
console.timeEnd('slow')

// but we can always manually cache it:
doc.cache()
// this will be a little faster now:
console.time('fast')
doc.match('#Person+')
console.timeEnd('fast')
}
Insert cell
Insert cell
Insert cell
Insert cell
{
let doc = nlp('i am the very model of a modern major general')
//set the cache
doc.cache()
//console.log(doc._cache)
//add a new tag
doc.match('major general').tag('Rank')
doc.has('#Rank') //false!
// invalidate the cache
doc = doc.replace('modern', 'old')
return doc.has('#Rank') //true now!
}
Insert cell
Insert cell
{
let doc = nlp('i am the very model of a modern major general')
doc.cache()
doc.cache.set //true
let child = doc.match('modern . general')
return child.cache.set //false!
}
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