forked from microsoft/NLU.DevOps
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds support for entity hierarchies in compare
This change allows users to declaratively specify hierarchical entities in their expected utterance results. For example, a user may declare the following: ```json { "text": "Order a pepperoni pizza", "intent": "OrderFood", "entities": { "entity": "FoodItem", "startPos": 8, "endPos": 22, "children": [ { "entity": "Topping", "startPos": 8, "endPos": 16 }, { "entity": "FoodType", "startPos": 18, "endPos": 22 } ] } } ``` This would result in 3 test cases, one for the parent entity (the "FoodItem" entity), and two additional test cases for each of the two nested entities ("FoodItem::Topping" and "FoodItem::FoodType"). Child entity type names are prefixed by their parent entity type names in the format `parentType::childType`. As such, the recursive entity parsing for the LUIS V3 provider has been updated to use this convention. Fixes microsoft#335
- Loading branch information
Showing
11 changed files
with
255 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
namespace NLU.DevOps.Core | ||
{ | ||
using System.Collections.Generic; | ||
using Newtonsoft.Json.Linq; | ||
|
||
/// <summary> | ||
/// Entity appearing in utterance. | ||
/// </summary> | ||
public sealed class HierarchicalEntity : Entity, IHierarchicalEntity | ||
{ | ||
/// <summary> | ||
/// Initializes a new instance of the <see cref="HierarchicalEntity"/> class. | ||
/// </summary> | ||
/// <param name="entityType">Entity type name.</param> | ||
/// <param name="entityValue">Entity value, generally a canonical form of the entity.</param> | ||
/// <param name="matchText">Matching text in the utterance.</param> | ||
/// <param name="matchIndex">Occurrence index of matching token in the utterance.</param> | ||
/// <param name="children">Children entities.</param> | ||
public HierarchicalEntity(string entityType, JToken entityValue, string matchText, int matchIndex, IEnumerable<HierarchicalEntity> children) | ||
: base(entityType, entityValue, matchText, matchIndex) | ||
{ | ||
this.Children = children; | ||
} | ||
|
||
/// <inheritdoc /> | ||
public IEnumerable<IHierarchicalEntity> Children { get; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
|
||
namespace NLU.DevOps.Core | ||
{ | ||
using System.Collections.Generic; | ||
using Models; | ||
|
||
/// <summary> | ||
/// Entity with nested children. | ||
/// </summary> | ||
public interface IHierarchicalEntity : IEntity | ||
{ | ||
/// <summary> | ||
/// Gets the child entities. | ||
/// </summary> | ||
IEnumerable<IHierarchicalEntity> Children { get; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.