-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexpert_system.py
executable file
·50 lines (44 loc) · 2 KB
/
expert_system.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
#!/usr/bin/env python3.6
# **************************************************************************** #
# #
# ::: :::::::: #
# expert_system.py :+: :+: :+: #
# +:+ +:+ +:+ #
# By: dhojt <dhojt@student.42.fr> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2018/07/12 00:09:39 by dhojt #+# #+# #
# Updated: 2018/07/17 21:30:28 by dhojt ### ########.fr #
# #
# **************************************************************************** #
import sys
import argparse
sys.path.extend(["./src/", "./src/parser/", "./src/inference_engine/"])
from Config import Config
from Parser import Parser
from Lexer import Lexer
from ParsingError import ParsingError
from InferenceEngine import InferenceEngine
def parse_arguments():
parser = argparse.ArgumentParser(description='A propositional calculus expert system.')
parser.add_argument("-c", "--config", metavar="file", help="file with symbols values")
parser.add_argument("-v", "--verbose", action="store_true",
help="displays investigation steps of the inference engine")
parser.add_argument("-o", "--output", action="store_true",
help="displays original input but prints facts in correct colour")
parser.add_argument("file", help="file with rules and facts")
if len(sys.argv) == 1:
parser.print_help()
parser.exit()
return (parser.parse_args())
def main():
args = parse_arguments()
try:
config = Config(args.config, args)
lexer = Lexer(config, args.file)
parser = Parser(config)
except ParsingError as ex:
exit(ex)
engine = InferenceEngine(config)
engine.induce()
if __name__== "__main__":
main()