0

Just started to work with clipspy-0.3.3 in Python 3.8.3.

When extracting facts, an inconsistency was encountered in the .facts() enumerator.

The code below

import clips

env = clips.Environment()

env.assert_string("(value 1)")
env.assert_string("(value 2)")
env.assert_string("(value 3)")
env.assert_string("(value 4)")
env.assert_string("(value 5)")
env.assert_string("(value 6)")
env.assert_string("(value 7)")
env.assert_string("(value 8)")
env.assert_string("(value 9)")
env.assert_string("(value 10)")

for fact in env.facts():
    print(fact)

Produces result

(initial-fact)
(value 1)
(value 2)
(value 3)
(value 4)
(value 5)
(value 6)
(value 7)
(value 8)
(value 9)
f-10    (value 10)

from which one can see an inconsistency in which

  • facts with number less than 10, the preceding f-1 is dropped away from the fact string, and,
  • facts with number equal or greater than 10, the preceding f-10 is not dropped away from the fact string.

Even if the above inconsistency can be solved with regular expression substitution, as follow

import re

for fact in env.facts():
    print(re.sub(r'^[^(]*',r'',str(fact)))

would be nice if the string representation of facts would be returned consistently by the .facts() enumerator in clispy package.

noxdafox
  • 14,439
  • 4
  • 33
  • 45
Heikki
  • 2,214
  • 19
  • 34

1 Answers1

1

This looks like a bug in clipspy, I would suggest you to open an issue on its repository.

noxdafox
  • 14,439
  • 4
  • 33
  • 45
  • Did it. The [content of the issue](https://github.com/noxdafox/clipspy/issues/38) is practically same. – Heikki Sep 23 '20 at 11:39