diff --git a/.gitignore b/.gitignore
index 493c262d..cae01f15 100644
--- a/.gitignore
+++ b/.gitignore
@@ -293,3 +293,4 @@ __pycache__/
/BotSharp.UnitTest/App_Data/DbInitializer/Agents
/BotSharp.UnitTest/App_Data/BotSharp.db
/BotSharp.WebHost/App_Data/BotSharp.db
+/BotSharp.UI
diff --git a/BotSharp.Core/Engines/Sebis/AgentImporterInSebis.cs b/BotSharp.Core/Engines/Sebis/AgentImporterInSebis.cs
index 2d59476b..32afb413 100644
--- a/BotSharp.Core/Engines/Sebis/AgentImporterInSebis.cs
+++ b/BotSharp.Core/Engines/Sebis/AgentImporterInSebis.cs
@@ -16,7 +16,7 @@ using Newtonsoft.Json.Linq;
namespace BotSharp.Core.Engines
{
///
- /// Import agent from Dialogflow
+ /// Import Sebis NLU benchmark corpus
///
public class AgentImporterInSebis : IAgentImporter
{
@@ -58,48 +58,74 @@ namespace BotSharp.Core.Engines
agent.Intents = sentences.Select(x => x.Name).Distinct().Select(x => new Intent{Name = x}).ToList();
agent.Intents.ForEach(intent => {
- intent.UserSays = new List();
-
- var userSays = sentences.Where(x => x.Name == intent.Name).ToList();
-
- userSays.ForEach(say =>
- {
- var expression = new IntentExpression();
-
- expression.Data = new List();
-
- for(int index = 0; index < say.Entities.Count; index++)
- {
-
- }
-
- intent.UserSays.Add(expression);
- });
+ ImportIntentUserSays(agent, intent, sentences);
});
}
- private Intent ImportIntentUserSays(Agent agent, Intent intent, string fileName)
+ private void ImportIntentUserSays(Agent agent, Intent intent, List sentences)
{
- // void id confict
- intent.Id = Guid.NewGuid().ToString();
- intent.Name = intent.Name.Replace("/", "_");
- // load user expressions
+ intent.UserSays = new List();
- string expressionFileName = fileName.Replace(intent.Name, $"{intent.Name}_usersays_{agent.Language}");
- if (File.Exists(expressionFileName))
+ var userSays = sentences.Where(x => x.Name == intent.Name).ToList();
+
+ userSays.ForEach(say =>
{
- string expressionJson = File.ReadAllText($"{expressionFileName}");
- intent.UserSays = JsonConvert.DeserializeObject>(expressionJson);
- }
+ var expression = new IntentExpression();
- return null;
+ say.Entities = say.Entities.OrderBy(x => x.Start).ToList();
+
+ int pos = 0;
+ say.Entities.ForEach(x =>
+ {
+ ConvertWordPosToCharPos(say.Text, x, pos);
+ pos = x.End;
+ });
+
+ expression.Data = new List();
+
+ pos = 0;
+ for (int entityIdx = 0; entityIdx < say.Entities.Count; entityIdx++)
+ {
+ var entity = say.Entities[entityIdx];
+
+ // previous
+ expression.Data.Add(new IntentExpressionPart
+ {
+ Text = say.Text.Substring(pos, entity.Start - pos)
+ });
+
+ // self
+ expression.Data.Add(new IntentExpressionPart
+ {
+ Alias = entity.Entity,
+ Meta = entity.Entity,
+ Text = say.Text.Substring(entity.Start, entity.Value.Length)
+ });
+
+ pos = entity.End + 1;
+
+ if (pos < say.Text.Length && entityIdx == say.Entities.Count - 1)
+ {
+ // end
+ expression.Data.Add(new IntentExpressionPart
+ {
+ Text = say.Text.Substring(pos)
+ });
+ }
+ }
+ });
+ }
+
+ private void ConvertWordPosToCharPos(string text, SebisIntentExpressionPart entity, int start)
+ {
+ entity.Start = text.IndexOf(entity.Value, start);
+ entity.End = entity.Start + entity.Value.Length;
}
public void LoadBuildinEntities(Agent agent, string agentDir)
{
agent.Intents.ForEach(intent =>
{
-
if (intent.UserSays != null)
{
intent.UserSays.ForEach(us =>
diff --git a/BotSharp.Core/Engines/Sebis/SebisAgent.cs b/BotSharp.Core/Engines/Sebis/SebisAgent.cs
index 002516c7..580f5c97 100644
--- a/BotSharp.Core/Engines/Sebis/SebisAgent.cs
+++ b/BotSharp.Core/Engines/Sebis/SebisAgent.cs
@@ -10,9 +10,9 @@ namespace BotSharp.Core.Adapters.Sebis
{
public String Id { get; set; }
public String Name { get; set; }
- [JsonProperty("desc")]
+
public String Description { get; set; }
- [JsonProperty("lang")]
+
public String Language { get; set; }
public List Sentences { get; set; }
diff --git a/BotSharp.WebHost/App_Data/DbInitializer/Accounts/users.json b/BotSharp.WebHost/App_Data/DbInitializer/Accounts/users.json
index d723a700..9b7fabcb 100644
--- a/BotSharp.WebHost/App_Data/DbInitializer/Accounts/users.json
+++ b/BotSharp.WebHost/App_Data/DbInitializer/Accounts/users.json
@@ -1,6 +1,6 @@
[
{
- "userName": "support@botsharp.io",
+ "userName": "botsharp",
"email": "support@botsharp.io",
"firstName": "Support",
"lastName": "Botsharp",
diff --git a/BotSharp.WebHost/App_Data/DbInitializer/Agents/Sebis/Airport/corpus.json b/BotSharp.WebHost/App_Data/DbInitializer/Agents/Sebis/Airport/corpus.json
index f9617fbb..5f605388 100644
--- a/BotSharp.WebHost/App_Data/DbInitializer/Agents/Sebis/Airport/corpus.json
+++ b/BotSharp.WebHost/App_Data/DbInitializer/Agents/Sebis/Airport/corpus.json
@@ -394,13 +394,13 @@
{
"entity": "StationStart",
"start": 6,
- "stop": 10,
+ "stop": 8,
"text": "kurt-eisner-straße"
},
{
"entity": "StationDest",
- "start": 12,
- "stop": 13,
+ "start": 10,
+ "stop": 11,
"text": "garching forschungszentrum"
}
]
@@ -586,13 +586,13 @@
{
"entity": "StationStart",
"start": 5,
- "stop": 9,
+ "stop": 5,
"text": "kurt-eisner-straße"
},
{
"entity": "StationDest",
- "start": 11,
- "stop": 12,
+ "start": 7,
+ "stop": 8,
"text": "garching forschungszentrum"
}
]
diff --git a/BotSharp.WebHost/wwwroot/images/BotSharp.min.png b/BotSharp.WebHost/wwwroot/images/BotSharp.min.png
new file mode 100644
index 00000000..8572d1f8
Binary files /dev/null and b/BotSharp.WebHost/wwwroot/images/BotSharp.min.png differ
diff --git a/BotSharp.WebHost/wwwroot/images/BotSharp.min.psd b/BotSharp.WebHost/wwwroot/images/BotSharp.min.psd
new file mode 100644
index 00000000..81e005f8
Binary files /dev/null and b/BotSharp.WebHost/wwwroot/images/BotSharp.min.psd differ