Let's say I have lots of ontologies with synonyms.
<term>
<word>cat</word>
<synonyms>
<synonym>feline</synonym>
</synonyms>
</term>
<term>
<word>feline></word>
<synonyms>
<synonym>kitty</synonym>
<synonyms>
</term>
How can I write a SPARQL query such that I can give it the word cat
and it will give me all the synonyms of cat
as well as all the synonyms of the synonyms of cat
I don't know if there's a way to do this recursively or if you have to specify each level.
To use SPARQL, you would need to represent this data as triples. Someone who knows ontologies better would come up with better IRIs, but something like (as represented inside MarkLogic):
<triple>
<subject>http://marklogic.com/scope#cat</subject>
<predicate>http://marklogic.com/term</predicate>
<object>cat</object>
</triple>
<triple>
<subject>http://marklogic.com/scope#cat</subject>
<predicate>http://marklogic.com/synonym</predicate>
<object>feline</object>
</triple>
<triple>
<subject>http://marklogic.com/scope#cat</subject>
<predicate>http://marklogic.com/synonym</predicate>
<object>kitty</object>
</triple>
Note that the meanings of my triples do not exactly match what you had, but hopefully close enough to make the point. With triples, you could then do a SPARQL query like:
select ?term
where {
<http://marklogic.com/scope#cat> <http://marklogic.com/synonym> ?term
}
which should return "feline" and "kitty".