2017-12-30 20:26:35 +00:00
|
|
|
|
using Bot.Rasa.Entities;
|
|
|
|
|
|
using Bot.Rasa.Models;
|
|
|
|
|
|
using EntityFrameworkCore.BootKit;
|
2017-12-18 13:31:15 +00:00
|
|
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using System.Linq;
|
|
|
|
|
|
using System.Text;
|
|
|
|
|
|
|
|
|
|
|
|
namespace Bot.Rasa.Agents
|
|
|
|
|
|
{
|
|
|
|
|
|
public static class AgentExtension
|
|
|
|
|
|
{
|
2017-12-30 20:26:35 +00:00
|
|
|
|
public static String CreateEntity(this Agent agent, EntityType entity, Database dc)
|
|
|
|
|
|
{
|
|
|
|
|
|
return entity.Id;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static RasaTrainingData GrabCorpus(this Agent agent, Database dc)
|
2017-12-18 13:31:15 +00:00
|
|
|
|
{
|
|
|
|
|
|
var trainingData = new RasaTrainingData
|
|
|
|
|
|
{
|
|
|
|
|
|
UserSays = new List<UserSay>()
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
var intents = dc.Intent().Include(x => x.Expressions).ToList();
|
|
|
|
|
|
|
|
|
|
|
|
intents.ForEach(intent => {
|
|
|
|
|
|
|
|
|
|
|
|
trainingData.UserSays.AddRange(intent.Expressions
|
|
|
|
|
|
.Select(exp => new UserSay
|
|
|
|
|
|
{
|
|
|
|
|
|
Intent = intent.Name,
|
|
|
|
|
|
Text = exp.Text
|
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
return trainingData;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|