Public
Edited
Jan 11, 2024
2 forks
Insert cell
Insert cell
{
let myWords = {
'apple':'Person'
}
let doc = nlp('Apple is nice', myWords) //add words as a 2nd param
return doc.json()
}
Insert cell
Insert cell
{
let words = {
'a hoy hoy' : 'Greeting',
'howdily doodily' : 'Greeting'
}
let doc = nlp('howdily doodily neighbourino?', words)
let m = doc.match('#Greeting+') // '+' for a greedy multi-word match
return m.text()
}
Insert cell
Insert cell
{
return Object.keys(nlp.model().one.lexicon).length.toLocaleString() +' words, total'
}
Insert cell
Insert cell
{
nlp.plugin({
words:{
'howdily doodily': 'Greeting',
neighbourino: 'Friend',
leftorium: 'Store',
}
})
return nlp('well hey there neighbourino').match('#Friend').text()
}
Insert cell
Insert cell
Insert cell
nlp.model().one.lexicon
Insert cell
Insert cell
{
let myWords = {abc:'Organization', apple:'Organization', fuji:'Organization', samsung:'Organization'}
let defaultWords = nlp.model().one.lexicon
return Object.keys(myWords).filter(k => defaultWords[k]!== myWords[k])
}
Insert cell
Insert cell
Insert cell
{
let before = nlp.model().one.lexicon['ibm']
//change it directly
delete nlp.model().one.lexicon.apple

//or change it in a plugin
nlp.plugin({
mutate:(world)=>{
delete world.model.one.lexicon['ibm']
}
})
return 'before: '+ before + '\n now: ' + nlp.model().one.lexicon['ibm']
}
Insert cell
Insert cell
{
nlp.addWords({
spot : 'Verb',
rush: 'Verb'
})
let doc = nlp(`"that's spot on!", said Rush Limbaugh.`)
}
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