| |||||||||||||
|
How to use COjDA - Complete OO jDREW APICreating a COjDA Object in JavaThere are six different ways to create a COjDA object. For complete details about COjDA readers are refered to the JavaDoc for COjDA. One way to create a COjDA api object is to use a RDFS taxonomy and POSL knowledge base. For example you have a file called Types.rdfs that contains the following:<rdf:RDFAlso you have a file called KB.posl that contains the following: discount(?customer, ?product, percent5) :- premium(?customer), regular(?product). base_price(customer->[sex->male!?]; vehicle->? : Car; price->650 : Integer). base_price(customer->[sex->male!?]; vehicle->? : Van; price->725 : Integer). You can create a COjDA api object by using the following Code:
File types = new File("Types.rdfs");
File kb = new File("KB.posl");
COjDA api = new COjDA(COjDA.POSL, COjDA.RDFS, kb, types);
Once you have created the COjDA object you can then execute KB queries and Taxonomy queries. For a full list of a methods avaible to COjDA readers are refered to the JavaDoc of COjDA.
An example KB query would be the following:
base_price(customer->[sex->male; name->"John Doe"; age->28]; vehicle->vehicle:ToyotaCorolla; price->?money:Integer). To execute this query using COjDA the following code would be used: String kbPOSLQuery = "base_price(customer->[sex->male; name->\"John Doe\"; age->28]; vehicle->vehicle:ToyotaCorolla; price->?money:Integer)."; String result = api.issueKBQuery_POSL(kbPOSLQuery);The resulting RuleML answer expression would look as follows:
To execute a Taxonomy Query the following code could be used:
String taxonomyPOSLQuery = "subsumesPlus(?X, MiniVan)"; String resultTaxonomy = api.issueTaxonomyQuery_POSL(taxonomyPOSLQuery);The resulting RuleML answer expression would look as follows:
For more information about RuleML answer expressions and how to query the taxonomy, readers are referred to the documents of Taxonomy Querying and the Taxonomy Querying API.
|
Last Updated: By: |
|||||||||||