|
@@ -16,26 +16,35 @@ namespace Yuuna
|
|
|
using Yuuna.Common.Utilities;
|
|
|
using System.Threading.Tasks;
|
|
|
using System.Reflection;
|
|
|
+ using System.Linq;
|
|
|
|
|
|
internal class EntryPoint
|
|
|
{
|
|
|
public static void Main(string[] args)
|
|
|
{
|
|
|
- var mc = new ModuleCollection();
|
|
|
-
|
|
|
- Console.WriteLine(mc._modules[mc.Names[0]].Name);
|
|
|
- Console.ReadKey();
|
|
|
-
|
|
|
- mc._modules[mc.Names[0]].Unload();
|
|
|
- Console.WriteLine(mc._modules[mc.Names[0]].Name);
|
|
|
- Console.ReadKey();
|
|
|
-
|
|
|
- mc._modules[mc.Names[0]].Reload();
|
|
|
- Console.WriteLine(mc._modules[mc.Names[0]].Name);
|
|
|
- Console.ReadKey();
|
|
|
- //Send("打開門");
|
|
|
+ //var mc = ModuleManager.Instance;
|
|
|
+ //foreach (var m in mc.Modules)
|
|
|
+ //{
|
|
|
+ // Console.WriteLine(m.Name);
|
|
|
+ //}
|
|
|
+ //Console.WriteLine("----");
|
|
|
+ //Console.ReadKey();
|
|
|
+ //mc.UnloadAll();
|
|
|
+ //foreach (var m in mc.Modules)
|
|
|
+ //{
|
|
|
+ // Console.WriteLine(m.Name);
|
|
|
+ //}
|
|
|
+ //Console.WriteLine("----");
|
|
|
+ //Console.ReadKey();
|
|
|
+ //mc.ReloadAll();
|
|
|
+ //foreach (var m in mc.Modules)
|
|
|
+ //{
|
|
|
+ // Console.WriteLine(m.Name);
|
|
|
+ //}
|
|
|
+
|
|
|
+ Send("打開門");
|
|
|
return;
|
|
|
-
|
|
|
+
|
|
|
Send("開燈");
|
|
|
try
|
|
|
{
|
|
@@ -74,7 +83,7 @@ namespace Yuuna
|
|
|
public static void Send(string text)
|
|
|
{
|
|
|
var segmenter = new JiebaTextSegmenter() as ITextSegmenter;
|
|
|
- var allPlugins = new ModuleBase[] { /*new Fake()*/ };
|
|
|
+ var allPlugins = ModuleManager.Instance.Modules;
|
|
|
foreach (var item in allPlugins)
|
|
|
{
|
|
|
item.Initialize(segmenter, new GroupManager());
|
|
@@ -86,7 +95,7 @@ namespace Yuuna
|
|
|
Console.WriteLine($"來自分詞器 {segmenter.Name} 的分詞結果: [ {string.Join(", ", cutted)} ]");
|
|
|
|
|
|
IStrategy plan = new DefaultStrategy();
|
|
|
- var alternative = plan.FindBest(allPlugins, cutted);
|
|
|
+ var alternative = plan.FindBest(allPlugins.Select(x=>x.PatternSet).ToArray(), cutted);
|
|
|
switch (alternative.Status)
|
|
|
{
|
|
|
case Status.Invalid:
|
|
@@ -94,15 +103,20 @@ namespace Yuuna
|
|
|
break;
|
|
|
case Status.Optimal:
|
|
|
alternative.Matches[0].Pattern.Owner.Patterns.TryGet(alternative.Matches[0].Pattern, out var bag);
|
|
|
- bag.Invoke(alternative.Matches[0]);
|
|
|
+ var r = bag.Invoke(alternative.Matches[0]);
|
|
|
+ Console.WriteLine(r.Mood + " | " + r.Message);
|
|
|
break;
|
|
|
case Status.Closest:
|
|
|
+ Console.WriteLine("closest");
|
|
|
break;
|
|
|
case Status.Proposition:
|
|
|
+ Console.WriteLine("proposition");
|
|
|
break;
|
|
|
case Status.Paradox:
|
|
|
+ Console.WriteLine("paradox");
|
|
|
break;
|
|
|
case Status.NoModuleInstalled:
|
|
|
+ Console.WriteLine("noModuleInstalled");
|
|
|
break;
|
|
|
default:
|
|
|
break;
|