Python 使用make_实例时ClipsPy中的Clips空错误
我不熟悉剪辑和剪贴画。我正在尝试创建CLIPS类的实例 这是我在python环境(clipsPy)中定义并正确构建的类 这与预期的一样有效,但当我尝试创建此类的实例时:Python 使用make_实例时ClipsPy中的Clips空错误,python,clips,clipspy,Python,Clips,Clipspy,我不熟悉剪辑和剪贴画。我正在尝试创建CLIPS类的实例 这是我在python环境(clipsPy)中定义并正确构建的类 这与预期的一样有效,但当我尝试创建此类的实例时: new_instance = "(ent0-0 of ENTITY-CLASS (text 'Bruce Springsteen')(confidence 1.0)(type PER))" env.make_instance( new_instance ) 我得到这个空错误: 我尝试了多种形式构建新的_实
new_instance = "(ent0-0 of ENTITY-CLASS (text 'Bruce Springsteen')(confidence 1.0)(type PER))"
env.make_instance( new_instance )
我得到这个空错误:
我尝试了多种形式构建新的_实例字符串,但都没有成功:
new_instance = '(ent0-0 of ENTITY-CLASS (text "Bruce Springsteen")(confidence 1.0)(type PER))'
new_instance = "(ent0-0 of ENTITY-CLASS (text 'Bruce Springsteen') (confidence 1.0) (type PER) )"
我的语法错误在哪里?
非常感谢您的帮助空错误问题可能是由于Jupyter如何重新引导IO造成的 在IPython上,我得到:
In [1]: import clips
In [2]: env = clips.Environment()
In [3]: ENTITIES_CLASS = """
...: (defclass ENTITY-CLASS (is-a INITIAL-OBJECT)
...: (slot text (type STRING))
...: (slot confidence (type FLOAT))
...: (slot type (type SYMBOL))
...: )
...: """
...: env.build(ENTITIES_CLASS)
In [4]: env.make_instance("(ent0-0 of ENTITY-CLASS (text 'Bruce Springsteen')(confidence 1.0)(type PER))")
---------------------------------------------------------------------------
CLIPSError Traceback (most recent call last)
<ipython-input-4-92b62ecc6bed> in <module>
----> 1 env.make_instance("(ent0-0 of ENTITY-CLASS (text 'Bruce Springsteen')(confidence 1.0)(type PER))")
/usr/local/lib/python3.6/dist-packages/clips/classes.py in make_instance(self, command)
215 ist = lib.EnvMakeInstance(self._env, command.encode())
216 if ist == ffi.NULL:
--> 217 raise CLIPSError(self._env)
218
219 return Instance(self._env, ist)
CLIPSError: [INSFUN7] ('Bruce Springsteen') illegal for single-field slot text of instance [ent0-0] found in put-text primary in class ENTITY-CLASS. [PRCCODE4] Execution halted during the actions of message-handler put-text primary in class ENTITY-CLASS
我正在使用clips 0.3.3和python 3.8.6执行
In [1]: import clips
In [2]: env = clips.Environment()
In [3]: ENTITIES_CLASS = """
...: (defclass ENTITY-CLASS (is-a INITIAL-OBJECT)
...: (slot text (type STRING))
...: (slot confidence (type FLOAT))
...: (slot type (type SYMBOL))
...: )
...: """
...: env.build(ENTITIES_CLASS)
In [4]: env.make_instance("(ent0-0 of ENTITY-CLASS (text 'Bruce Springsteen')(confidence 1.0)(type PER))")
---------------------------------------------------------------------------
CLIPSError Traceback (most recent call last)
<ipython-input-4-92b62ecc6bed> in <module>
----> 1 env.make_instance("(ent0-0 of ENTITY-CLASS (text 'Bruce Springsteen')(confidence 1.0)(type PER))")
/usr/local/lib/python3.6/dist-packages/clips/classes.py in make_instance(self, command)
215 ist = lib.EnvMakeInstance(self._env, command.encode())
216 if ist == ffi.NULL:
--> 217 raise CLIPSError(self._env)
218
219 return Instance(self._env, ist)
CLIPSError: [INSFUN7] ('Bruce Springsteen') illegal for single-field slot text of instance [ent0-0] found in put-text primary in class ENTITY-CLASS. [PRCCODE4] Execution halted during the actions of message-handler put-text primary in class ENTITY-CLASS
In [4]: env.make_instance('(ent0-0 of ENTITY-CLASS (text "Bruce Springsteen")(confidence 1.0)(type PER))')
Out[4]: Instance: [ent0-0] of ENTITY-CLASS (text "Bruce Springsteen") (confidence 1.0) (type PER)