microsoft / botbuilder-tools

Welcome to the Bot Framework Tools repository, which is the home for a set of tools for developers building bots with the Microsoft Bot Framework
https://github.com/Microsoft/botframework
MIT License
444 stars 262 forks source link

LUISGen creates incorrect package names #1060

Closed mekinney closed 5 years ago

mekinney commented 5 years ago

Tool

Name: LuisGen Version: 2.0.2.0

Describe the bug

Clearly, I'm doing something wrong because this is too obvious not to have been fixed.

I'm building the VirtualAssistant and LUISGen creates the incorrect CS files for Intents and Entities.

Correct Code included with VirtualAssistant project:

// <auto-generated>
// Code generated by LUISGen
// Tool github: https://github.com/microsoft/botbuilder-tools
// Changes may cause incorrect behavior and will be lost if the code is
// regenerated.
// </auto-generated>
using Newtonsoft.Json;
using System.Collections.Generic;
using Microsoft.Bot.Builder;
using Microsoft.Bot.Builder.AI.Luis;
namespace Luis
{
    public class CalendarLU: IRecognizerConvert
    {
        public string Text;
        public string AlteredText;
        public enum Intent {
            AcceptEventEntry, 
            ChangeCalendarEntry, 
            CheckAvailability, 
            ConnectToMeeting, 
            ContactMeetingAttendees, 
            CreateCalendarEntry, 
            DeleteCalendarEntry, 
            FindCalendarDetail, 
            FindCalendarEntry, 
            FindCalendarWhen, 
            FindCalendarWhere, 
            FindCalendarWho, 
            FindDuration, 
            FindMeetingRoom, 
            GoBack, 
            None, 
            ShowNextCalendar, 
            ShowPreviousCalendar, 
            TimeRemaining
        };
        public Dictionary<Intent, IntentScore> Intents;

        public class _Entities
        {
            // Simple entities
            public string[] Subject;
            public string[] FromDate;
            public string[] FromTime;
            public string[] ToTime;
            public string[] MeetingRoom;
            public string[] Location;
            public string[] MoveEarlierTimeSpan;
            public string[] MoveLaterTimeSpan;
            public string[] ToDate;
            public string[] SlotAttribute;
            public string[] OrderReference;
            public string[] PositionReference;
            public string[] Message;
            public string[] Duration;
            public string[] DestinationCalendar;

            // Built-in entities
            public DateTimeSpec[] datetime;
            public double[] number;
            public double[] ordinal;
            public string[] personName;

            // Lists
            public string[][] RelationshipName;

            // Instance
            public class _Instance
            {
                public InstanceData[] Subject;
                public InstanceData[] FromDate;
                public InstanceData[] FromTime;
                public InstanceData[] ToTime;
                public InstanceData[] MeetingRoom;
                public InstanceData[] Location;
                public InstanceData[] MoveEarlierTimeSpan;
                public InstanceData[] MoveLaterTimeSpan;
                public InstanceData[] ToDate;
                public InstanceData[] SlotAttribute;
                public InstanceData[] OrderReference;
                public InstanceData[] PositionReference;
                public InstanceData[] Message;
                public InstanceData[] Duration;
                public InstanceData[] DestinationCalendar;
                public InstanceData[] datetime;
                public InstanceData[] number;
                public InstanceData[] ordinal;
                public InstanceData[] personName;
                public InstanceData[] RelationshipName;
            }
            [JsonProperty("$instance")]
            public _Instance _instance;
        }
        public _Entities Entities;

        [JsonExtensionData(ReadData = true, WriteData = true)]
        public IDictionary<string, object> Properties {get; set; }

        public void Convert(dynamic result)
        {
            var app = JsonConvert.DeserializeObject<CalendarLU>(JsonConvert.SerializeObject(result));
            Text = app.Text;
            AlteredText = app.AlteredText;
            Intents = app.Intents;
            Entities = app.Entities;
            Properties = app.Properties;
        }

        public (Intent intent, double score) TopIntent()
        {
            Intent maxIntent = Intent.None;
            var max = 0.0;
            foreach (var entry in Intents)
            {
                if (entry.Value.Score > max)
                {
                    maxIntent = entry.Key;
                    max = entry.Value.Score.Value;
                }
            }
            return (maxIntent, max);
        }
    }
}

Code generated by LuisGen 2.0.2.0 has a number of errors: Using statements are missing. Namespaces are incorrect (Microsoft.Bot.Builder.Core.Extensions.IRecognizerConvert and Microsoft.Bot.Builder.Ai.LUIS.IntentData).

// <auto-generated>
// Code generated by LUISGen C:\Code\AI\solutions\Virtual-Assistant\src\csharp\assistant\DeploymentScripts\..\LocaleConfigurations\..\DeploymentScripts\en\calendar.luis -cs Luis.CalendarLU -o C:\Code\AI\solutions\Virtual-Assistant\src\csharp\assistant\DeploymentScripts\..\LocaleConfigurations\..\..\skills\calendarskill\calendarskill\CognitiveModels\LUIS\en\calendar.lu\..\..\..\..\Dialogs\Shared\Resources
// Tool github: https://github.com/microsoft/botbuilder-tools
// Changes may cause incorrect behavior and will be lost if the code is
// regenerated.
// </auto-generated>
using Newtonsoft.Json;
using System.Collections.Generic;
namespace Luis
{
    public class CalendarLU: Microsoft.Bot.Builder.Core.Extensions.IRecognizerConvert
    {
        public string Text;
        public string AlteredText;
        public enum Intent {
            AcceptEventEntry, 
            ChangeCalendarEntry, 
            CheckAvailability, 
            ConnectToMeeting, 
            ContactMeetingAttendees, 
            CreateCalendarEntry, 
            DeleteCalendarEntry, 
            FindCalendarDetail, 
            FindCalendarEntry, 
            FindCalendarWhen, 
            FindCalendarWhere, 
            FindCalendarWho, 
            FindDuration, 
            FindMeetingRoom, 
            GoBack, 
            None, 
            ShowNextCalendar, 
            ShowPreviousCalendar, 
            TimeRemaining
        };
        public Dictionary<Intent, Microsoft.Bot.Builder.Ai.LUIS.IntentData> Intents;

        public class _Entities
        {
            // Simple entities
            public string[] Subject;
            public string[] FromDate;
            public string[] FromTime;
            public string[] ToTime;
            public string[] MeetingRoom;
            public string[] Location;
            public string[] MoveEarlierTimeSpan;
            public string[] MoveLaterTimeSpan;
            public string[] ToDate;
            public string[] SlotAttribute;
            public string[] OrderReference;
            public string[] PositionReference;
            public string[] Message;
            public string[] Duration;
            public string[] DestinationCalendar;

            // Built-in entities
            public Microsoft.Bot.Builder.Ai.LUIS.DateTimeSpec[] datetime;
            public double[] number;
            public double[] ordinal;
            public string[] personName;

            // Lists
            public string[][] RelationshipName;

            // Instance
            public class _Instance
            {
                public Microsoft.Bot.Builder.Ai.LUIS.InstanceData[] Subject;
                public Microsoft.Bot.Builder.Ai.LUIS.InstanceData[] FromDate;
                public Microsoft.Bot.Builder.Ai.LUIS.InstanceData[] FromTime;
                public Microsoft.Bot.Builder.Ai.LUIS.InstanceData[] ToTime;
                public Microsoft.Bot.Builder.Ai.LUIS.InstanceData[] MeetingRoom;
                public Microsoft.Bot.Builder.Ai.LUIS.InstanceData[] Location;
                public Microsoft.Bot.Builder.Ai.LUIS.InstanceData[] MoveEarlierTimeSpan;
                public Microsoft.Bot.Builder.Ai.LUIS.InstanceData[] MoveLaterTimeSpan;
                public Microsoft.Bot.Builder.Ai.LUIS.InstanceData[] ToDate;
                public Microsoft.Bot.Builder.Ai.LUIS.InstanceData[] SlotAttribute;
                public Microsoft.Bot.Builder.Ai.LUIS.InstanceData[] OrderReference;
                public Microsoft.Bot.Builder.Ai.LUIS.InstanceData[] PositionReference;
                public Microsoft.Bot.Builder.Ai.LUIS.InstanceData[] Message;
                public Microsoft.Bot.Builder.Ai.LUIS.InstanceData[] Duration;
                public Microsoft.Bot.Builder.Ai.LUIS.InstanceData[] DestinationCalendar;
                public Microsoft.Bot.Builder.Ai.LUIS.InstanceData[] datetime;
                public Microsoft.Bot.Builder.Ai.LUIS.InstanceData[] number;
                public Microsoft.Bot.Builder.Ai.LUIS.InstanceData[] ordinal;
                public Microsoft.Bot.Builder.Ai.LUIS.InstanceData[] personName;
                public Microsoft.Bot.Builder.Ai.LUIS.InstanceData[] RelationshipName;
            }
            [JsonProperty("$instance")]
            public _Instance _instance;
        }
        public _Entities Entities;

        [JsonExtensionData(ReadData = true, WriteData = true)]
        public IDictionary<string, object> Properties {get; set; }

        public void Convert(dynamic result)
        {
            var app = JsonConvert.DeserializeObject<CalendarLU>(JsonConvert.SerializeObject(result));
            Text = app.Text;
            AlteredText = app.AlteredText;
            Intents = app.Intents;
            Entities = app.Entities;
            Properties = app.Properties;
        }

        public (Intent intent, double score) TopIntent()
        {
            Intent maxIntent = Intent.None;
            var max = 0.0;
            foreach (var entry in Intents)
            {
                if (entry.Value.Score > max)
                {
                    maxIntent = entry.Key;
                    max = entry.Value.Score;
                }
            }
            return (maxIntent, max);
        }
    }
}

[bug]

AmirGeorge commented 5 years ago

It doesn't seem like the output from LuisGen has recently changed. The using statements are still there. @cahann please assign someone from the VA team to take a look.

cahann commented 5 years ago

@darrenj who is the right person in your team to look into this issue?

darrenj commented 5 years ago

Don't think it's an issue on our side? I've just re-run luisgen for the attached Calendar.json file and it matches the original example given, I can't repro the 2nd example?

This is on version 2.0.2.0

// <auto-generated>
// Code generated by LUISGen calendar.json -cs Luis.CalendarLU -o 
// Tool github: https://github.com/microsoft/botbuilder-tools
// Changes may cause incorrect behavior and will be lost if the code is
// regenerated.
// </auto-generated>
using Newtonsoft.Json;
using System.Collections.Generic;
using Microsoft.Bot.Builder;
using Microsoft.Bot.Builder.AI.Luis;
namespace Luis
{
    public class CalendarLU: IRecognizerConvert
    {
        public string Text;
        public string AlteredText;
        public enum Intent {
            AcceptEventEntry, 
            ChangeCalendarEntry, 
            CheckAvailability, 
            ConnectToMeeting, 
            ContactMeetingAttendees, 
            CreateCalendarEntry, 
            DeleteCalendarEntry, 
            FindCalendarDetail, 
            FindCalendarEntry, 
            FindCalendarWhen, 
            FindCalendarWhere, 
            FindCalendarWho, 
            FindDuration, 
            FindMeetingRoom, 
            GoBack, 
            None, 
            ShowNextCalendar, 
            ShowPreviousCalendar, 
            TimeRemaining
        };
        public Dictionary<Intent, IntentScore> Intents;

        public class _Entities
        {
            // Simple entities
            public string[] Subject;
            public string[] FromDate;
            public string[] FromTime;
            public string[] ToTime;
            public string[] MeetingRoom;
            public string[] Location;
            public string[] MoveEarlierTimeSpan;
            public string[] MoveLaterTimeSpan;
            public string[] ToDate;
            public string[] SlotAttribute;
            public string[] OrderReference;
            public string[] PositionReference;
            public string[] Message;
            public string[] Duration;
            public string[] DestinationCalendar;

            // Built-in entities
            public DateTimeSpec[] datetime;
            public double[] number;
            public double[] ordinal;
            public string[] personName;

            // Lists
            public string[][] RelationshipName;

            // Instance
            public class _Instance
            {
                public InstanceData[] Subject;
                public InstanceData[] FromDate;
                public InstanceData[] FromTime;
                public InstanceData[] ToTime;
                public InstanceData[] MeetingRoom;
                public InstanceData[] Location;
                public InstanceData[] MoveEarlierTimeSpan;
                public InstanceData[] MoveLaterTimeSpan;
                public InstanceData[] ToDate;
                public InstanceData[] SlotAttribute;
                public InstanceData[] OrderReference;
                public InstanceData[] PositionReference;
                public InstanceData[] Message;
                public InstanceData[] Duration;
                public InstanceData[] DestinationCalendar;
                public InstanceData[] datetime;
                public InstanceData[] number;
                public InstanceData[] ordinal;
                public InstanceData[] personName;
                public InstanceData[] RelationshipName;
            }
            [JsonProperty("$instance")]
            public _Instance _instance;
        }
        public _Entities Entities;

        [JsonExtensionData(ReadData = true, WriteData = true)]
        public IDictionary<string, object> Properties {get; set; }

        public void Convert(dynamic result)
        {
            var app = JsonConvert.DeserializeObject<CalendarLU>(JsonConvert.SerializeObject(result));
            Text = app.Text;
            AlteredText = app.AlteredText;
            Intents = app.Intents;
            Entities = app.Entities;
            Properties = app.Properties;
        }

        public (Intent intent, double score) TopIntent()
        {
            Intent maxIntent = Intent.None;
            var max = 0.0;
            foreach (var entry in Intents)
            {
                if (entry.Value.Score > max)
                {
                    maxIntent = entry.Key;
                    max = entry.Value.Score.Value;
                }
            }
            return (maxIntent, max);
        }
    }
}

calendar.zip

mekinney commented 5 years ago

On vacation, so slow response and can’t retest. Daily build worked for me. Seems to be a release issue, if that helps.

Get Outlook for iOShttps://aka.ms/o0ukef


From: Darren Jefford notifications@github.com Sent: Thursday, April 18, 2019 4:11:32 AM To: Microsoft/botbuilder-tools Cc: Mike Kinney; Author Subject: Re: [Microsoft/botbuilder-tools] LUISGen creates incorrect package names (#1060)

Don't think it's an issue on our side? I've just re-run luisgen for the attached Calendar.json file and it matches the original example given, I can't repro the 2nd example?

This is on version 2.0.2.0

// // Code generated by LUISGen calendar.json -cs Luis.CalendarLU -o // Tool github: https://github.com/microsoft/botbuilder-tools // Changes may cause incorrect behavior and will be lost if the code is // regenerated. // using Newtonsoft.Json; using System.Collections.Generic; using Microsoft.Bot.Builder; using Microsoft.Bot.Builder.AI.Luis; namespace Luis { public class CalendarLU: IRecognizerConvert { public string Text; public string AlteredText; public enum Intent { AcceptEventEntry, ChangeCalendarEntry, CheckAvailability, ConnectToMeeting, ContactMeetingAttendees, CreateCalendarEntry, DeleteCalendarEntry, FindCalendarDetail, FindCalendarEntry, FindCalendarWhen, FindCalendarWhere, FindCalendarWho, FindDuration, FindMeetingRoom, GoBack, None, ShowNextCalendar, ShowPreviousCalendar, TimeRemaining }; public Dictionary<Intent, IntentScore> Intents;

    public class _Entities
    {
        // Simple entities
        public string[] Subject;
        public string[] FromDate;
        public string[] FromTime;
        public string[] ToTime;
        public string[] MeetingRoom;
        public string[] Location;
        public string[] MoveEarlierTimeSpan;
        public string[] MoveLaterTimeSpan;
        public string[] ToDate;
        public string[] SlotAttribute;
        public string[] OrderReference;
        public string[] PositionReference;
        public string[] Message;
        public string[] Duration;
        public string[] DestinationCalendar;

        // Built-in entities
        public DateTimeSpec[] datetime;
        public double[] number;
        public double[] ordinal;
        public string[] personName;

        // Lists
        public string[][] RelationshipName;

        // Instance
        public class _Instance
        {
            public InstanceData[] Subject;
            public InstanceData[] FromDate;
            public InstanceData[] FromTime;
            public InstanceData[] ToTime;
            public InstanceData[] MeetingRoom;
            public InstanceData[] Location;
            public InstanceData[] MoveEarlierTimeSpan;
            public InstanceData[] MoveLaterTimeSpan;
            public InstanceData[] ToDate;
            public InstanceData[] SlotAttribute;
            public InstanceData[] OrderReference;
            public InstanceData[] PositionReference;
            public InstanceData[] Message;
            public InstanceData[] Duration;
            public InstanceData[] DestinationCalendar;
            public InstanceData[] datetime;
            public InstanceData[] number;
            public InstanceData[] ordinal;
            public InstanceData[] personName;
            public InstanceData[] RelationshipName;
        }
        [JsonProperty("$instance")]
        public _Instance _instance;
    }
    public _Entities Entities;

    [JsonExtensionData(ReadData = true, WriteData = true)]
    public IDictionary<string, object> Properties {get; set; }

    public void Convert(dynamic result)
    {
        var app = JsonConvert.DeserializeObject<CalendarLU>(JsonConvert.SerializeObject(result));
        Text = app.Text;
        AlteredText = app.AlteredText;
        Intents = app.Intents;
        Entities = app.Entities;
        Properties = app.Properties;
    }

    public (Intent intent, double score) TopIntent()
    {
        Intent maxIntent = Intent.None;
        var max = 0.0;
        foreach (var entry in Intents)
        {
            if (entry.Value.Score > max)
            {
                maxIntent = entry.Key;
                max = entry.Value.Score.Value;
            }
        }
        return (maxIntent, max);
    }
}

}

calendar.ziphttps://eur04.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FMicrosoft%2Fbotbuilder-tools%2Ffiles%2F3094738%2Fcalendar.zip&data=02%7C01%7C%7C92931cde6a9a4f6e418108d6c407c3c9%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636911934954628560&sdata=yX7Z8bEA%2BZfz%2B3UdD9VPNpZmxAMJdFIC%2FtXv%2FrD5fGo%3D&reserved=0

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://eur04.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FMicrosoft%2Fbotbuilder-tools%2Fissues%2F1060%23issuecomment-484527091&data=02%7C01%7C%7C92931cde6a9a4f6e418108d6c407c3c9%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636911934954628560&sdata=8eXdZ37UKEwv1qZqbTo52YSlqVApZHp3%2BrpVAXyMvMQ%3D&reserved=0, or mute the threadhttps://eur04.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FABZT22QBK7A3EC7QAOX72L3PRB6RJANCNFSM4HFBQGYA&data=02%7C01%7C%7C92931cde6a9a4f6e418108d6c407c3c9%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C636911934954638555&sdata=AwM8UcWw5ufePjU7%2FsfFR%2FHDlHhRq57ptGh2JXR0Nm4%3D&reserved=0.

AmirGeorge commented 5 years ago

Closing as we can't reproduce the issue. @mekinney feel free to reopen if you have repro steps to follow. Thanks!