Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

_clips.ClipsError: C12: could not assert

Help
Pyc Liph
2008-12-21
2013-04-25
  • Pyc Liph
    Pyc Liph
    2008-12-21

    Multiple executions of clips.Assert(...) generate an error. For example:

    >>> clips.Assert("(hello)")
    <Fact 'f-0': fact object at 0x8428ce0>
    >>> clips.Assert("(hello)")
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "build/bdist.linux-i686/egg/clips/_clips_wrap.py", line 3152, in Assert
    _clips.ClipsError: C12: could not assert
    >>> clips.Assert("(hello)")
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "build/bdist.linux-i686/egg/clips/_clips_wrap.py", line 3152, in Assert
    _clips.ClipsError: C12: could not assert

    whereas the CLIPS itself, in a similar situation, complaints with just a FALSE message:

    CLIPS> (assert (hello))
    <Fact-0>
    CLIPS> (assert (hello))
    FALSE
    CLIPS> (assert (hello))
    FALSE

    It would be good if pyclips was not crashing but was setting up a boolean false upon a repeated assert. Would something like this: clips.Assert("(hello)",boolvar) be possible? To enable checking the boolvar value, true or false, and allowing a program to keep running.
    Regards,
    Pyc.

     
    • Hi,

      the "_clips.ClipsError: C12: could not assert" exception is caused by a generic error condition returned when the underlying CLIPS API reports an error of whatever nature. So, it's not straightforward to check whether the error is caused by a repeated assertion or something else. Moreover, repeated assertions are normally considered an error even in CLIPS.

      There are two ways to bypass this behaviour, though:

      1) set clips.EngineConfig.FactDuplication = True: in this case the engine would stop complaining about fact duplication, and just reassert the same fact multiple times (this would not change the activations and firings though);

      2) surrounding the assertion in a try/catch statement.

      The latter allows more control but you'll have to check yourself for the actual nature of a possible error. Please note that, if you set clips.EngineConfig.FactDuplication to True, you'll not receive any notifications about reassertions.

      F.