forked from microsoft/BotBuilder-Samples
-
Notifications
You must be signed in to change notification settings - Fork 6
/
languageGeneration.js
31 lines (22 loc) · 1.17 KB
/
languageGeneration.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
const { TimexProperty } = require('@microsoft/recognizers-text-data-types-timex-expression');
// This langauge generation capabilitis are the logical opposite of what the recognizer does.
// As an experiment try feeding the result of lanaguage generation back into a recognizer.
// You should get back the same TIMEX expression in the result.
const describe = t => {
// Note natural language is often relative, for example the senstence "Yesterday all my troubles seemed so far away."
// Having your bot say something like "next Wednesday" in a response can make it sound more natural.
const referenceDate = new Date();
console.log(`${ t.timex } ${ t.toNaturalLanguage(referenceDate) }`);
};
module.exports.examples = () => {
describe(new TimexProperty('2017-05-29'));
describe(new TimexProperty('XXXX-WXX-6'));
describe(new TimexProperty('XXXX-WXX-6T16'));
describe(new TimexProperty('T12'));
const today = new Date();
describe(TimexProperty.fromDate(today));
today.setDate(today.getDate() + 1);
describe(TimexProperty.fromDate(today));
};