Published
Edited
Mar 23, 2022
1 fork
Importers
10 stars
Insert cell
Insert cell
{
let text = await getText('Vladamir Putin')
let arr = nlp(text).people()
return printList(arr)
}
Insert cell
Insert cell
{
let text = await getText('Tom Green')
let arr = nlp(text).places()
return printList(arr)
}
Insert cell
Insert cell
{
let arr = nlp("If word gets out about this, Kwazy-Clown Airlines will be a laughing stock.").organizations()
return printList(arr)
}
Insert cell
Insert cell
{
let text = await getText('Alan Greenspan')
let arr = nlp(text).topics()
return printList(arr)
}
Insert cell
Insert cell
{
var text = `i went to Toronto's waterfront and saw the Toronto Blue Jays`
var topics = nlp(text).topics()
//normalize them
topics.normalize({possessives:true}) //maybe add plurals: true?
topics = topics.out('array')
//throw these at wikipedia (follows redirects)
let docs = await wtf.fetch(topics)
//get rid of empty results
docs = docs.filter(l=> l)
//render some html
let result= docs.map(doc=>{
return `<li id="result">${doc.sentences(0).text()}</li>` //print the first sentence of the article
}).join(' ')
return html`${result}`
}
Insert cell
Insert cell
{
let str = `Elizabeth Woolridge Grant (born June 21, 1985), known professionally as Lana Del Rey, is an American singer, songwriter, record producer, poet, and model.`;
let doc=nlp(str)
//grab default results
let topics=doc.topics()
//grab all titlecased words
let capitals=doc.clauses().match('#TitleCase+')
//add them in to our results
topics = topics.concat(capitals).unique().sort('chron')
return topics.out('array')
}
Insert cell
Insert cell
Insert cell
printList=function(doc){
return JSON.stringify(doc.out('array'), null, 2)
}
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