Fix rasa ui response entity data format issue.

This commit is contained in:
botsharp2018 2018-08-24 09:47:40 -05:00
parent d3fd87cc2a
commit 7e9927b1f8
7 changed files with 33 additions and 6 deletions

View file

@ -44,7 +44,6 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="BotSharp.NLP" Version="0.2.2" />
<PackageReference Include="DotNetToolkit" Version="1.6.0" />
<PackageReference Include="EntityFrameworkCore.BootKit" Version="1.9.1" />
<PackageReference Include="Microsoft.AspNetCore.Cryptography.KeyDerivation" Version="2.1.1" />
@ -56,4 +55,8 @@
<Folder Include="Engines\CoreNlp\" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\BotSharp.NLP\BotSharp.NLP\BotSharp.NLP.csproj" />
</ItemGroup>
</Project>

View file

@ -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

View file

@ -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<string, object> Parameters { get; set; }
public List<NlpEntity> Entities { get; set; }
public AIContext[] Contexts { get; set; }
public AIResponseMetadata Metadata { get; set; }

View file

@ -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;
}

View file

@ -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; }
}

View file

@ -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,

View file

@ -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