BotSharp/BotSharp.Core/Engines/SpaCy/SpaCyEntitizer.cs

43 lines
1.2 KiB
C#
Raw Normal View History

2018-06-13 22:17:35 +00:00
using System;
using System.Collections.Generic;
using System.Text;
2018-08-08 21:39:00 +00:00
using System.Threading.Tasks;
2018-06-14 15:03:01 +00:00
using BotSharp.Core.Abstractions;
2018-06-15 17:39:24 +00:00
using BotSharp.Core.Agents;
2018-06-13 22:17:35 +00:00
using BotSharp.Core.Models;
2018-08-22 15:45:50 +00:00
using BotSharp.Models.NLP;
2018-06-13 22:17:35 +00:00
using Microsoft.Extensions.Configuration;
2018-06-14 15:03:01 +00:00
using Newtonsoft.Json.Linq;
2018-06-13 22:17:35 +00:00
using RestSharp;
namespace BotSharp.Core.Engines.SpaCy
{
2018-06-14 15:03:01 +00:00
public class SpaCyEntitizer : INlpPipeline
2018-06-13 22:17:35 +00:00
{
public IConfiguration Configuration { get; set; }
public PipeSettings Settings { get; set; }
2018-06-13 22:17:35 +00:00
public async Task<bool> Predict(Agent agent, NlpDoc doc, PipeModel meta)
2018-08-08 21:39:00 +00:00
{
return true;
}
public async Task<bool> Train(Agent agent, NlpDoc doc, PipeModel meta)
2018-06-13 22:17:35 +00:00
{
var client = new RestClient(Configuration.GetSection("SpaCyProvider:Url").Value);
var request = new RestRequest("entitize", Method.GET);
2018-06-15 17:39:24 +00:00
request.AddParameter("text", "");
2018-06-13 22:17:35 +00:00
var response = client.Execute<Result>(request);
2018-06-15 17:39:24 +00:00
//data.Add("Entities", JToken.FromObject(response.Data.Entities));
2018-06-14 15:03:01 +00:00
return response.IsSuccessful;
2018-06-13 22:17:35 +00:00
}
public class Result
{
public List<NlpEntity> Entities { get; set; }
}
}
}