Public
Edited
Nov 3, 2022
1 fork
3 stars
Insert cell
Insert cell
{
let doc = nlp("John's family")
let json = doc.json()
return JSON.stringify(json[0].terms, null, 2)
}
Insert cell
Insert cell
Insert cell
nlp(`springfield, springfield, it's a hell of a town.`).match('springfield').tag('City').out('tags')
Insert cell
Insert cell
nlp("telegram for Heywood U. Cuddleme").people().unTag('#Person').json(0)
Insert cell
Insert cell
nlp("Moe Sizlak.").terms().canBe('#Verb').found
Insert cell
Insert cell
{
let doc = nlp("Moe Sizlak.").terms()
doc.tagSafe('#Verb') //has no effect
return doc.out('tags')[0].moe
}
Insert cell
Insert cell
// give it an ambiguous word
word = nlp('april')
Insert cell
// you can see, it's tagged as a '#Month':
word.json(0)
Insert cell
{//ok, decide it's a Person's name, instead
word.tag('FemaleName');
return word.json(0)
}
Insert cell
Insert cell
{ //add an unknown tag
word.tag('FooBar');
//change it back to a #Month
word.tag('Month');
return word.json(0).terms[0]
}
Insert cell
Insert cell
Insert cell
{
nlp.verbose(true); // open the dev console, to see the output
nlp('it is supercalifragilisticexpialidocious')
// 'it' -> Pronoun (lexicon-match)
// 'is' -> Copula (lexicon-match)
// 'supercal...' -> Adjective suffix -ous
}
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