Previous topic  Top  Next topic  Print this Topic
 

Rule Management

 

If you want an easy way to

Find rules by module and rule identifier
Retrieve rule by rule identifier
Search for rules containing a ObjectLogic term (concept/instance) in the head or body
Search for rules containing some text
Add and remove rules

then you can use the rule management features of OntoBroker. Explanations and explanation rules are described in the Explanations chapter.

Find rules & retrieve rule text

Use the built-ins _ruleByID/3 and _queryByID/3 to retrieve the rule text for a given rule ID and module. If you only need the rule IDs of a given module, you can use the built-ins _isRule/2 and _isQuery/2.

Example

"Give me the rule text of all rules in all modules"

?- $module(?M) AND _ruleByID(?M,?ID,?TXT).

Search for rules containing a ObjectLogic term

The built-ins _ruleContainsTerm/4, _queryContainsTerm/3 can be used to retrieve all rules and queries respectively containing an F-logic term in rule head or body.

Example

"Give me the rule IDs of all rules in module 'm1' containing the concept 'Person' in the rule body"

?- _ruleContainsTerm("m1","Person","_false",?ID).

Full-text search support for rules

The rule text and the rule metadata are full-text indexed. The built-in queryIndex/10 can be used to search text in rules. Add "+type:u" to the lucene query text to restrict the query to rules or "+type:q" to restrict to queries. The SearchHelper class of the OntoBroker API also supports this functionality.

Commands for adding and removing rules

Commands for ObjectLogic:

insert rule { ruleText ...}

delete rule { ruleText ... }

delete rule ruleID1,ruleID2,...

Example:

"Add facts q(1,a) and q(2,b) to module m1, and exchange rule r1 with following rule: @{r1} p(?X) :- q(?X,?)."

:- module m1.

insert {q(1,a),q(2,b)}

delete rule r1.

insert rule {@{r1} p(?X) :- q(?X,?).}