public override void Display()
        {
            base.Display();

            Console.WriteLine();
            Console.WriteLine("We'll create a new \"intent\" including the following utterances:");
            Console.WriteLine(" - Hi");
            Console.WriteLine(" - Hello");

            var greetingIntent = new ModelCreateObject
            {
                Name = "Greeting"
            };

            var intentId = AwaitTask(Client.Model.AddIntentAsync(AppId, VersionId, greetingIntent));

            Console.WriteLine($"{greetingIntent.Name} intent created with the id {intentId}");

            var utterances = new List <ExampleLabelObject>
            {
                new ExampleLabelObject("Hi", null, greetingIntent.Name),
                new ExampleLabelObject("Hello", null, greetingIntent.Name)
            };

            var utterancesResult = AwaitTask(Client.Examples.BatchAsync(AppId, VersionId, utterances));

            Console.WriteLine("Utterances added to the intent");

            NavigateWithInitializer <AddUtterancePage>((page) => {
                page.AppId      = AppId;
                page.VersionId  = VersionId;
                page.IntentName = greetingIntent.Name;
            });
        }
예제 #2
0
        public override void Display()
        {
            base.Display();

            Console.WriteLine("We’ll create two new entities.");
            Console.WriteLine("The \"Destination\" simple entity will hold the flight destination.");
            Console.WriteLine("The \"Class\" hierarchical entity will accept \"First\", \"Business\" and \"Economy\" values.");

            var simpleEntity = new ModelCreateObject
            {
                Name = "Destination"
            };

            var simpleEntityId = AwaitTask(Client.Model.AddEntityAsync(AppId, VersionId, simpleEntity));

            Console.WriteLine($"{simpleEntity.Name} simple entity created with id {simpleEntityId}");

            var hierarchicalEntity = new HierarchicalEntityModel
            {
                Name     = "Class",
                Children = new[] { "First", "Business", "Economy" }
            };

            var hierarchicalEntityId = AwaitTask(Client.Model.AddHierarchicalEntityAsync(AppId, VersionId, hierarchicalEntity));

            Console.WriteLine($"{hierarchicalEntity.Name} hierarchical entity created with id {hierarchicalEntityId}");

            BaseProgram.sampleUtterance = "Find flights to London in first class";

            NavigateWithInitializer <FlightsEntityPage>((page) =>
            {
                page.AppId     = AppId;
                page.VersionId = VersionId;
            });
        }
        public override void Display()
        {
            base.Display();

            Console.WriteLine("We’ll create a new \"FindFlights\" intent including the following utterances:");
            Console.WriteLine($" - {findEconomyToMadrid}");
            Console.WriteLine($" - {findFirstToLondon}");

            var findFlightsIntent = new ModelCreateObject
            {
                Name = "FindFlights"
            };

            var intentId = AwaitTask(Client.Model.AddIntentAsync(this.AppId, this.VersionId, findFlightsIntent));

            Console.WriteLine($"{findFlightsIntent.Name} intent created with the id {intentId}");

            var findEconomyToMadridUtterance = new ExampleLabelObject
            {
                Text         = findEconomyToMadrid,
                EntityLabels = new[]
                {
                    GetExampleLabel(findEconomyToMadrid, "Flight", "economy to Madrid"),
                    GetExampleLabel(findEconomyToMadrid, "Destination", "Madrid"),
                    GetExampleLabel(findEconomyToMadrid, "Class", "economy")
                },
                IntentName = findFlightsIntent.Name
            };
            var findFirstToLondonUtterance = new ExampleLabelObject
            {
                Text         = findFirstToLondon,
                EntityLabels = new[]
                {
                    GetExampleLabel(findFirstToLondon, "Flight", "London in first class"),
                    GetExampleLabel(findFirstToLondon, "Destination", "London"),
                    GetExampleLabel(findFirstToLondon, "Class", "first")
                },
                IntentName = findFlightsIntent.Name
            };

            var utterances = new List <ExampleLabelObject> {
                findEconomyToMadridUtterance, findFirstToLondonUtterance
            };

            var utterancesResult = AwaitTask(Client.Examples.BatchAsync(this.AppId, this.VersionId, utterances));

            Console.WriteLine($"Utterances added to the {findFlightsIntent.Name} intent");

            NavigateWithInitializer <TrainAppPage>((page) =>
            {
                page.AppId     = AppId;
                page.VersionId = VersionId;
            });
        }
예제 #4
0
        public void AddIntent()
        {
            UseClientFor(async client =>
            {
                var newIntent = new ModelCreateObject
                {
                    Name = "TestIntent"
                };

                var newIntentId = await client.Model.AddIntentAsync(GlobalAppId, versionId, newIntent);
                var intents     = await client.Model.ListIntentsAsync(GlobalAppId, versionId);
                await client.Model.DeleteIntentAsync(GlobalAppId, versionId, newIntentId);

                Assert.True(newIntentId != Guid.Empty);
                Assert.Contains(intents, i => i.Id.Equals(newIntentId) && i.Name.Equals(newIntent.Name));
            });
        }
예제 #5
0
        public override void Display()
        {
            base.Display();

            Console.WriteLine("We’ll create a new \"SendFlowers\" intent including the following utterances:");
            Console.WriteLine($" - {sendBouquetOfRoses}");
            Console.WriteLine($" - {sendCactusFlowerpot}");

            var sendFlowersIntent = new ModelCreateObject
            {
                Name = "SendFlowers"
            };

            var intentId = AwaitTask(Client.Model.AddIntentAsync(this.AppId, this.VersionId, sendFlowersIntent));

            Console.WriteLine($"{sendFlowersIntent.Name} intent created with the id {intentId}");

            var bouquetOfRosesUtterance = new ExampleLabelObject
            {
                Text         = sendBouquetOfRoses,
                EntityLabels = new[] { GetExampleLabel(sendBouquetOfRoses, "Bouquet"), GetExampleLabel(sendBouquetOfRoses, "Bouquet::Roses", "roses") },
                IntentName   = sendFlowersIntent.Name
            };
            var cactusFlowerpotUtterance = new ExampleLabelObject
            {
                Text         = sendCactusFlowerpot,
                EntityLabels = new[] { GetExampleLabel(sendCactusFlowerpot, "Flowerpot"), GetExampleLabel(sendCactusFlowerpot, "Flowerpot::Cactus", "cactus") },
                IntentName   = sendFlowersIntent.Name
            };

            var utterances = new List <ExampleLabelObject> {
                bouquetOfRosesUtterance, cactusFlowerpotUtterance
            };

            var utterancesResult = AwaitTask(Client.Examples.BatchAsync(this.AppId, this.VersionId, utterances));

            Console.WriteLine($"Utterances added to the {sendFlowersIntent.Name} intent");


            NavigateWithInitializer <TrainAppPage>((page) =>
            {
                page.AppId     = AppId;
                page.VersionId = VersionId;
            });
        }
예제 #6
0
        public async Task <Guid> AddIntentAsync(string name)
        {
            var create = new ModelCreateObject(name);

            return(await _luisAuthoringClient.Model.AddIntentAsync(_luisSettings.AppId, _luisSettings.LuisVersion, create));
        }