Пример #1
0
        public async Task ShoulAddBatchExample()
        {
            using (var client = new LuisProgClient(SubscriptionKey, Region))
            {
                if (await client.GetIntentByNameAsync(IntentName, appId, appVersion) == null)
                {
                    await client.AddIntentAsync(IntentName, appId, appVersion);
                }

                List <Example> examples = new List <Example>();
                examples.Add(new Example
                {
                    Text       = "Hello World!",
                    IntentName = IntentName
                });

                examples.Add(new Example
                {
                    Text       = "This is a test Utterance",
                    IntentName = IntentName
                });

                var addExamples = await client.AddBatchExampleAsync(appId, appVersion, examples.ToArray());

                Assert.AreEqual <int>(2, addExamples.Length);
            }
        }
Пример #2
0
        public async Task ShoulAddBatchLbeledExample()
        {
            using (var client = new LuisProgClient(SubscriptionKey, Region))
            {
                // Add simple entity name if not already exists
                if (await client.GetEntityByNameAsync("name", appId, appVersion) == null)
                {
                    await client.AddEntityAsync("name", appId, appVersion);
                }

                // Add simple intent name if not already exists
                if (await client.GetIntentByNameAsync(IntentName, appId, appVersion) == null)
                {
                    await client.AddIntentAsync(IntentName, appId, appVersion);
                }

                List <Example> examples = new List <Example>();
                examples.Add(new Example()
                {
                    Text         = "Who is Bill?",
                    IntentName   = IntentName,
                    EntityLabels = new List <EntityLabel>
                    {
                        new EntityLabel
                        {
                            EntityName     = "name",
                            StartCharIndex = 7,
                            EndCharIndex   = 10
                        }
                    }
                });

                examples.Add(new Example()
                {
                    Text         = "Who is Christopher?",
                    IntentName   = IntentName,
                    EntityLabels = new List <EntityLabel>
                    {
                        new EntityLabel
                        {
                            EntityName     = "name",
                            StartCharIndex = 7,
                            EndCharIndex   = 17
                        }
                    }
                });

                var addExamples = await client.AddBatchExampleAsync(appId, appVersion, examples.ToArray());

                Assert.AreEqual <bool>(false, addExamples[0].HasError);
                Assert.AreEqual <bool>(false, addExamples[1].HasError);
            }
        }