Merge branch 'master' of https://github.com/Oceania2018/BotSharp
This commit is contained in:
commit
3019a3a17a
|
|
@ -13,18 +13,23 @@
|
|||
<Authors>Haiping Chen</Authors>
|
||||
<Company />
|
||||
<Product>BotSharp.Core</Product>
|
||||
<Description>Upgrade .Net Core to 2.1</Description>
|
||||
<Description>Open source chatbot platform written in C#. Ready for enterprise.</Description>
|
||||
<RepositoryType>MIT</RepositoryType>
|
||||
<RepositoryUrl>https://github.com/Oceania2018/BotSharp</RepositoryUrl>
|
||||
<PackageTags>NLU, Chatbot, Bot, AI Bot</PackageTags>
|
||||
<Version>1.2.0</Version>
|
||||
<PackageReleaseNotes>Support Rasa NLU 0.12.x</PackageReleaseNotes>
|
||||
<Version>1.3.0</Version>
|
||||
<PackageReleaseNotes>Add NLP pipeline. Support training model by input context.</PackageReleaseNotes>
|
||||
<Copyright>Since 2018 Haiping Chen</Copyright>
|
||||
<PackageProjectUrl>https://github.com/Oceania2018/BotSharp</PackageProjectUrl>
|
||||
<AssemblyVersion>1.3.0.0</AssemblyVersion>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||
<DefineConstants>TRACE;DEBUG;MODEL_PER_CONTEXTS</DefineConstants>
|
||||
<DefineConstants>TRACE;MODEL_PER_CONTEXTS;NETCOREAPP;NETCOREAPP2_1</DefineConstants>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
|
||||
<DefineConstants>TRACE;MODEL_PER_CONTEXTS</DefineConstants>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
|||
|
|
@ -36,6 +36,8 @@ namespace BotSharp.Core.Engines
|
|||
#else
|
||||
var result = CallRasa(rasa.agent.Id, request.Query.First(), rasa.agent.Id);
|
||||
#endif
|
||||
result.Content.Log();
|
||||
|
||||
RasaResponse response = result.Data;
|
||||
aiResponse.Id = Guid.NewGuid().ToString();
|
||||
aiResponse.Lang = rasa.agent.Language;
|
||||
|
|
|
|||
44
BotSharp.Core/Engines/SpaCy/SpaCyEntityRecognizer.cs
Normal file
44
BotSharp.Core/Engines/SpaCy/SpaCyEntityRecognizer.cs
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
using BotSharp.Core.Abstractions;
|
||||
using BotSharp.Core.Agents;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using RestSharp;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace BotSharp.Core.Engines.SpaCy
|
||||
{
|
||||
public class SpaCyEntityRecognizer : INlpPipeline
|
||||
{
|
||||
List<String> entitiesInTrainingSet = new List<string>();
|
||||
public IConfiguration Configuration { get; set; }
|
||||
|
||||
public bool Process(Agent agent, JObject data)
|
||||
{
|
||||
String modelPath = "./entity_rec_output";
|
||||
String newModelName = "test";
|
||||
String outputDir = "./entity_rec_output2";
|
||||
int iterTimes = 20;
|
||||
|
||||
agent.Entities.ForEach(entity => entitiesInTrainingSet.Add(entity.Name));
|
||||
var client = new RestClient(Configuration.GetSection("SpaCyProvider:Url").Value);
|
||||
var request = new RestRequest("entityrecognizer", Method.POST);
|
||||
request.RequestFormat = DataFormat.Json;
|
||||
|
||||
request.AddParameter("application/json", JsonConvert.SerializeObject(new { ModelPath = modelPath, NewModelName = newModelName, OutputDir = outputDir, IterTimes = iterTimes, EntitiesInTrainingSet = entitiesInTrainingSet }), ParameterType.RequestBody);
|
||||
|
||||
var response = client.Execute<Result>(request);
|
||||
|
||||
data["EntityModelTrained"] = response.Data.EntityModelTrained;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public class Result
|
||||
{
|
||||
public Boolean EntityModelTrained { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
@ -7,6 +7,7 @@ using Microsoft.EntityFrameworkCore;
|
|||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
|
|
@ -50,7 +51,7 @@ namespace BotSharp.UnitTest
|
|||
var rasa = new RasaAi(dc);
|
||||
var importer = new AgentImporterInDialogflow();
|
||||
|
||||
string dataDir = $"{Database.ContentRootPath}\\App_Data\\DbInitializer\\Agents\\";
|
||||
string dataDir = $"{Database.ContentRootPath}App_Data{Path.DirectorySeparatorChar}DbInitializer{Path.DirectorySeparatorChar}Agents{Path.DirectorySeparatorChar}";
|
||||
var agent = rasa.RestoreAgent(importer, BOT_NAME, dataDir);
|
||||
agent.Id = BOT_ID;
|
||||
agent.ClientAccessToken = BOT_CLIENT_TOKEN;
|
||||
|
|
|
|||
|
|
@ -9,6 +9,6 @@
|
|||
"SpaCyProvider": {
|
||||
"Url": "http://10.2.21.200:5005"
|
||||
},
|
||||
"Pipe": "SpaCyTokenizer, SpacyFeaturizer, SpaCyEntitizer, SpaCyTextCategorizer"
|
||||
"Pipe": "SpaCyTokenizer, SpacyFeaturizer, SpaCyEntitizer, SpaCyTextCategorizer, SpaCyEntityRecognizer"
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue