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

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