1

I am new to CLIPS and to clipsPy. I am trying to create a instance of a CLIPS class

This is the class I have defined and correctly build in my python environment (clipsPy)

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)

This works as expected, but when I try to create an instance of this class:

new_instance = "(ent0-0 of ENTITY-CLASS (text 'Bruce Springsteen')(confidence 1.0)(type PER))"
env.make_instance( new_instance )

I get this empty error:

enter image description here

I have tried multiple forms of building the new_instance string but none have work :

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) )"

Where is my syntax error? I appreciate any help

asked Oct 30, 2020 at 9:25

1 Answer 1

1

The empty error issue might be due to how Jupyter re-directs IO.

On IPython I get:

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

The problem lies within the way you represent the string 'Bruce Springstreen'. In CLIPS, STRING types are within doublequotes ".

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)
answered Oct 30, 2020 at 9:42
Sign up to request clarification or add additional context in comments.

3 Comments

I am executing < env.make_instance('(ent0-0 of ENTITY-CLASS (text "Bruce Springsteen")(confidence 1.0)(type PER))') > with clips 0.3.3 and python 3.8.6 but I still get the same blank error. Do you know why?
There's a bug in the old version of CLIPS in which if an error occurs at the API level, the error status is not re-set and any other interaction with CLIPS will still return error. It was fixed in a more recent version of CLIPS. I'll see if I can backport that fix into the CLIPSPy binary.
Thank you for your comment, we are using your package in one Uni subject of data science degree, be proud!

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.