Python 使用make_实例时ClipsPy中的Clips空错误

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 ) 我得到这个空错误: 我尝试了多种形式构建新的_实

我不熟悉剪辑和剪贴画。我正在尝试创建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))'
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执行,但我仍然得到相同的空白错误。你知道为什么吗?旧版本的CLIPS中有一个bug,如果在API级别发生错误,错误状态不会被重新设置,与CLIPS的任何其他交互仍将返回错误。它是在最近版本的剪辑中修复的。我会看看我是否可以把这个补丁移植到CLIPSPy二进制文件中。谢谢你的评论,我们正在使用你的软件包作为数据科学学位的一个统一主题,感到自豪吧!
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)