AI-ExpertSystem-Simple

 view release on metacpan or  search on metacpan

bin/consult  view on Meta::CPAN

103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
.text tag config is_information -foreground grey
 
# A nice hello message
 
status "Welcome to the Tcl/Tk expert system shell"
status ""
status "This program is used to call the command line"
status "expert system called simpleshell and allows"
status "you to interact with it via the gui"
status ""
status "First select a knowledgebase to load with the Load button"
status "Then start a consultation with the Run button"
status "You can rerun the consultation as many times as you like"
status ""
status "The Save button allows you to save the contents of the"
status "session to a file"
status ""
status "The \"Display 'information' messages\" check box is used"
status "to turn the grey information messages on and off. The "
status "information messages tell you what the expert system is"
status "up to and can be quite voluminous"

bin/consult  view on Meta::CPAN

141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
        status "Load a file..."
 
        set types {{{XML Files} {.xml}} {{All Files} *}}
 
        global filename
        set filename [tk_getOpenFile -filetypes $types -title "Load a knowledge base"]
 
        if {$filename != ""} {
                load_a_file $filename
        } {
                status "No file was selected"
        }
}
 
proc load_a_file {filename} {
        if {[file isfile $filename] == 0} {
                status "The file you selected is not really a file"
        } elseif {[file readable $filename] == 0} {
                status "The file you selected in not readable"
        } else {
                .run  configure -state normal
                status "Loading file $filename"
                status "The next step is to Run it..."
 
                wm title . [append newtitle "Simple Inference Engine: " [file tail $filename]]
        }
}
 
proc do_run {} {

bin/consult  view on Meta::CPAN

216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
proc do_save {} {
        status "Save the output..."
 
        set types { {{Text Files} {.txt} } {{All Files} * } }
 
        set filename [tk_getSaveFile -filetypes $types -title "Save the results of a run" -initialfile "Results.txt"]
 
        if {$filename != ""} {
                if {[file isfile $filename] == 0} {
                        status "The file you selected is not really a file"
                } elseif {[file writeable $filename] == 0} {
                        status "The file you selected in not writeable"
                } else {
                        status "Saving the output to $filename"
                        set handle [open $filename "w"]
                        puts $handle [.text get 0.1 end]
                        close $handle
                }
        } {
                status "No file was selected"
        }
}
 
################################################################################
# Utility functions
################################################################################
 
proc status      {text} { mymessage $text is_status }
proc question    {text} { mymessage $text is_question }
proc response    {text} { mymessage $text is_response }

lib/AI/ExpertSystem/Simple.pm  view on Meta::CPAN

462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
=back
 
=item get_question( )
 
If the process( ) method has returned "question" then this method will return the question to ask the user
and a list of valid responses.
 
=item answer( VALUE )
 
The user has been presented with the question from the get_question( ) method along with a set of
valid responses and the users selection is returned by this method.
 
=item get_answer( )
 
If the process( ) method has returned "finished" then the answer to the users query will be
returned by this method.
 
=item log( )
 
Returns a list of the actions undertaken so far and clears the log.

lib/AI/ExpertSystem/Simple/Knowledge.pm  view on Meta::CPAN

166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
=item get_setter( )
 
Returns the current setter of the attribute.
 
=item is_value_set( )
 
Returns true if the value of the attribute is set or false if not.
 
=item set_question( QUESTION, RESPONSES )
 
Allows a question to ask of the user to set the value of the attribute. QUESTION is the text that will be displayed to the user and RESPONSES is a list of valid responses that the user may select from.
 
=item get_question( )
 
Returns the QUESTION and list of valid RESPONSES for the attribute.
 
=item has_question( )
 
Returns true if the attribute has a question to ask the user if the VALUE of the attribute has not already been set.
 
=item name( )



( run in 0.243 second using v1.01-cache-2.11-cpan-87723dcf8b7 )