Public
Edited
Jul 25, 2023
1 fork
Importers
5 stars
Insert cell
Insert cell
Insert cell
Insert cell
{
let doc = nlp('april')
//by default, it is a #Month, and a #Date
doc.tag('FemaleName')
//now it is automatically a #Person, and a #FirstName
return doc.out('tags')[0].april
}
Insert cell
Insert cell
{
let doc = nlp('Elizabeth May')
doc.match('may').tag('Modal') //make it a verb (remove all Person tags)
return doc.json(0)
}
Insert cell
Insert cell
nlp('hiii everybody!').tag('Greeting').out('tags')
Insert cell
Insert cell
{
//extend compromise
nlp.plugin({
tags:{
Doctor: {
isA: 'Person',
},
Surgeon: {
isA: 'Doctor',
},
Actor: {
isA: 'Person',
notA: 'Doctor',
},
}
})

let doc = nlp('hiii Dr. Nick!')
// apply a new tag:
doc.people().tag('Surgeon') // (also becomes 'Doctor')
// set a new, conflicting tag:
doc.people().tag('Actor') // no longer doctor, or Surgeon
return doc.out('tags')
}
Insert cell
Insert cell
{
//add a new tag:
nlp.extend({
tags: { CoolTag: {} }
})

return nlp.model().one.tagSet
}
Insert cell
Insert cell
Insert cell
{
let doc = nlp(`I've got a Dungeon Master's Guide`)
doc.compute('penn')
let json = doc.json()[0].terms
return json.map(term=> [ term.text, term.penn] )
}
Insert cell
Insert cell
{
const mapping = {
CC: 'Conjunction',
CD: 'Cardinal',
DT: 'Determiner',
EX: 'Preposition', //Existential there
FW: 'Expression',
IN: 'Preposition',
JJ: 'Adjective',
JJR: 'Comparative',
JJS: 'Superlative',
MD: 'Modal',
NN: 'Noun',
NNS: 'Plural',
NNP: 'Singular',
NNPS: ' Plural',
POS: 'Possessive',
PRP: 'Pronoun',
RB: 'Adverb',
RBR: 'Comparative',
RBS: 'Superlative',
RP: 'PhrasalVerb',
PDT: 'Determiner',
SYM: 'Expression',
TO: 'Conjunction',
UH: 'Expression',
VB: 'Verb',
VBD: 'PastTense',
VBG: 'Gerund',
VBN: 'Participle', // past participle
VBP: 'PresentTense', // non-3rd person singular present
VBZ: 'PresentTense', // 3rd person singular present
'PRP$': 'Pronoun',
'WP$': 'Possessive',
WDT: 'Determiner',
WP: 'Pronoun',
WRB: 'Adverb',
}
}
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