Question Objects
Questions are stored as objects so that they can be implemented in different ways (and stored in other places than memory). The aim of a Question is to find a value for a given attribute. By default, Questions cause the user to be prompted on the console, but other implementations may interrogate system or network resources before resorting to interactive user requests.
Constructor
Requires an attribute name and the text of the question as arguments. The text would ordinarily be used as the prompt to the user. In non-interactive implementations, the text is useful for identifying the question in the knowledge base.
add_response
Adds a required response to the question. The desired response is provided as an argument. If any defined responses are set, then the user must respond with one of the defined responses, otherwise the question is repeated. If no responses are defined, then the user can enter anything they wish.
check
Returns 1 if the question has some responses defined, 0 otherwise.
check_attribute
Returns 1 if this question is about the supplied attribute, 0 if not.
get_text
Returns the text of the question (as set during construction)
get_responses
Returns a list of the defined responses.
get_attribute
Returns the attribute to which this question relates.
ask_question
Actually obtains an answer to the question. In the Console implementation (the default), this method prompts the user for a response, and accepts only defined responses. The user can also add in a confidence value if they wish.
This method returns the response if called in a scalar context. If called in an array context, returns a list of two elements, the response and the confidence value. Undef is returned if there was some problem obtaining a value.
