Reasoning with SWRL Rules Creates Empty Nodes?

When I run a reasoning query, using an ontology with SWRL rules defined, it returns what I want as well as these strange blank nodes.

{
        "@type": ["http://www.w3.org/2002/07/owl#Thing"],
        "@id": "_:genid-edb550b395e8486196bb847e7db92cce-node1d0qfg8p3x21161"
    }

Is this expected behavior? Is there something I can add to the query to prevent this from happening?

Can you share the query, rules and data?

These look like anonymous nodes generated by the reasoner. You could try: FILTER (!isBlank(?x))

Tracy M. Safran
Programmer Analyst - EVS support
Frederick National Laboratory for Cancer Research

Thank you both for your swift replies!
In reply to zachary.whitley, the rules are all variations of this rule, defining different "contains" and "containedBy" relationships:

Collection(?c), CredentialAccess(?ca), Discovery(?d), Exfiltration(?e), LateralMovement(?lm), Effects(?es), NetworkEffects(?nes), RemoteServiceEffects(?rses), Consequence(?ctf) -> contains(?ctf, ?c), contains(?ctf, ?ca), contains(?ctf, ?d), contains(?ctf, ?e), contains(?ctf, ?lm), contains(?ctf, ?es), contains(?ctf, ?nes), contains(?ctf, ?rses), containedBy(?c, ?ctf), containedBy(?ca, ?ctf), containedBy(?d, ?ctf), containedBy(?e, ?ctf), containedBy(?lm, ?ctf), containedBy(?es, ?ctf), containedBy(?nes, ?ctf), containedBy(?rses, ?ctf)

The query just queries over everything in the graph:

construct {
    ?s ?p ?o
} where {
        graph ?g {
            ?s ?p ?o
    }
}

The data being reasoned over is just a set of 33 JSON objects, here is a sample of a few:

[
    {
        "@type": ["tag:darklight:attack#AdversaryOpsec"],
        "@id": "tag:darklight:attack#AdversaryOpsec"
    },
    {
        "@type": ["tag:darklight:attack#BuildCapabilities"],
        "@id": "tag:darklight:attack#BuildCapabilities"
    },
    {
        "@type": ["tag:darklight:attack#Collection"],
        "@id": "tag:darklight:attack#Collection"
    }]

In reply to safrant, I will try this filter out! Thanks for the idea!

Safrant, your recommendation works! It removes the weird empty nodes. I am still curious as to why this happens in the first place though. Do you know why, or have a link to some place that does?
Thanks for all your help!

I've been avoiding JSON-LD for as long as possible so my knowledge of the syntax isn't great but isn't your data saying that you have some instances identified by the same url as its type?

<tag:darklight:attack#Collection> a <tag:darklight:attack#Collection>

If that's the case than it's punning and that might be were the generated blank node is coming from.

I also believe that that reasoner doesn't always play well with unbounded queries like that because it can't determine what type of predicate it is.

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