How to create an SWRL to create new individual

Hello. I have read this Home | Stardog Documentation Latest, 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) .
}
THEN {
?friendly a :Friendly .
?friendly isARelationWith ?q;
isARelationOfPerson ?p.
}

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

Thanks!

Hi,

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.

2 Likes

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.