Public
Edited
Nov 24, 2022
3 forks
4 stars
Insert cell
Insert cell
Insert cell
{
let doc = nlp(input)
// find and interpret each date in the text
let dates = doc.dates()
// reformat each one
dates.format('{month} {date-ordinal}')
// return the text
return html`<div class="result">${doc.text()}</div>`
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
nlp(`we met on June 1st 1992 at 8pm, then got married 1998-03-28.`).dates().out('array')
Insert cell
Insert cell
nlp(`it was two weeks after christmas.`).dates().json()[0]
Insert cell
Insert cell
nlp(`see you in three days`).dates().get()[0]
Insert cell
Insert cell
nlp(`i was born 1986-03-20.`).dates().format('{month} {date-ordinal} {year}').all().text()
Insert cell
Insert cell
nlp('four days and seven hours passed').durations().get()[0]
Insert cell
Insert cell
nlp('30mins tuesday').durations().json()[0]
Insert cell
Insert cell
nlp('it was 3 in the morning').times().get()[0]
Insert cell
nlp('meet at 5pm PST').times().get()[0]
Insert cell
Insert cell
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