2 Replies Latest reply on Apr 25, 2008 9:06 PM by alwu-Oracle

    Creating URIs in rules

    user625573
      A question regarding the RDF rule support in Oracle 11g:

      When creating custom rules, is there a way to infer the existence of
      new individuals, by constructing URIs as an expression involving some of
      the values in antecedents and using this in the consequents?

      As an example, could I do something like the following contrived example
      rule:

      ('familyRule',
      '(?person1 :relatedTo ?person2)
      (?person1 :surName ?surname1)
      (?person2 :surName ?surname2)', -- antecedents
      NULL,
      '({'http://test.com#surName_' + ?surname1} rdf:type :Family)') -- consequent

      or maybe of the form:

      ('familyRule',
      '(?person1 :relatedTo ?person2)
      (?person1 :surName ?surname1)
      (?person2 :surName ?surname2)', -- antecedents
      NULL,
      '?family = expr('http://test#surName_' + ?surname1)', -- new variable
      '(?family rdf:type :Family)
      (?person1 :memberOf ?family)
      (?person2 :memberOf ?family)') -- consequents

      In other words, can the consequents refer to variables that are not in
      the antecedents, and not constants, but created from an expression.
      This is extremely useful in real-world rule sets. For some examples of such support, see the 'uriConcat' and 'makeInstance' functions in Jena rules.

      Thanks,
      Jan
        • 1. Re: Creating URIs in rules
          bjg-Oracle
          Hello Jan,

          Although I don't know what you've asked. But perhaps you can help me in a somewhat similar situation.

          I am trying with a rule like this:
          insert into mdsys.rdfr_RuleBase1 values
          ( 'Rule1' ,
          '( ?instance rdf:type :ClassA)
          (?instance :has_PropertyA ?a) (?a :hasValue ?c)',

          'REGEXP_like(c, ''Open'')' ,

          '(?instance :has_PropertyB ?b) (?b :hasValue "HIGH")' ,

          sdo_rdf_aliases(...)
          )
          );
          The purpose behind this rule is something like:

          If I query for all instaces for ClassA that have the value of the property has_PropertyA as Open, then it should also give me all the instances that have a value for the property has_PropertyB as HIGH.

          But when I query using this rule I donot get the required results.
          The query is:
          select j ID, c propertyA, d propertyB from table

          ( sdo_rdf_match ( '( ?instance rdf:type :ClassA)
          (?instance :has_PropertyA ?a) (?a v2:hasValue ?c)
          (?instance :has_ID ?i) (?i :hasValue ?j)
          (?instance :has_PropertyB ?b) (?b :hasValue ?d)',

          sdo_rdf_models( 'Model1' ) ,

          sdo_rdf_rulebases(‘RuleBase1’) ,

          sdo_rdf_aliases(…),

          'c=''Open'''
          )
          );
          But, I do not get all the extra instances that have propertyB = HIGH. I only get some extra instances wherein propertyA = Open and propertyB = HIGH. The query result leaves many instances where propertyB=HIGH, but the propertyA has many other values.

          Can you help me come out of the dark?

          Thanks
          Bhaskar
          • 2. Re: Creating URIs in rules
            alwu-Oracle
            Oracle 11g does not support generation of new URIs via inference.

            However, you can use query + insert to simulate that.