"""Example code""" import expert # download expert.py import rules1 # download rules1.py # This function determines if an answer has been found. # (i.e. the system is in a 'final' state) # It is run everytime a matched rule fires. def is_final(facts): """Return true when 'final_flag' is set""" return facts.get('final_flag') # Initialize the expert engine e = expert.Expert() # Initialize rules in module 'rules1' e.rules_init(rules1) # Initial facts e.facts.set('initial', True) # The 'is_final' function is used to determine if an answer has been found. # The system stops when 'is_final' returns True if e.get_answer(is_final): print "is_final() returned True, that means an answer has been found." print print "> Facts" e.facts.show() print print "> Log" e.logger.show() else: print "No answer found! This is probably a bad thing."