diff --git a/BotSharp.Core/BotSharp.Core.csproj b/BotSharp.Core/BotSharp.Core.csproj
index f267287d..5e08e97a 100644
--- a/BotSharp.Core/BotSharp.Core.csproj
+++ b/BotSharp.Core/BotSharp.Core.csproj
@@ -44,7 +44,6 @@
-
@@ -56,4 +55,8 @@
+
+
+
+
diff --git a/BotSharp.Core/Engines/BotEngineBase.cs b/BotSharp.Core/Engines/BotEngineBase.cs
index 62993e8b..f582624d 100644
--- a/BotSharp.Core/Engines/BotEngineBase.cs
+++ b/BotSharp.Core/Engines/BotEngineBase.cs
@@ -53,6 +53,7 @@ namespace BotSharp.Core.Engines
ResolvedQuery = doc.Sentences[0].Text,
Fulfillment = new AIResponseFulfillment { },
Parameters = parameters,
+ Entities = doc.Sentences[0].Entities,
Metadata = new AIResponseMetadata
{
IntentName = doc.Sentences[0].Intent?.Label
diff --git a/BotSharp.Core/Engines/Dialogflow/AIResponseResult.cs b/BotSharp.Core/Engines/Dialogflow/AIResponseResult.cs
index 4e7e5b54..ccf1b2a2 100644
--- a/BotSharp.Core/Engines/Dialogflow/AIResponseResult.cs
+++ b/BotSharp.Core/Engines/Dialogflow/AIResponseResult.cs
@@ -1,4 +1,5 @@
using BotSharp.Core.Intents;
+using BotSharp.Models.NLP;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
@@ -33,6 +34,8 @@ namespace BotSharp.Core.Models
public Dictionary Parameters { get; set; }
+ public List Entities { get; set; }
+
public AIContext[] Contexts { get; set; }
public AIResponseMetadata Metadata { get; set; }
diff --git a/BotSharp.Core/Engines/NERs/CRFsuiteEntityRecognizer.cs b/BotSharp.Core/Engines/NERs/CRFsuiteEntityRecognizer.cs
index 53f1c1e2..036d70c4 100644
--- a/BotSharp.Core/Engines/NERs/CRFsuiteEntityRecognizer.cs
+++ b/BotSharp.Core/Engines/NERs/CRFsuiteEntityRecognizer.cs
@@ -209,7 +209,8 @@ namespace BotSharp.Core.Engines.NERs
Entity = entity,
Start = doc.Sentences[0].Tokens[i].Start,
Value = doc.Sentences[0].Tokens[i].Text,
- Confidence = probability
+ Confidence = probability,
+ Extrator = "CRFsuiteEntityRecognizer"
});
}
@@ -249,6 +250,7 @@ namespace BotSharp.Core.Engines.NERs
nlpEntity.Start = tokens[i].Start;
nlpEntity.Value = unionValue.ToString();
nlpEntity.Confidence = unoinConfidence;
+ nlpEntity.Extrator = tokens[i].Extrator;
res.Add(nlpEntity);
i = j - 1;
}
diff --git a/BotSharp.Core/Engines/TrainingIntentExpressionPart.cs b/BotSharp.Core/Engines/TrainingIntentExpressionPart.cs
index 070f960f..28739675 100644
--- a/BotSharp.Core/Engines/TrainingIntentExpressionPart.cs
+++ b/BotSharp.Core/Engines/TrainingIntentExpressionPart.cs
@@ -7,7 +7,13 @@ namespace BotSharp.Core.Engines
public class TrainingIntentExpressionPart
{
public int Start { get; set; }
- public int End { get { return Start + Value.Length; } }
+ public int End
+ {
+ get
+ {
+ return Start + Value.Length - 1;
+ }
+ }
public String Value { get; set; }
public String Entity { get; set; }
}
diff --git a/BotSharp.RestApi/Rasa/ParseController.cs b/BotSharp.RestApi/Rasa/ParseController.cs
index 14294a5b..8be0d301 100644
--- a/BotSharp.RestApi/Rasa/ParseController.cs
+++ b/BotSharp.RestApi/Rasa/ParseController.cs
@@ -72,10 +72,12 @@ namespace BotSharp.RestApi.Rasa
Name = aIResponse.Result.Metadata.IntentName,
Confidence = aIResponse.Result.Score
},
- Entities = aIResponse.Result.Parameters.Select(x => new RasaResponseEntity
+ Entities = aIResponse.Result.Entities.Select(x => new RasaResponseEntity
{
- Entity = x.Key,
- Value = x.Value.ToString()
+ Extractor = x.Extrator,
+ Start = x.Start,
+ Entity = x.Entity,
+ Value = x.Value
}).ToList(),
Text = request.Text,
Model = request.Model,
diff --git a/BotSharp.sln b/BotSharp.sln
index 0e04dc70..29cc2e01 100644
--- a/BotSharp.sln
+++ b/BotSharp.sln
@@ -11,6 +11,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BotSharp.WebHost", "BotShar
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BotSharp.Core.UnitTest", "BotSharp.Core.UnitTest\BotSharp.Core.UnitTest.csproj", "{A31A6853-DFB8-477D-8F09-8E6E3D166102}"
EndProject
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BotSharp.NLP", "..\BotSharp.NLP\BotSharp.NLP\BotSharp.NLP.csproj", "{E5588B4E-D973-4450-A676-4CF236F691AA}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -51,6 +53,14 @@ Global
{A31A6853-DFB8-477D-8F09-8E6E3D166102}.Release|Any CPU.Build.0 = Release|Any CPU
{A31A6853-DFB8-477D-8F09-8E6E3D166102}.Release|x64.ActiveCfg = Release|x64
{A31A6853-DFB8-477D-8F09-8E6E3D166102}.Release|x64.Build.0 = Release|x64
+ {E5588B4E-D973-4450-A676-4CF236F691AA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {E5588B4E-D973-4450-A676-4CF236F691AA}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {E5588B4E-D973-4450-A676-4CF236F691AA}.Debug|x64.ActiveCfg = Debug|x64
+ {E5588B4E-D973-4450-A676-4CF236F691AA}.Debug|x64.Build.0 = Debug|x64
+ {E5588B4E-D973-4450-A676-4CF236F691AA}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {E5588B4E-D973-4450-A676-4CF236F691AA}.Release|Any CPU.Build.0 = Release|Any CPU
+ {E5588B4E-D973-4450-A676-4CF236F691AA}.Release|x64.ActiveCfg = Release|x64
+ {E5588B4E-D973-4450-A676-4CF236F691AA}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE