Published
Edited
Mar 24, 2022
1 star
Insert cell
Insert cell
Insert cell
{
let doc = nlp('Larry, Curly, and Moe')
let people = doc.match('#Noun') // grab each noun
// loop over each of them
people = people.map(d => {
return d.toQuotation() //do some mutation
})
//print it out
return people.text()
}
Insert cell
Insert cell
{
let doc = nlp('Larry, Curly, and Moe')
let people = doc.match('#Noun')
let arr = people.map(d => {
return d.text('reduced') //return strings instead
})
return arr
}
Insert cell
Insert cell
{
let doc = nlp('monday, tuesday, wednesday, thursday, and friday')
//split it into terms
let terms = doc.terms()
// loop around each one
terms.forEach(d => {
let str = d.text() // get the term's text
if(str.match(/day$/)){
d.toUpperCase() // transform the term
}
})
return doc.text()
}
Insert cell
Insert cell
Insert cell
{
let doc = nlp('one two three. three four five.')
// loop through each sentence (by default)
doc=doc.filter(p => {
return p.has('four')
})
return doc.text()
}
Insert cell
Insert cell
{
let doc = nlp('one two three. three four five.')
doc=doc.filter(p => {
return p.has('seven')
})
return doc.found
}
Insert cell
Insert cell
nlp("8:45? and here I am yappin away like it's 8:35!")
.terms()
.find(d => d.has('@hasExclamation'))
.text()
Insert cell
Insert cell
nlp("8:45? and here I am yappin away like it's 8:35!")
.terms()
.find(d => d.has('@hasQuestionMark'))
.text()
Insert cell
Insert cell
nlp('one, two, three, four').terms().random().text()
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