Re: How to save facts or rules into a files?

1,683 views
Skip to first unread message

anders....@gmail.com

unread,
Jun 11, 2013, 4:39:04 AM6/11/13
to clip...@googlegroups.com
Hello,

I'm a CLIPS beginner as well but i would say you can use the "save" command to save templates, rules and functions. To save facts you would use the "save-facts" command.

CLIPS> (save-facts "factsfile.clp")
TRUE
CLIPS> (save-facts "rulesfile.clp")
TRUE

Den torsdagen den 6:e juni 2013 kl. 11:36:46 UTC+3 skrev WangPeng:
Hi everyone,
        I have download two samples in this website https://clips.codeplex.com/releases/view/66878, it seems that the clips environment can only load facts and rules from some files, what can I do if I want to save some facts or rules into a file?  Please someone give me some  instructions. Sorry for my poor English.
        Thank you!

anders....@gmail.com

unread,
Jun 13, 2013, 3:50:13 AM6/13/13
to clip...@googlegroups.com
Sorry, the example went wrong, it should be:

CLIPS> (save-facts "factsfile.clp")
TRUE
CLIPS> (save "rulesfile.clp")
TRUE

Cristiane Lana

unread,
Jan 8, 2014, 2:26:37 PM1/8/14
to clip...@googlegroups.com


Em quinta-feira, 6 de junho de 2013 05h36min46s UTC-3, WangPeng escreveu:
Hi everyone,
        I have download two samples in this website https://clips.codeplex.com/releases/view/66878, it seems that the clips environment can only load facts and rules from some files, what can I do if I want to save some facts or rules into a file?  Please someone give me some  instructions. Sorry for my poor English.
        Thank you!Hello,

I used (save-facts "factsfile.clp") and is returning me it was not found to save-facts function. Can to assist please?

Cristiane Lana

unread,
Jan 13, 2014, 5:48:18 PM1/13/14
to clip...@googlegroups.com

I'm using this rule to save. and created the file normally, but is empty. I've tried the 3 forms below and have not worked.

(defrule Extracting::ruleSaveBI1 "This rule save the softgoals in BI1"


( declare (salience 80))

( softgoalElement

( sgId ?idSg )

( sgQualityAttribute ?QualityAttributeSg)

( sgSujectObject ?SubjectObjectSg))

(startWriteInFile)

=>

(printout basesoftgoal "ID" ?idSg "<[TYPE]QUALITY ATTRIBUTE>" ?QualityAttributeSg "<[TOPIC]SUBJECT/OBJECT LAL>" ?SubjectObjectSg crlf)

;;(save-facts "softgoalFile.clp")

;;( savefacts "softgoalFile.clp" visible deftemplate basesoftgoal)

)



CLIPS Support

unread,
Jan 18, 2014, 3:22:09 PM1/18/14
to clip...@googlegroups.com
I don't see anything obviously wrong with the code fragment you posted. This small test worked for me:

CLIPS> (defmodule MAIN))
CLIPS> (defrule MAIN::start => (focus Extracting))
CLIPS> (defmodule Extracting)
CLIPS> 
(deftemplate Extracting::basesoftgoal (slot value))
CLIPS> 
(deffacts Extracting::initial
   (basesoftgoal (value eat))
   (basesoftgoal (value sleep))
   (basesoftgoal (value work)))
CLIPS> 
(defrule Extracting::ruleSaveBl1
   =>
   (save-facts "softgoalFile.fct"))
CLIPS> (reset)
CLIPS> (run)
CLIPS> 
Reply all
Reply to author
Forward
0 new messages