Public
Edited
Jun 14, 2023
Insert cell
Insert cell
// (use .tokenize() for a minimal initial analysis)
doc=nlp.tokenize(`time for our weekly silluette drawing`);
Insert cell
Insert cell
doc.json()[0].terms
Insert cell
Insert cell
{
let d = doc.clone()
d.compute('wordCount')
d.compute('tagRank')
d.compute('offset')
return d.json()[0].terms
}
Insert cell
Insert cell
{
let d=nlp('weekly silluette drawing')
//add the reverse for each term
d.docs[0].forEach(term=> {
// reverse it
term.backwards = term.normal.split("").reverse().join("")
})
return d.json()[0].terms
}
Insert cell
Insert cell
{
// create a plugin for our .compute() method
nlp.plugin({
compute:{
// our new compute method
backward:(d)=>{
d.docs.forEach(terms=>{
terms.forEach(t=>{
t.backward = t.normal.split("").reverse().join("") //reverse the string
})
})
}
}
})
// okay, now it has a new compute method
let doc = nlp('patio furniture')
doc.compute('backward')
return doc.json()[0].terms.map(t=>t.backward)
}
Insert cell
Insert cell
Insert cell
nlp.version
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