So I have been working on an expert system using clipspy recently. I have already came out with the rule file and load it back in using the clipspy. Some my question is, how do I extract the printout content in the rule file using the clipspy library because I have to make a simple GUI for the system. The GUI will be like pop up the question and prompt the user to fill in the answer until the ends of the system.
Example rule file:
(defrule BR_Service
(service BR)
=>
(printout t crlf "Would you like to book or return a car? ("B" for book / "R" for return)" crlf)
(assert (br (upcase(read))))
)
(defrule Book_Service
(br B)
=>
(printout t crlf "Are you a first-time user? (Y/N)" crlf)
(assert (b (upcase(read))))
)
(defrule Premium_Member
(b N)
=>
(printout t crlf "Are you a Premium status member? (Y/N)" crlf)
(assert (p (upcase(read))))
)
Python script with clipspy:
import clips
env = clips.Environment()
rule_file = 'rule_file.CLP'
env.load(rule_file)
print("What kind of service needed? ('BR' for book/return car / 'EM' for emergency)")
input = input()
env.assert_string("(service {})".format(input))
env.run()