我正在试验PyClips,我想将其与 Python 紧密集成,以便当激活规则时,它会调用 python 函数。
\n\n这是我到目前为止所拥有的:
\n\nimport clips\n\ndef addf(a, b):\n return a + b\n\nclips.RegisterPythonFunction(addf)\n\nclips.Build("""\n(defrule duck\n (animal-is duck)\n =>\n (assert (sound-is quack))\n (printout t "it\xe2\x80\x99s a duck" crlf))\n (python-call addf 40 2 )\n""")\nRun Code Online (Sandbox Code Playgroud)\n\n然而,当我断言“动物是鸭子”这一事实时,我的 python 函数没有被调用:
\n\n>>> clips.Assert("(animal-is duck)")\n<Fact \'f-0\': fact object at 0x7fe4cb323720>\n>>> clips.Run()\n0\nRun Code Online (Sandbox Code Playgroud)\n\n我究竟做错了什么?
\n