1use isu::*;
2use std::collections::{HashMap, HashSet};
3
4fn main() {
7 let preds0 = HashSet::from(["return".to_string(), "need-visa".to_string()]);
9
10 let preds1 = HashMap::from([
12 ("price".to_string(), "int".to_string()),
13 ("how".to_string(), "means".to_string()),
14 ("dest_city".to_string(), "city".to_string()),
15 ("depart_city".to_string(), "city".to_string()),
16 ("depart_day".to_string(), "day".to_string()),
17 ("class".to_string(), "flight_class".to_string()),
18 ("return_day".to_string(), "day".to_string()),
19 ]);
20
21 let sorts = HashMap::from([
23 (
24 "means".to_string(),
25 HashSet::from(["plane".to_string(), "train".to_string()]),
26 ),
27 (
28 "city".to_string(),
29 HashSet::from(["paris".to_string(), "london".to_string(), "berlin".to_string()]),
30 ),
31 (
32 "day".to_string(),
33 HashSet::from(["today".to_string(), "tomorrow".to_string()]),
34 ),
35 (
36 "flight_class".to_string(),
37 HashSet::from(["first".to_string(), "second".to_string()]),
38 ),
39 ]);
40
41 let mut domain = Domain::new(preds0, preds1, sorts);
43
44 let plan = vec![
46 "Findout('?x.how(x)')".to_string(),
47 "Findout('?x.dest_city(x)')".to_string(),
48 "Findout('?x.depart_city(x)')".to_string(),
49 "Findout('?x.depart_day(x)')".to_string(),
50 "Findout('?x.class(x)')".to_string(),
51 "Findout('?return()')".to_string(),
52 "If('?return()', ['Findout(?x.return_day(x))'], [])".to_string(),
53 "ConsultDB('?x.price(x)')".to_string(),
54 ];
55 domain.add_plan(Question::new("?x.price(x)").unwrap(), plan);
56
57 let mut database = TravelDB::new();
59 database.add_entry(HashMap::from([
60 ("price".to_string(), "232".to_string()),
61 ("from".to_string(), "berlin".to_string()),
62 ("to".to_string(), "paris".to_string()),
63 ("day".to_string(), "today".to_string()),
64 ]));
65 database.add_entry(HashMap::from([
66 ("price".to_string(), "345".to_string()),
67 ("from".to_string(), "paris".to_string()),
68 ("to".to_string(), "london".to_string()),
69 ("day".to_string(), "today".to_string()),
70 ]));
71
72 let mut grammar = SimpleGenGrammar::new();
74 grammar.add_form("Ask('?x.how(x)')", "How do you want to travel?");
75 grammar.add_form("Ask('?x.dest_city(x)')", "Where do you want to go?");
76 grammar.add_form("Ask('?x.depart_city(x)')", "From where are you leaving?");
77 grammar.add_form("Ask('?x.depart_day(x)')", "When do you want to leave?");
78 grammar.add_form("Ask('?x.return_day(x)')", "When do you want to return?");
79 grammar.add_form("Ask('?x.class(x)')", "First or second class?");
80 grammar.add_form("Ask('?return()')", "Do you want a return ticket?");
81
82 let demo_inputs = vec![
84 "I want to go to paris".to_string(),
85 "train".to_string(),
86 "berlin".to_string(),
87 "today".to_string(),
88 "first".to_string(),
89 "yes".to_string(),
90 "tomorrow".to_string(),
91 "quit".to_string(),
92 ];
93
94 let demo_handler = isu::DemoInputHandler::new(demo_inputs);
96 let mut ibis = isu::IBISController::with_input_handler(domain, database, grammar, Box::new(demo_handler));
97
98 println!("Starting IBIS Travel Dialogue System (Demo Mode)...");
99 println!("Simulating user interaction with predefined inputs:");
100 println!();
101
102 ibis.run();
104}