AI-ExpertSystem-Simple
view release on metacpan or search on metacpan
bin/consult view on Meta::CPAN
103104105106107108109110111112113114115116117118119120121122123.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
141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
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
216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246proc 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
462463464465466467468469470471472473474475476477478479480481=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
166167168169170171172173174175176177178179180181182183184185186=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 )