我想使用python字典中的clipspy添加事实(字典到事实)。但到目前为止,我无法这样做。当我是 Clips 规则和事实编码的初学者时,我遇到了语法错误。如果有人可以帮助我解决此问题,请提前感谢您。以下是我的代码:
import clips
template_string = """
(deftemplate person
(slot name (type STRING))
(slot surname (type STRING)))
"""
Dict = {'name': 'John', 'surname': 'Doe' }
env = clips.Environment()
env.build(template_string)
template = env.find_template('person')
parstr = """(name%(name))(surname%(surname))"""%Dict
fact = template.assert_fact(parstr)
assert_fact = fact
env.run()
for fact in env.facts():
print(fact)
这是我遇到的错误:
Traceback (most recent call last):
File "/home/aqsa/Clips/example2.py", line 13, in <module>
parstr = """(name%(name))(surname%(surname))"""%Dict
ValueError: unsupported format character ')' (0x29) at index 12