add: 语法测试4
This commit is contained in:
parent
79962727ba
commit
81cd5aa06f
22
Katheryne.Tests/Katheryne/Grammar4/grammar.yaml
Normal file
22
Katheryne.Tests/Katheryne/Grammar4/grammar.yaml
Normal file
|
@ -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
|
2
Katheryne.Tests/Katheryne/Grammar4/in.txt
Normal file
2
Katheryne.Tests/Katheryne/Grammar4/in.txt
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
今天北京的天气怎么样?
|
||||||
|
你说的对,但是
|
6
Katheryne.Tests/Katheryne/Grammar4/out.txt
Normal file
6
Katheryne.Tests/Katheryne/Grammar4/out.txt
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
我是啊准,一个可以查询天气的机器人。
|
||||||
|
今天北京市的天气是晴,气温是20 摄氏度。
|
||||||
|
我是啊准,一个可以查询天气的机器人。
|
||||||
|
对不起,做不到。
|
||||||
|
我是啊准,一个可以查询天气的机器人。
|
||||||
|
再见。
|
|
@ -74,6 +74,20 @@ public class KatheryneRobotTests
|
||||||
() => ValidateOutput(_katheryneChatRobotFactory.GetRobot(), file));
|
() => 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]
|
[Fact]
|
||||||
public void WeatherModuleTest()
|
public void WeatherModuleTest()
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue
Block a user