Skip to content
This repository was archived by the owner on Jan 15, 2025. It is now read-only.
This repository was archived by the owner on Jan 15, 2025. It is now read-only.

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

Open

Description

@ooorndtski

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]

Activity

  1. added
    bug
    needs-triage
    on Aug 4, 2021
  2. benbrown commented on Aug 4, 2021

    @benbrown
    Contributor

    Emilio Munoz (@munozemilio) can you check this out?

  3. ooorndtski commented on Aug 5, 2021

    @ooorndtski
    Author

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

  4. added
    Bot Services
    customer-reported
    on Aug 5, 2021
  5. axelsrz commented on Aug 6, 2021

    @axelsrz
    Member

    Hello Andreas (@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.

  6. added
    customer-replied-to
    on Aug 6, 2021
  7. ooorndtski commented on Aug 9, 2021

    @ooorndtski
    Author

    Axel Suárez (@axelsrz) I made these changes in the luis portal.

  8. axelsrz commented on Aug 11, 2021

    @axelsrz
    Member

    Thanks, I will look into this and provide an update

  9. tracyboehrer commented on Aug 23, 2021

    @tracyboehrer
    Member

    Axel Suárez (@axelsrz) What is the status of this?

  10. axelsrz commented on Sep 8, 2021

    @axelsrz
    Member

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

    Thanks

  11. added
    ExemptFromDailyDRIReport
    on Sep 8, 2021
  12. added
    P1
    on Sep 20, 2021
  13. added
    backlog
    on Sep 23, 2021
  14. modified the milestones: R15, r16 on Sep 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Bot ServicesExemptFromDailyDRIReportP1backlogbugcustomer-replied-tocustomer-reportedneeds-triage

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions