-
Notifications
You must be signed in to change notification settings - Fork 0
/
checkinbot.py
67 lines (53 loc) · 1.99 KB
/
checkinbot.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/usr/bin/env python3
#coding: utf-8
"""
checkinbot is a chatbot which mission is to help users book a flight.
This program can understand basic informations about a flight such as
the departure date and location and the arrival date and location.
It then give the user corresponding flights according to a textfile
database.
Homepage and documentation: https://github.com/Vincent-Fabioux/checkinbot
"""
__authors__ = "Vincent Fabioux, Nicolas Montoro, Olivier Nappert"
__version__ = "0.1-dev"
__contact__ = "Vincent Fabioux <[email protected]>"
import argparse
from src.normalize import normalize, normalizeDebug
from src.extract import extract, extractDebug
from src.guess import guess, guessDebug
from src.answer import answer, answerDebug
def main():
# Command line arguments recovery for debug mode
parser = argparse.ArgumentParser()
parser.add_argument("-d", "--debug", type=str,
choices = ["normalize", "extract", "guess", "answer"],
help = "enter debug mode for one of the user input analyse steps")
args = parser.parse_args()
if args.debug: # Launch debug mode if specified
if args.debug == "normalize":
normalizeDebug()
elif args.debug == "extract":
extractDebug()
elif args.debug == "guess":
guessDebug()
elif args.debug == "answer":
answerDebug()
else: # Launch program as usual
checkinbot()
# Main program function
def checkinbot():
data = {"dep_loc": None, "dep_date": None, "dep_hour": None,
"arr_loc": None, "arr_date": None, "arr_hour": None,
"special": None}
print("Hi! My name is Checkinbot, I am here to help you book a flight\n"
+ "from any capital city in western Europe to any capital city in\n"
+ "the same zone.\n"
+ "To start things off, could you tell me what is your travel plan?")
run = True
while(run):
userInput = input("> ")
modified = guess(extract(normalize(userInput)), data)
run = answer(data)
# Calling of main function
if __name__ == "__main__":
main()