How to create an SWRL to create new individual

Hello. I have read this, and I have installed Stardog but I don’t know how apply this.

I need next:

IF {
?p a :Person .
?q a :Person .
?p hasFriend ?q.
BIND (UUID() AS ?friendly) .
?friendly a :Friendly .
?friendly isARelationWith ?q;
isARelationOfPerson ?p.

How I need to write it on stardog to run it? Is in SPARQL console?



To use a Stardog Rule, simply insert the following RDF into the database (turtle, in this example):

@prefix rule: <tag:stardog:api:rule:> .

[] a rule:SPARQLRule ;
  rule:content """
    PREFIX :<urn:test:>
      IF {...}
      THEN {...}""" .

Once the database contains that information, running a query with reasoning enabled will use that rule as needed.

1 Like

You might want to go over the “Remarks” section under “New Individuals with SWRL”. Specifically #2 or you might be surprised with the results from your rule.

Due to normalization, rules with more than one atom in the head are broken up into several rules.


Thank you!!! It’s works :slight_smile:

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.