2017-06-04 5 views
1

LUIS DatetimeV2エンティティをJS Dateオブジェクトに変換するための組み込みヘルパーメソッドがLUIS SdkまたはBot Sdkにありますか? C#用のChronic Parserを使用している人もいますが、Nodejsで動作するものは見つかりませんでした。LUIS Datetime V2をJSに変換する

const dt = builder.EntityRecognizer.findEntity(args.intent.entities, 'datetimeV2'); 
if (dt) { 
    // this is just the matching intent, I believe. 
    // example intents; today, yesterday, 2/28, 31/5, ... 
    // How do I convert this to a valid Date is where I am stuck. 
} 

答えて

1

NodeJSでdatetimeV2エンティティを抽出するために、あなたが実行する必要がありますという点で、より具体的である:

const dt = builder.EntityRecognizer.findEntity(args.intent.entities, 
    'builtin.datetimeV2.date'); 

const dt_daterange = builder.EntityRecognizer.findEntity(args.intent.entities, 
    'builtin.datetimeV2.daterange'); 

あなたはMDNで、ここでそれを見ることができますDateオブジェクトを作成します。

ここには、LUIS応答オブジェクトのエンティティの構造を示すdatetimeV2のblogpostがあります。 Dateオブジェクトを作成するには

、あなたはdt.resolution.values[i]['value']を取ると、そのようなコンストラクタにそれを置くことができます。

const dt_obj = new Date(dt.resolution.values[i]['value']); 
+1

感謝。 'IEntity'型に' resolution'プロパティがあるのを知らなかったのです。 'dt'オブジェクト全体を文字列化するときにそれを見ただけです。これは魅力のように機能します! –