From 81cd5aa06ff3bfeb6948b660d9993b99e8994faf Mon Sep 17 00:00:00 2001 From: jackfiled Date: Sun, 26 Nov 2023 11:34:42 +0800 Subject: [PATCH] =?UTF-8?q?add:=20=E8=AF=AD=E6=B3=95=E6=B5=8B=E8=AF=954?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Katheryne/Grammar4/grammar.yaml | 22 +++++++++++++++++++ Katheryne.Tests/Katheryne/Grammar4/in.txt | 2 ++ Katheryne.Tests/Katheryne/Grammar4/out.txt | 6 +++++ .../Katheryne/KatheryneRobotTests.cs | 14 ++++++++++++ 4 files changed, 44 insertions(+) create mode 100644 Katheryne.Tests/Katheryne/Grammar4/grammar.yaml create mode 100644 Katheryne.Tests/Katheryne/Grammar4/in.txt create mode 100644 Katheryne.Tests/Katheryne/Grammar4/out.txt diff --git a/Katheryne.Tests/Katheryne/Grammar4/grammar.yaml b/Katheryne.Tests/Katheryne/Grammar4/grammar.yaml new file mode 100644 index 0000000..bb17fcf --- /dev/null +++ b/Katheryne.Tests/Katheryne/Grammar4/grammar.yaml @@ -0,0 +1,22 @@ +robotName: 啊准 +stages: + - name: start + answer: 我是啊准,一个可以查询天气的机器人。 + transformers: + - pattern: .*?天气|气温.*? + nextStageName: weather + - pattern: .*? + nextStageName: running + + - name: running + answer: 对不起,做不到。 + transformers: + - pattern: + nextStageName: start + + - name: weather + answer: 今天北京市的天气是@weather/text,气温是@weather/temp 摄氏度。 + transformers: + - pattern: + nextStageName: start +beginStageName: start \ No newline at end of file diff --git a/Katheryne.Tests/Katheryne/Grammar4/in.txt b/Katheryne.Tests/Katheryne/Grammar4/in.txt new file mode 100644 index 0000000..3ebfd5e --- /dev/null +++ b/Katheryne.Tests/Katheryne/Grammar4/in.txt @@ -0,0 +1,2 @@ +今天北京的天气怎么样? +你说的对,但是 \ No newline at end of file diff --git a/Katheryne.Tests/Katheryne/Grammar4/out.txt b/Katheryne.Tests/Katheryne/Grammar4/out.txt new file mode 100644 index 0000000..f75fdc6 --- /dev/null +++ b/Katheryne.Tests/Katheryne/Grammar4/out.txt @@ -0,0 +1,6 @@ +我是啊准,一个可以查询天气的机器人。 +今天北京市的天气是晴,气温是20 摄氏度。 +我是啊准,一个可以查询天气的机器人。 +对不起,做不到。 +我是啊准,一个可以查询天气的机器人。 +再见。 \ No newline at end of file diff --git a/Katheryne.Tests/Katheryne/KatheryneRobotTests.cs b/Katheryne.Tests/Katheryne/KatheryneRobotTests.cs index 8baf335..ffa3ee8 100644 --- a/Katheryne.Tests/Katheryne/KatheryneRobotTests.cs +++ b/Katheryne.Tests/Katheryne/KatheryneRobotTests.cs @@ -74,6 +74,20 @@ public class KatheryneRobotTests () => ValidateOutput(_katheryneChatRobotFactory.GetRobot(), file)); } + [Fact] + public void KatheryneRobotTest4() + { + IParamsModule weatherModule = new MockWeatherModule(); + _katheryneChatRobotFactory.Modules.Clear(); + _katheryneChatRobotFactory.Modules.Add(weatherModule.ModuleName, weatherModule); + + InputOutputFile file = new("Grammar4"); + StreamReader reader = new(Path.Combine(file.PrefixPath, "grammar.yaml")); + _katheryneChatRobotFactory.SetGrammar(reader.ReadToEnd()); + + ValidateOutput(_katheryneChatRobotFactory.GetRobot(), file); + } + [Fact] public void WeatherModuleTest() {