Public
Edited
Mar 24, 2022
1 star
Insert cell
Insert cell
Insert cell
nlp.tokenize(`as shocks go, this one's a real zaperoo.`).json(0).terms
Insert cell
Insert cell
{
nlp.plugin({
// add new tags
tags:{
"Food": {
"isA": "Noun"
},
"Dessert": {
"isA": "Food"
},
"Vegetable":{
"isA": "Food",
"notA": "Dessert"
}
},

// add new words to the lexicon
words:{
rutabaga: 'Vegetable',
'spotted dick': 'Dessert',
},

api:(View)=>{
//add a new method to compromise
View.prototype.isHealthy = function(){
return this.match('#Food+').notIf('Dessert')
}
}
})
// see our plugin in-action:
return nlp('i ate rutabaga and a carrot cake').isHealthy().out('array')
}
Insert cell
{
let doc = nlp(`as shocks go, this one's a real zaperoo.`)
let data = doc.json()
// (you can put this into a database, or something)
//... ok, load this data as a new doc object
let doc2 = nlp(data)
return doc2.json()
}
Insert cell
Insert cell
{
// turn-on verbose mode
nlp.verbose('tagger')
nlp("why can't i have no kids and three money?")
//see the output in the developer console
}
Insert cell
Insert cell
nlp.version
Insert cell
Insert cell
nlp.world()
Insert cell
Insert cell
{
let matchString = 'who . (the|that)'
// parse it into a faster format
let matchObj = nlp.parseMatch(matchString)
let docs=[
`who controls the British crown?`,
`Who keeps the metric system down?`,
`the leader? who's that, some kind of leader?`
]
return docs.map(str => {
let doc = nlp(str)
//avoid re-parsing the match-string, each time
return doc.match(matchObj).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