Import CmdHelper.Run
This commit is contained in:
parent
2927aef12e
commit
18253d6fea
|
|
@ -35,7 +35,7 @@
|
|||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="DotNetToolkit" Version="1.4.0" />
|
||||
<PackageReference Include="DotNetToolkit" Version="1.5.0" />
|
||||
<PackageReference Include="EntityFrameworkCore.BootKit" Version="1.8.0" />
|
||||
<PackageReference Include="Microsoft.AspNetCore.Cryptography.KeyDerivation" Version="2.1.1" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="11.0.2" />
|
||||
|
|
@ -46,4 +46,8 @@
|
|||
<ProjectReference Include="..\BotSharp.MachineLearning\BotSharp.MachineLearning.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Engines\CoreNlp\" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
using BotSharp.Core.Abstractions;
|
||||
using BotSharp.Core.Agents;
|
||||
using BotSharp.MachineLearning.NLP;
|
||||
using DotNetToolkit;
|
||||
using EntityFrameworkCore.BootKit;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System;
|
||||
using System.Collections;
|
||||
|
|
@ -65,47 +65,13 @@ namespace BotSharp.Core.Engines.CRFsuite
|
|||
|
||||
var algorithmDir = Path.Join(AppDomain.CurrentDomain.GetData("ContentRootPath").ToString(), "Algorithms");
|
||||
|
||||
CallCommandLine(Path.Join(algorithmDir, "crfsuite"), $"learn -m {modelFileName} {parsedTrainingDataFileName}"); // --split=3 -x
|
||||
CmdHelper.Run(Path.Join(algorithmDir, "crfsuite"), $"learn -m {modelFileName} {parsedTrainingDataFileName}"); // --split=3 -x
|
||||
|
||||
Console.WriteLine($"Saved model to {modelFileName}");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public void CallCommandLine(string fileName, string arguments)
|
||||
{
|
||||
Console.WriteLine($"{fileName} {arguments}");
|
||||
|
||||
ProcessStartInfo procStartInfo = new ProcessStartInfo(fileName);
|
||||
procStartInfo.Arguments = arguments;
|
||||
// The following commands are needed to redirect the standard output.
|
||||
// This means that it will be redirected to the Process.StandardOutput StreamReader.
|
||||
procStartInfo.RedirectStandardOutput = true;
|
||||
procStartInfo.UseShellExecute = false;
|
||||
// Do not create the black window.
|
||||
procStartInfo.CreateNoWindow = true;
|
||||
if (procStartInfo.EnvironmentVariables["OS"] == "Windows_NT")
|
||||
{
|
||||
procStartInfo.FileName = fileName;
|
||||
}
|
||||
else
|
||||
{
|
||||
procStartInfo.FileName = "sh";
|
||||
}
|
||||
|
||||
Process proc = new Process();
|
||||
proc.StartInfo = procStartInfo;
|
||||
proc.Start();
|
||||
|
||||
string output = String.Empty;
|
||||
while (!proc.HasExited)
|
||||
{
|
||||
Thread.Sleep(1);
|
||||
output = proc.StandardOutput.ReadLine();
|
||||
Console.WriteLine(output);
|
||||
}
|
||||
}
|
||||
|
||||
public List<TrainingData> Merge(List<NlpToken> tokens, List<TrainingIntentExpressionPart> entities)
|
||||
{
|
||||
List<TrainingData> trainingTuple = new List<TrainingData>();
|
||||
|
|
@ -173,10 +139,10 @@ namespace BotSharp.Core.Engines.CRFsuite
|
|||
|
||||
public TrainingData(string entity, string token, string pos, string chunk)
|
||||
{
|
||||
this.Token = token;
|
||||
this.Entity = entity;
|
||||
this.Pos = pos;
|
||||
this.Chunk = chunk;
|
||||
Token = token;
|
||||
Entity = entity;
|
||||
Pos = pos;
|
||||
Chunk = chunk;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue