diff --git a/BotSharp.Core/AgentStorage/AgentStorageInRedis.cs b/BotSharp.Core/AgentStorage/AgentStorageInRedis.cs index dc7ee711..7fb03532 100644 --- a/BotSharp.Core/AgentStorage/AgentStorageInRedis.cs +++ b/BotSharp.Core/AgentStorage/AgentStorageInRedis.cs @@ -85,7 +85,7 @@ namespace BotSharp.Core.AgentStorage { var keys = csredis.Keys($"{prefix}*"); - csredis.Remove(keys.Select(x => x.Substring(prefix.Length)).ToArray()); + csredis.Del(keys.Select(x => x.Substring(prefix.Length)).ToArray()); return keys.Count(); } diff --git a/BotSharp.Core/BotSharp.Core.csproj b/BotSharp.Core/BotSharp.Core.csproj index 63225fc6..1332e91a 100644 --- a/BotSharp.Core/BotSharp.Core.csproj +++ b/BotSharp.Core/BotSharp.Core.csproj @@ -20,14 +20,14 @@ If you feel that this project is helpful to you, please Star on the project, we will be very grateful. MIT https://github.com/Oceania2018/BotSharp - NLU, Chatbot, Bot, AI Bot, Artificial Intelligence, RPA - 1.6.0 + NLU, Chatbot, Bot, AI Bot, Artificial Intelligence + 1.7.1 Monthly Update. -Integrated with Articulate UI. +Integrated with Tencent Wechat. If you feel that this project is helpful to you, please Star on the project, we will be very grateful. Since 2018 Haiping Chen https://github.com/Oceania2018/BotSharp - 1.6.0.0 + 1.7.1.0 https://raw.githubusercontent.com/Oceania2018/BotSharp/master/BotSharp.WebHost/wwwroot/images/BotSharp.png https://github.com/Oceania2018/BotSharp/blob/master/LICENSE @@ -75,7 +75,7 @@ If you feel that this project is helpful to you, please Star on the project, we - + diff --git a/BotSharp.Core/Engines/BotPredictor.cs b/BotSharp.Core/Engines/BotPredictor.cs index f4a29339..ec9c6f7d 100644 --- a/BotSharp.Core/Engines/BotPredictor.cs +++ b/BotSharp.Core/Engines/BotPredictor.cs @@ -72,13 +72,13 @@ namespace BotSharp.Core.Engines await pipe.Predict(agent, data, pipeModel); } - Console.WriteLine($"Prediction result:", Color.Green); + /*Console.WriteLine($"Prediction result:", Color.Green); Console.WriteLine(JsonConvert.SerializeObject(data, new JsonSerializerSettings { Formatting = Formatting.Indented, NullValueHandling = NullValueHandling.Ignore, ContractResolver = new CamelCasePropertyNamesContractResolver() - })); + }));*/ return data; } diff --git a/BotSharp.Core/Engines/BotSharp/BotSharpIntentClassifier.cs b/BotSharp.Core/Engines/BotSharp/BotSharpIntentClassifier.cs index 4c83f663..3b4caf5a 100644 --- a/BotSharp.Core/Engines/BotSharp/BotSharpIntentClassifier.cs +++ b/BotSharp.Core/Engines/BotSharp/BotSharpIntentClassifier.cs @@ -56,7 +56,7 @@ namespace BotSharp.Core.Engines.BotSharp { Classifier = "BotSharpIntentClassifier", Label = result.First().Item1, - Confidence = (decimal)result.First().Item2 + Confidence = result.First().Item2 }; return true; diff --git a/BotSharp.Core/Engines/TextClassificationResult.cs b/BotSharp.Core/Engines/TextClassificationResult.cs index 2da49b71..a415ec83 100644 --- a/BotSharp.Core/Engines/TextClassificationResult.cs +++ b/BotSharp.Core/Engines/TextClassificationResult.cs @@ -10,6 +10,6 @@ namespace BotSharp.Core.Engines public String Label { get; set; } - public Decimal Confidence { get; set; } + public double Confidence { get; set; } } } diff --git a/BotSharp.Core/Modules/ModuleOptions.cs b/BotSharp.Core/Modules/ModuleOptions.cs index ef9b1587..a043f1d9 100644 --- a/BotSharp.Core/Modules/ModuleOptions.cs +++ b/BotSharp.Core/Modules/ModuleOptions.cs @@ -9,6 +9,11 @@ namespace BotSharp.Core.Modules /// public class ModuleOptions { + public ModuleOptions() + { + Path = String.Empty; + } + /// /// Module name /// diff --git a/BotSharp.Core/Modules/ModulesOptions.cs b/BotSharp.Core/Modules/ModulesOptions.cs index bb92f94c..3748e504 100644 --- a/BotSharp.Core/Modules/ModulesOptions.cs +++ b/BotSharp.Core/Modules/ModulesOptions.cs @@ -9,10 +9,10 @@ namespace BotSharp.Core.Modules /// public class ModulesOptions { - /// - /// Module base directory - /// - public String ModuleBasePath { get; set; } + public ModulesOptions() + { + Modules = new List(); + } /// /// List of module configurations. diff --git a/BotSharp.Core/Modules/PlatformModuleAssembyLoader.cs b/BotSharp.Core/Modules/PlatformModuleAssembyLoader.cs index 3ab13098..5c390dab 100644 --- a/BotSharp.Core/Modules/PlatformModuleAssembyLoader.cs +++ b/BotSharp.Core/Modules/PlatformModuleAssembyLoader.cs @@ -22,8 +22,11 @@ namespace Microsoft.Extensions.DependencyInjection Console.WriteLine(); options.Modules.ForEach(module => { - - var dllPath = Path.Combine(options.ModuleBasePath, module.Path, $"{module.Type}.dll"); + if (String.IsNullOrEmpty(module.Path)) + { + module.Path = AppContext.BaseDirectory; + } + var dllPath = Path.Combine(module.Path, $"{module.Type}.dll"); if (File.Exists(dllPath)) { Assembly library = AssemblyLoadContext.Default.LoadFromAssemblyPath(dllPath); @@ -36,15 +39,14 @@ namespace Microsoft.Extensions.DependencyInjection new Formatter(dllPath, Color.Yellow) }; Console.WriteLineFormatted("Loaded {0} module, type: {1}, path: {2}", Color.White, settings); + Console.WriteLine(); } else { - Console.WriteLine($"Can't load {module.Type} assembly from {dllPath}."); + Console.WriteFormatted($"Can't load {module.Type} assembly from {dllPath}.", Color.Red); + Console.WriteLine(); } - }); - - Console.WriteLine(); } } } diff --git a/BotSharp.NLP/BotSharp.NLP.csproj b/BotSharp.NLP/BotSharp.NLP.csproj index 26678b03..99ce811d 100644 --- a/BotSharp.NLP/BotSharp.NLP.csproj +++ b/BotSharp.NLP/BotSharp.NLP.csproj @@ -4,7 +4,7 @@ netstandard2.0 AnyCPU;x64 true - 0.4.0 + 0.5.0 Botsharp.NLP is a set of tools for building C# programs to work with human language data. It can be used in common tasks like POS, NER and text classification in the NLP or NLU field. BotSharp.NLP has implemented below machine learning algorithms: @@ -42,6 +42,10 @@ Naive Bayes Classifier false + + DEBUG;TRACE + + diff --git a/BotSharp.NLP/Classify/SVMClassifier.cs b/BotSharp.NLP/Classify/SVMClassifier.cs index 9c5d8220..330a006a 100644 --- a/BotSharp.NLP/Classify/SVMClassifier.cs +++ b/BotSharp.NLP/Classify/SVMClassifier.cs @@ -131,8 +131,8 @@ namespace BotSharp.NLP.Classify public List GetData(List sentences, ClassifyOptions options) { - //var extractor = new CountFeatureExtractor(); - var extractor = new Word2VecFeatureExtractor(); + var extractor = new CountFeatureExtractor(); + //var extractor = new Word2VecFeatureExtractor(); extractor.ModelFile = options.Word2VecFilePath; extractor.Sentences = sentences; if(features != null) diff --git a/BotSharp.NLP/Tokenize/Token.cs b/BotSharp.NLP/Tokenize/Token.cs index 4013fe52..f19ef2ee 100644 --- a/BotSharp.NLP/Tokenize/Token.cs +++ b/BotSharp.NLP/Tokenize/Token.cs @@ -46,7 +46,7 @@ namespace BotSharp.NLP.Tokenize { get { - return Regex.IsMatch(Text, @"^[a-zA-Z]+$"); + return Regex.IsMatch(Text, @"^[a-zA-Z]+|[\u4e00-\u9fa5]+$"); } } diff --git a/BotSharp.Platform.Abstraction/BotSharp.Platform.Abstraction.csproj b/BotSharp.Platform.Abstraction/BotSharp.Platform.Abstraction.csproj index 58913343..1766d5fd 100644 --- a/BotSharp.Platform.Abstraction/BotSharp.Platform.Abstraction.csproj +++ b/BotSharp.Platform.Abstraction/BotSharp.Platform.Abstraction.csproj @@ -3,7 +3,8 @@ netstandard2.0 true - 0.1.0 + 0.2.0 + https://github.com/Oceania2018/BotSharp diff --git a/BotSharp.Platform.Abstraction/IPlatformBuilder.cs b/BotSharp.Platform.Abstraction/IPlatformBuilder.cs index f9f7cb9e..0a58b276 100644 --- a/BotSharp.Platform.Abstraction/IPlatformBuilder.cs +++ b/BotSharp.Platform.Abstraction/IPlatformBuilder.cs @@ -47,6 +47,6 @@ namespace BotSharp.Platform.Abstraction Task Train(TAgent agent, TrainingCorpus corpus, BotTrainOptions options); - Task TextRequest(AiRequest request); + Task TextRequest(AiRequest request); } } diff --git a/BotSharp.Platform.Models/BotSharp.Platform.Models.csproj b/BotSharp.Platform.Models/BotSharp.Platform.Models.csproj index 715df064..c940c0e2 100644 --- a/BotSharp.Platform.Models/BotSharp.Platform.Models.csproj +++ b/BotSharp.Platform.Models/BotSharp.Platform.Models.csproj @@ -3,7 +3,8 @@ netstandard2.0 true - 0.1.0 + 0.2.0 + https://github.com/Oceania2018/BotSharp diff --git a/BotSharp.Platform.Models/MachineLearning/AgentMlConfig.cs b/BotSharp.Platform.Models/MachineLearning/AgentMlConfig.cs index 13ab2740..9e3900a9 100644 --- a/BotSharp.Platform.Models/MachineLearning/AgentMlConfig.cs +++ b/BotSharp.Platform.Models/MachineLearning/AgentMlConfig.cs @@ -13,7 +13,7 @@ namespace BotSharp.Platform.Models.MachineLearning public String AgentId { get; set; } [Required] - public decimal MinConfidence { get; set; } + public double MinConfidence { get; set; } [Required] [MaxLength(64)] diff --git a/BotSharp.WebHost/Settings/BotSharpNLU.json b/BotSharp.WebHost/Settings/BotSharpNLU.json index e40068cf..ba0c4bca 100644 --- a/BotSharp.WebHost/Settings/BotSharpNLU.json +++ b/BotSharp.WebHost/Settings/BotSharpNLU.json @@ -10,7 +10,7 @@ "pipe": "BotSharpTokenizer, BotSharpTagger, BotSharpCRFNer, BotSharpIntentClassifier", "botSharpTokenizer": { - "tokenizer": "TreebankTokenizer" + "tokenizer": "JiebaTokenizer" }, "botSharpIntentClassifier": { @@ -19,18 +19,11 @@ }, "botSharpTagger": { - "tagger": "NGramTagger" + "tagger": "JiebaTagger" }, "botSharpCRFNer": { "template": "|App_Data|CRFLite/template.en" - }, - - "witAiEntityRecognizer": { - "url": "https://api.wit.ai", - "resource": "message", - "serverAccessToken": "SERVER_ACCESS_TOKEN", - "version": "20180811" } } } diff --git a/BotSharp.WebHost/Settings/DialogflowAi.json b/BotSharp.WebHost/Settings/DialogflowAi.json index dba3a169..3e97eb18 100644 --- a/BotSharp.WebHost/Settings/DialogflowAi.json +++ b/BotSharp.WebHost/Settings/DialogflowAi.json @@ -2,6 +2,6 @@ // if you want to override platform setting, please set corresponding value, otherwise you don't need this section. "dialogflowAi": { "botEngine": "BotSharpNLU", - "agentStorage": "AgentStorageInMemory" + "agentStorage": "AgentStorageInRedis" } } diff --git a/BotSharp.WebHost/Settings/app.json b/BotSharp.WebHost/Settings/app.json index 82cc335e..dcfbd6bf 100644 --- a/BotSharp.WebHost/Settings/app.json +++ b/BotSharp.WebHost/Settings/app.json @@ -8,27 +8,22 @@ "dataDir": "D:\\Projects\\BotSharp\\Data" }, - "moduleBasePath": "C:\\Users\\haipi\\Documents\\Projects", "modules": [ { "Name": "DialogflowAi", - "Type": "BotSharp.Platform.Dialogflow", - "Path": "botsharp-dialogflow\\BotSharp.Platform.Dialogflow\\bin\\Debug\\netcoreapp2.1" - } /*, + "Type": "BotSharp.Platform.Dialogflow" + }, { "Name": "WeixinChannel", - "Type": "BotSharp.Channel.Weixin", - "Path": "botsharp-channel-weixin\\BotSharp.Channel.Weixin\\bin\\Debug\\netcoreapp2.1" - }, + "Type": "BotSharp.Channel.Weixin" + }/*, { "Name": "RasaAi", "Type": "BotSharp.Platform.Rasa", - "Path": "botsharp-rasa\\BotSharp.Platform.Rasa\\bin\\Debug\\netcoreapp2.1" }, { "Name": "ArticulateAi", "Type": "BotSharp.Platform.Articulate", - "Path": "botsharp-articulate\\BotSharp.Platform.Articulate\\bin\\Debug\\netcoreapp2.1" }*/ ] }