add response parameters.

This commit is contained in:
botsharp2018 2018-10-24 23:54:26 -05:00
parent 045a7fbffd
commit 09282234e4
7 changed files with 24 additions and 25 deletions

View file

@ -1,14 +1,8 @@
using BotSharp.Models.NLP;
using BotSharp.Platform.Abstraction;
using BotSharp.Platform.Models;
using BotSharp.Platform.Models;
using BotSharp.Platform.Models.AiRequest;
using BotSharp.Platform.Models.AiResponse;
using BotSharp.Platform.Models.Intents;
using DotNetToolkit;
using BotSharp.Platform.Models.Entities;
using EntityFrameworkCore.BootKit;
using Microsoft.EntityFrameworkCore;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
using System;
using System.Collections.Generic;
using System.Drawing;

View file

@ -2,9 +2,7 @@
using Bigtree.Algorithm.CRFLite;
using Bigtree.Algorithm.CRFLite.Decoder;
using Bigtree.Algorithm.CRFLite.Encoder;
using BotSharp.Models.NLP;
using BotSharp.NLP.Tokenize;
using DotNetToolkit;
using Microsoft.Extensions.Configuration;
using System;
using System.Collections.Generic;
@ -14,10 +12,11 @@ using System.Text;
using System.Threading.Tasks;
using BotSharp.Platform.Models;
using BotSharp.Platform.Models.MachineLearning;
using BotSharp.Platform.Models.Entities;
namespace BotSharp.Core.Engines.BotSharp
{
public class BotSharpCRFNer : INlpTrain, INlpPredict
public class BotSharpNER : INlpTrain, INlpPredict
{
public IConfiguration Configuration { get; set; }
public PipeSettings Settings { get; set; }
@ -197,7 +196,7 @@ namespace BotSharp.Core.Engines.BotSharp
Start = doc.Sentences[0].Tokens[i].Start,
Value = doc.Sentences[0].Tokens[i].Text,
Confidence = 0,
Extrator = "BotSharpCRFNer"
Extrator = "BotSharpNER"
});
}

View file

@ -1,6 +1,6 @@
using BotSharp.Core.Abstractions;
using BotSharp.Models.NLP;
using BotSharp.NLP.Tokenize;
using BotSharp.Platform.Models.Entities;
using System;
using System.Collections.Generic;
using System.Text;

View file

@ -1,12 +1,11 @@
using BotSharp.Core.Engines;
using BotSharp.Models.NLP;
using BotSharp.Platform.Abstraction;
using BotSharp.Platform.Models;
using BotSharp.Platform.Models.AiRequest;
using BotSharp.Platform.Models.AiResponse;
using BotSharp.Platform.Models.Entities;
using BotSharp.Platform.Models.MachineLearning;
using DotNetToolkit;
using Microsoft.Extensions.Configuration;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
@ -152,12 +151,10 @@ namespace BotSharp.Core
var preditor = new BotPredictor();
var doc = await preditor.Predict(Agent, request);
var parameters = new Dictionary<String, Object>();
if (doc.Sentences[0].Entities == null)
{
doc.Sentences[0].Entities = new List<NlpEntity>();
}
doc.Sentences[0].Entities.ForEach(x => parameters[x.Entity] = x.Value);
var predictedIntent = doc.Sentences[0].Intent;
@ -166,7 +163,8 @@ namespace BotSharp.Core
ResolvedQuery = request.Text,
Score = predictedIntent.Confidence,
Source = predictedIntent.Classifier,
Intent = predictedIntent.Label
Intent = predictedIntent.Label,
Entities = doc.Sentences[0].Entities
};
Console.WriteLine($"TextResponse: {aiResponse.Intent}, {request.SessionId}");

View file

@ -1,4 +1,5 @@
using System;
using BotSharp.Platform.Models.Entities;
using System;
using System.Collections.Generic;
using System.Text;
@ -6,12 +7,19 @@ namespace BotSharp.Platform.Models.AiResponse
{
public class AiResponse
{
public String ResolvedQuery { get; set; }
public AiResponse()
{
Entities = new List<NlpEntity>();
}
public string ResolvedQuery { get; set; }
public string Intent { get; set; }
public string Source { get; set; }
public double Score { get; set; }
public List<NlpEntity> Entities { get; set; }
}
}

View file

@ -2,7 +2,7 @@
using System.Collections.Generic;
using System.Text;
namespace BotSharp.Models.NLP
namespace BotSharp.Platform.Models.Entities
{
public class NlpEntity
{

View file

@ -7,10 +7,10 @@
"botSharpProvider": {
},
"pipe": "BotSharpTokenizer, BotSharpTagger, BotSharpCRFNer, BotSharpIntentClassifier",
"pipe": "BotSharpTokenizer, BotSharpTagger, BotSharpNER, BotSharpIntentClassifier",
"botSharpTokenizer": {
"tokenizer": "JiebaTokenizer"
"tokenizer": "TreebankTokenizer"
},
"botSharpIntentClassifier": {
@ -19,10 +19,10 @@
},
"botSharpTagger": {
"tagger": "JiebaTagger"
"tagger": "NGramTagger"
},
"botSharpCRFNer": {
"botSharpNER": {
"template": "|App_Data|CRFLite/template.en"
}
}