How to query with sameAs

HI, im curious about how Stardog pick one of the entity has relation owl:sameAs.
Like this:
A owl:sameAs B,
A:age 50
B:text "ABC"

search age 50 it only return one URI A. I read docs Stardog will pick randomly sameAs entities.
But i dont know how to do that by SPARQL query.
Any idea that i can simulate this feature of Stardog by SPARQL query ???

I’m not quite sure what you’re asking here. You’d like to simulate the sames feature using a SPARQL query? Are you trying to do sameAs reasoning without prematerialization?

That brings up an interesting question. Does the reasoner make sameAs inferences or are they deferred to the sameAs feature so there aren’t conflicts. If it does defer you probably can’t do it but if it will produce sameAs inferences I guess you can do some sort of subquery to get the individuals and limit to 1 to get a canonical url and then join from there. I don’t think it would be guaranteed to produce stable IRIs though. Performance would be much worse than the sameas feature though.

Someone else can probably give a more definitive answer.

I’d like to simulate the same feature using a SPARQL query but dont know how.
Because with normal SPARQL only return list of result some thing like that:
search by age 50
result => A B C ....
In this: A sameAs B
i dont know how to eliminate the duplicate result like B to return only A C...

you could try this in two steps. first determine the class for each individual:

select ?individual ?age (spa:set(?sameAs) as ?class) {
  ?individual :sameAs ?sameAs . # requires reflexivity
  ?individual :age ?age
} group by ?individual ?age

next use the result of that and select a single individual per class:

select ?class ?age (sample(?individual) as ?representative) {
  # inner subquery
} group by ?class ?age

you could further wrap this with another select to drop ?class as it's no longer needed

Thanks for answering. That leads me to another interesting question whether we can count all the number of sameAs entity by SPARQL to help me know more about my data.

Like this:
URI NumberOfSameAs
A 2
C 1

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