Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Member in entity class not created correctly using bf luis:generate:cs #1281

Open
ooorndtski opened this issue Aug 4, 2021 · 7 comments
Open
Assignees
Labels
backlog The issue is out of scope for the current iteration but it will be evaluated in a future release. Bot Services Required for internal Azure reporting. Do not delete. Do not change color. bug Indicates an unexpected problem or an unintended behavior. customer-replied-to Indicates that the team has replied to the issue reported by the customer. Do not delete. customer-reported Issue is created by anyone that is not a collaborator in the repository. ExemptFromDailyDRIReport Use this label to exclude the issue from the DRI report. needs-triage The issue has just been created and it has not been reviewed by the team. P1 Painful if we don't fix, won't block releasing
Milestone

Comments

@ooorndtski
Copy link

ooorndtski commented Aug 4, 2021

Versions

BF-CLI: @microsoft/botframework-cli/4.14.1 win32-x64 node-v14.6.0
NodeJs: v14.6.0
CommandLine: Git Bash
OS: Windows 10

Describe the bug

When creating the c# class of a luis app the botframework-cli does not create entity classes of ML entities containig subentities correctly in some cases.

To Reproduce

Take this exported luis app:

{
  "luis_schema_version": "7.0.0",
  "intents": [
    {
      "name": "DeviceIntent",
      "features": []
    },
    {
      "name": "None",
      "features": []
    }
  ],
  "entities": [
    {
      "name": "Device",
      "children": [
        {
          "name": "DeviceName",
          "children": [],
          "features": [
            {
              "modelName": "DeviceName",
              "isRequired": false
            }
          ]
        },
        {
          "name": "Number",
          "children": [],
          "features": [
            {
              "modelName": "number",
              "isRequired": false
            }
          ]
        }
      ],
      "roles": [],
      "features": []
    },
    {
      "name": "ObjectEntity",
      "children": [
        {
          "name": "number",
          "children": [],
          "features": [
            {
              "modelName": "number",
              "isRequired": true
            }
          ]
        },
        {
          "name": "name",
          "children": [],
          "features": [
            {
              "modelName": "ObjectName",
              "isRequired": true
            }
          ]
        }
      ],
      "roles": [],
      "features": []
    }
  ],
  "hierarchicals": [],
  "composites": [],
  "closedLists": [
    {
      "name": "DeviceName",
      "subLists": [
        {
          "canonicalForm": "abc",
          "list": [
            "AbC"
          ]
        },
        {
          "canonicalForm": "fgh",
          "list": [
            "FGH"
          ]
        }
      ],
      "roles": []
    },
    {
      "name": "ObjectName",
      "subLists": [
        {
          "canonicalForm": "Name1",
          "list": [
            "name 1",
            "name one"
          ]
        },
        {
          "canonicalForm": "Name2",
          "list": [
            "name 2",
            "name two"
          ]
        }
      ],
      "roles": []
    }
  ],
  "prebuiltEntities": [
    {
      "name": "number",
      "roles": []
    }
  ],
  "utterances": [
    {
      "text": "it is device abc 1",
      "intent": "DeviceIntent",
      "entities": [
        {
          "entity": "Device",
          "startPos": 13,
          "endPos": 17,
          "children": [
            {
              "entity": "Number",
              "startPos": 17,
              "endPos": 17,
              "children": []
            },
            {
              "entity": "DeviceName",
              "startPos": 13,
              "endPos": 15,
              "children": []
            }
          ]
        }
      ]
    },
    {
      "text": "it's device fgh 2",
      "intent": "DeviceIntent",
      "entities": [
        {
          "entity": "Device",
          "startPos": 12,
          "endPos": 16,
          "children": [
            {
              "entity": "Number",
              "startPos": 16,
              "endPos": 16,
              "children": []
            },
            {
              "entity": "DeviceName",
              "startPos": 12,
              "endPos": 14,
              "children": []
            }
          ]
        }
      ]
    },
    {
      "text": "object name one 3 times",
      "intent": "DeviceIntent",
      "entities": [
        {
          "entity": "ObjectEntity",
          "startPos": 7,
          "endPos": 16,
          "children": [
            {
              "entity": "number",
              "startPos": 16,
              "endPos": 16,
              "children": []
            },
            {
              "entity": "name",
              "startPos": 7,
              "endPos": 14,
              "children": []
            }
          ]
        }
      ]
    },
    {
      "text": "the object is name1 18 times",
      "intent": "DeviceIntent",
      "entities": [
        {
          "entity": "ObjectEntity",
          "startPos": 14,
          "endPos": 21,
          "children": [
            {
              "entity": "number",
              "startPos": 20,
              "endPos": 21,
              "children": []
            },
            {
              "entity": "name",
              "startPos": 14,
              "endPos": 18,
              "children": []
            }
          ]
        }
      ]
    },
    {
      "text": "the objects name is name two 123 times",
      "intent": "DeviceIntent",
      "entities": [
        {
          "entity": "ObjectEntity",
          "startPos": 20,
          "endPos": 31,
          "children": [
            {
              "entity": "number",
              "startPos": 29,
              "endPos": 31,
              "children": []
            },
            {
              "entity": "name",
              "startPos": 20,
              "endPos": 27,
              "children": []
            }
          ]
        }
      ]
    }
  ],
  "versionId": "0.1",
  "name": "MyTest",
  "desc": "",
  "culture": "de-de",
  "tokenizerVersion": "1.0.2",
  "patternAnyEntities": [],
  "regex_entities": [],
  "phraselists": [],
  "regex_features": [],
  "patterns": [],
  "settings": []
}

Please notice the entity Device with child DeviceName to which the feature DeviceName (a list entity) was assigned.

Then run bf luis:generate:cs --in app.json --out ./app.cs --className MyApp.MyLuisModel. The command creates the file app.cs containing the class "MyLuisModel". In the nested class _Entities there are members public double[] number;, public string[][] DeviceName; and public DeviceClass[] Device;. DeviceClass looks like this:

public class DeviceClass
{
    public string[][] DeviceName;
    public string[] Number;
    [JsonProperty("$instance")]
    public _InstanceDevice _instance;
}

You can see that the member DeviceName is of type string[][]. If you change the child name of entity Device from DeviceName to Name (or anything other than DeviceName; just change the value of property "name" in the json file at path entities[0].children[0]), then the class DeviceClass looks like this:

public class DeviceClass
{
    public string[] Name;
    public string[] Number;
    [JsonProperty("$instance")]
    public _InstanceDevice _instance;
}

EDIT:

I've updated the Luis model and added another ML entity "ObjectEntity" consisting of sub entity "name" (required feature ObjectName) and "number" (required feature "number"). When I export the app and create the model classes, the new entity class looks like this:

public class ObjectEntityClass
{
    public double[] number;
    public string[] name;
    [JsonProperty("$instance")]
    public _InstanceObjectEntity _instance;
}

This is as expected! Well, now when I run a request using REST api the result looks like this:

{
  "query": "object name 1 5 times",
  "prediction": {
    "topIntent": "DeviceIntent",
    "intents": {
      "DeviceIntent": {
        "score": 0.9664061
      }
    },
    "entities": {
      "ObjectEntity": [{
        "name": [
          ["Name1"]
        ],
        "number": [5],
        "$instance": {
          "name": [{
            "type": "ObjectName",
            "text": "name 1",
            "startIndex": 7,
            "length": 6,
            "score": 0.6040929,
            "modelTypeId": 1,
            "modelType": "Entity Extractor",
            "recognitionSources": ["model"]
          }],
          "number": [{
            "type": "builtin.number",
            "text": "5",
            "startIndex": 14,
            "length": 1,
            "score": 0.7429372,
            "modelTypeId": 1,
            "modelType": "Entity Extractor",
            "recognitionSources": ["model"]
          }]
        }
      }],
      "number": [1],
      "$instance": {
        "ObjectEntity": [{
          "type": "ObjectEntity",
          "text": "name 1 5",
          "startIndex": 7,
          "length": 8,
          "score": 0.6226765,
          "modelTypeId": 1,
          "modelType": "Entity Extractor",
          "recognitionSources": ["model"]
        }],
        "number": [{
          "type": "builtin.number",
          "text": "1",
          "startIndex": 12,
          "length": 1,
          "modelTypeId": 2,
          "modelType": "Prebuilt Entity Extractor",
          "recognitionSources": ["model"]
        }]
      }
    }
  }
}

Have a close look at the extracted entity:

"entities": {
      "ObjectEntity": [{
        "name": [
          ["Name1"]
        ],
        "number": [5],

You'll see that the sub entity is of type string[][] which leads to an JSON exception in the code because string[] is expected.

End of edit

Expected behavior

DeviceName in class DeviceClass is of type string[].

[bug]

@ooorndtski ooorndtski added bug Indicates an unexpected problem or an unintended behavior. needs-triage The issue has just been created and it has not been reviewed by the team. labels Aug 4, 2021
@benbrown
Copy link
Contributor

benbrown commented Aug 4, 2021

@munozemilio can you check this out?

@munozemilio munozemilio assigned axelsrz and unassigned munozemilio Aug 4, 2021
@ooorndtski
Copy link
Author

It get's more stranger. I've updated the bug report. Have a look at the edit section at the end.

@benbrown benbrown added Bot Services Required for internal Azure reporting. Do not delete. Do not change color. customer-reported Issue is created by anyone that is not a collaborator in the repository. labels Aug 5, 2021
@axelsrz
Copy link
Member

axelsrz commented Aug 6, 2021

Hello @ooorndtski thanks for logging this. We're taking a closer look at this scenario to better understand if this is a bug or a limitation of the use case. Could I ask for some extre info, like if you are making these changes directly in the lu file or through the luis portal?

Thanks.

@gabog gabog added the customer-replied-to Indicates that the team has replied to the issue reported by the customer. Do not delete. label Aug 6, 2021
@ooorndtski
Copy link
Author

@axelsrz I made these changes in the luis portal.

@axelsrz
Copy link
Member

axelsrz commented Aug 11, 2021

Thanks, I will look into this and provide an update

@tracyboehrer
Copy link
Member

@axelsrz What is the status of this?

@axelsrz
Copy link
Member

axelsrz commented Sep 8, 2021

This is indeed an issue, we will provide a fix in our next cli release or sooner if a patch comes up.

Thanks

@a-b-r-o-w-n a-b-r-o-w-n added the ExemptFromDailyDRIReport Use this label to exclude the issue from the DRI report. label Sep 8, 2021
@munozemilio munozemilio added this to the R15 milestone Sep 10, 2021
@munozemilio munozemilio added the P1 Painful if we don't fix, won't block releasing label Sep 20, 2021
@mrivera-ms mrivera-ms added the backlog The issue is out of scope for the current iteration but it will be evaluated in a future release. label Sep 23, 2021
@mrivera-ms mrivera-ms modified the milestones: R15, r16 Sep 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backlog The issue is out of scope for the current iteration but it will be evaluated in a future release. Bot Services Required for internal Azure reporting. Do not delete. Do not change color. bug Indicates an unexpected problem or an unintended behavior. customer-replied-to Indicates that the team has replied to the issue reported by the customer. Do not delete. customer-reported Issue is created by anyone that is not a collaborator in the repository. ExemptFromDailyDRIReport Use this label to exclude the issue from the DRI report. needs-triage The issue has just been created and it has not been reviewed by the team. P1 Painful if we don't fix, won't block releasing
Projects
None yet
Development

No branches or pull requests

8 participants