0

This is a small ontology to get the color combination and their reviews For example (red combinesWith black and hasReview "perfect Match") Is there a better way of doing this? I'm trying to query SubPropertyOf. Is it possible to do- :hasReview rdfs:subPropertyOf :combinesWith .

Thank you

PREFIX : <http://myexample#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> 
SELECT ?color ?colorcode ?coc ?review ?description
WHERE   { 
    ?color rdf:type :Color;
                  :Code  ?colorcode .
        {SELECT ?coc
    WHERE {
        ?color :combinesWith ?coc .
       //here I would to get the value of hasReview 

      :hasReview rdfs:subPropertyOf :combinesWith .
    }
} 
}
  • 1
    I don't think `subPropertyOf` means what you think it means. You seem to be looking for declaring a property that applies to a whole triple, which is not supported in RDF graphs. You will have to identify a color combination with an IRI of its own, and then link both colors, as well as the `hasReview` property, do that IRI. Also, in general, a triple pattern without any variables, like your statement `:hasReview rdfs:subPropertyOf :combinesWith .`, does not make much sense in the `WHERE` part of a SPARQL query. – O. R. Mapper Mar 08 '15 at 15:20
  • Hi Mapper please could you help me with a small example in how I can link these 2 colors and show the review? Thank you – user1539510 Mar 09 '15 at 01:09
  • Could you provide a link to your ontology so that this discussion will go easier? – Artemis Mar 09 '15 at 21:13
  • This is a link to my ontology https://www.dropbox.com/s/sirwo767d6lrkzw/colors.owl?dl=0 I've just started learning about protege and ontology. I trying to find the best way to query all colors that combine and the ones that do not with their respective review. I can make it work just for two colors using a object property, but if I have (Green combineWith Brown Red and blue and hasreview "Perfect combination", "Too dark colors") then becomes really complicated. Will be grateful with any help. Thank you – user1539510 Mar 10 '15 at 11:46

1 Answers1

0

I will first try and juxtapose how I imagine your idea of the meaning of subClassOf (feel free to correct me if my impression is wrong) and its actual meaning, and then go on to explain how you might achieve what you are looking for instead.


For your :combinesWith property

?color :combinesWith ?coc .

let's assume the following small dataset:

:red :combinesWith :yellow .
:red :combinesWith :purple .
:green :combinesWith :yellow .
:green :combinesWith :white .
:green :combinesWith :black .
:white :combinesWith :silver .
:white :combinesWith :black .
:black :combinesWith :white .

Apparently, you assume that a subproperty of a property X is a property that applies to triples whose predicate is the property X. In concrete terms, in the above dataset, you seem to think you are able to assign a review to each of those combinations, something like (pseudo-code, no valid syntax!):

{ :red :combinesWith :yellow } :hasReview "a combination of warm colors" .
{ :green :combinesWith :yellow } :hasReview "nature, sunflowers" .
{ :black :combinesWith :white } :hasReview "too much contrast for my taste" .

Actually, however, a subproperty Y of a property X can be understood in a way so that for all triples whose predicate is property Y, there is also a triple with the same subject and object whose predicate is X. Or, in a slightly different interpretation, when you're looking for triples whose predicate is X, you will find all triples whose predicate is X and all triples whose predicate is Y. It works in an analogous way to subclasses.

So, for the above dataset, what might be reasonable is to declare a new property :combinesPerfectlyWith, which is a subproperty of :combinesWith. Like this, you could change the dataset to something as follows:

:red :combinesWith :yellow .
:red :combinesPerfectlyWith :purple .
:green :combinesPerfectlyWith :yellow .
:green :combinesWith :white .
:green :combinesWith :black .
:white :combinesWith :silver .
:white :combinesWith :black .
:black :combinesWith :white .

You are not losing any information here, you are just further specifying some information.


Now, back to what you actually seem to want to do - assign one or more reviews with color combinations.

To do so, the actual review (or at least an indicator of its presence?) will be the object of your review-related triples, and you will have to have something that can be the subject. That something needs to be another IRI or blank node, one that represents the color combination.

Therefore, you may want to redefine your ontology in a way that there is a :ColorCombination type with properties like :color and :hasReview. An excerpt of the dataset might then look as follows:

_:cc1 a :ColorCombination ;
    :color :red ;
    :color :purple .
_:cc2 a :ColorCombination ;
    :color :red ;
    :color :yellow ;
    :hasReview "a combination of warm colors" .
...

Now, in your SPARQL query, you can fetch the values with some straightforward triple patterns. I am not entirely sure what your query is intended to do, given that your nested SELECT query exports only the variable ?coc, which is not connected to your restrictions in the outer query.

O. R. Mapper
  • 20,083
  • 9
  • 69
  • 114