compromise
Version:
natural language processing in the browser
37 lines (34 loc) • 831 B
JavaScript
;
const Text = require('../../index');
const Date = require('./date');
class Dates extends Text {
toShortForm() {
this.match('#Month').forEachTerms((t) => {
t = t.month.toShortForm();
});
this.match('#WeekDay').forEachTerms((t) => {
t = t.weekday.toShortForm();
});
return this;
}
toLongForm() {
this.match('#Month').forEachTerms((t) => {
t = t.month.toLongForm();
});
this.match('#WeekDay').forEachTerms((t) => {
t = t.weekday.toLongForm();
});
return this;
}
data() {
return this.list.map((ts) => ts.data());
}
static find(r) {
let dates = r.match('#Date+');
dates.list = dates.list.map((ts) => {
return new Date(ts.terms, ts.lexicon, ts.parent, ts.parentTerms);
});
return dates;
}
}
module.exports = Dates;