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

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