samples/basic/tutorial/products.kb and products_1.mdb
Some knowledgebases need to reason over data that can be stored in an internal data table. To do this, KnowledgeWright provides data_table objects and the find() function. Data_Tables are generally more flexible than external database tables because each column can contain different types of data, i.e. strings and numbers. Data_Tables are also more powerful because entries can consist of formulas and object names. In this case, the KnowledgeWright reasoning engine is called to determine a value before the find() function returns a value.
To illustrate this, we will query a data_table to determine the upgrade price for a product. First we need to build a knowledgebase with a data_table to contain the pricing information and a fact whose value is the result of a find() function that queries the data_table:
old_product version new_product price "ap1pc" "4.0" "ap1pc" 0 "ap1pc" "4.1" "ap1pc" 0 "ap1pc" "5.0" "ap1pc" 0 "ap1pc" "4.0" "apxpc" 2500 "ap1pc" "4.1" "apxpc" 2500 "ap1pc" "5.0" "apxpc" 2500 "apxpc" "4.0" "apxpc" 1500 "apxpc" "4.1" "apxpc" 1000 "apxpc" "5.0" "apxpc" 0
Our knowledgebase asks the three questions, old_product, old_version and new_product used in the find() function above. Using the answers to those questions, the fact price gets the price. The price is displayed in a short document.
rule_text display_text ap1pc Amzi! Prolog + Logic Server, Personal Edition apxpc Amzi! Prolog + Logic Server,
Professional Edition or Commercial License
Note, you can use the find() function anywhere any object name is allowed. You do not have to create a fact object to issue a query In this case we needed a separate fact object because the result of query is embedded in a text object.
|
|
Copyright ©1995-2006 Amzi!
inc. All Rights Reserved. Privacy Policy.
Amzi!, KnowledgeWright and WebLS are registered
trademarks and Adventure in Prolog, Logic Server, Logic Explorer, Adventure
in Prolog and Subscription Plus are trademarks of Amzi! inc.