0

I have a course assessment to create a simple Knowledge-Based System in CLIPS. I have created an ontology via Protege, exported the Classes and Instances to a .clp format and everything loads. I have an idea of what rules and templates to use, but I don't know how to access the pre-generated instances & classes from the files. I don't think it would be appropriate to hardcode them again since I have them ready for use.

Here's a chunk of my Classes file and Instances file respectively:

Classes:

; Tue Feb 03 14:37:58 EET 2015
; 
;+ (version "3.5")
;+ (build "Build 663")


(defclass %3ACLIPS_TOP_LEVEL_SLOT_CLASS "Fake class to save top-level slot information"
    (is-a USER)
    (role abstract)
    (single-slot title
        (type STRING)
;+      (cardinality 1 1)
        (create-accessor read-write))
    (single-slot purchased_by
        (type INSTANCE)
;+      (allowed-classes Customer)
;+      (cardinality 0 1)
        (create-accessor read-write))
    (multislot number_of_pages
        (type INTEGER)
        (range 0 3000)
        (create-accessor read-write))
    (single-slot type
        (type SYMBOL)
        (allowed-values Fiction Non-Fiction)
;+      (cardinality 0 1)
        (create-accessor read-write))
    (single-slot filmed
        (type SYMBOL)
        (allowed-values Yes No)
;+      (cardinality 0 1)
        (create-accessor read-write))
    (single-slot name_
        (type STRING)
;+      (cardinality 1 1)
        (create-accessor read-write))
    (single-slot publishing_year
        (type INTEGER)
        (range 1440 2015)
;+      (cardinality 0 1)
        (create-accessor read-write))

Instances:

; Tue Feb 03 14:37:58 EET 2015
; 
;+ (version "3.5")
;+ (build "Build 663")

(definstances myInstances

([Bookstore_Class0] of  Horror

    (author "Stephen King")
    (filmed Yes)
    (number_of_pages 497)
    (publishing_year 1977)
    (title "The Shining")
    (type Fiction))

([Bookstore_Class10000] of  Drama

    (author "Vladimir Nabokov")
    (filmed Yes)
    (number_of_pages 300)
    (publishing_year 1955)
    (title "Lolita")
    (type Fiction))

([Bookstore_Class10001] of  Drama

    (author "Gabriel Garcia Marquez")
    (filmed No)
    (number_of_pages 432)
    (publishing_year 1970)
    (title "One Hundred Years of Solitude")
    (type Fiction))

([Bookstore_Class10002] of  Horror

    (author "Stephen King")
    (filmed No)
    (number_of_pages 531)
    (publishing_year 2013)
    (title "Doctor Sleep")
    (type Fiction))

The hierarchy goes three levels deep and everything loads, I just don't know how to use the generated data.

P.S. The actual files are far longer and I don't think it would be necessary to post them.

  • It's not clear what you mean by "how to access pre-generated instances and classes" and "I just don't know how to use the generated data". You access class and instances by their name. What specifically are you trying to do? – Gary Riley Feb 03 '15 at 20:22
  • I want to load them and use them and I don't know how to achieve that. Either load them as facts or in a single variable –  Feb 03 '15 at 20:29
  • 1
    If the definstances is loaded, all you need to do is issue a (reset) command to create the instances. It would be easiest to simply write rules that pattern match on the instances, but if you want to convert the defclasses to deftemplates and the instances to facts there are a number of introspection functions you could use in writing code to perform a conversion. – Gary Riley Feb 03 '15 at 22:02
  • When i type `(reset)` the interpreter spews out the following `[INSMNGR13] Slot name does not exist in instance`. I understand what this means but the problem is that I don't find anything suspicious with that particular instance, everything seems fine. Is that some kind of a syntax error, or an error generated while exporting the files in CLIPS format from Protege, or something else? –  Feb 03 '15 at 22:08
  • 1
    Difficult to say. I've never used Protege, but the most likely explanation is that there's a syntax error in the generated code. – Gary Riley Feb 03 '15 at 23:07
  • Thank you, your comments have been very helpful. –  Feb 03 '15 at 23:09

0 Answers0