-
Notifications
You must be signed in to change notification settings - Fork 4.9k
/
LanguageGeneration.cs
34 lines (31 loc) · 1.41 KB
/
LanguageGeneration.cs
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
32
33
34
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
using System;
using Microsoft.Recognizers.Text.DataTypes.TimexExpression;
namespace Microsoft.BotBuilderSamples
{
/// <summary>
/// This language generation capabilities are the logical opposite of what the recognizer does.
/// As an experiment try feeding the result of language generation back into a recognizer.
/// You should get back the same TIMEX expression in the result.
/// </summary>
public static class LanguageGeneration
{
private static void Describe(TimexProperty t)
{
// Note natural language is often relative, for example the sentence "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.
var referenceDate = DateTime.Now;
Console.WriteLine($"{t.TimexValue} {t.ToNaturalLanguage(referenceDate)}");
}
public static void Examples()
{
Describe(new TimexProperty("2019-05-29"));
Describe(new TimexProperty("XXXX-WXX-6"));
Describe(new TimexProperty("XXXX-WXX-6T16"));
Describe(new TimexProperty("T12"));
Describe(TimexProperty.FromDate(DateTime.Now));
Describe(TimexProperty.FromDate(DateTime.Now + TimeSpan.FromDays(1)));
}
}
}