4

I have a system that models some domain data in an ontology, the usual sort of triplestore.

I've been looking around for a way to express plurality and ordering but haven't found anything via the googles. My main use case is something like one entity in the domain can be a list of tasks, (get groceries, cook meal, eat meal, something like that) but in general I feel like having the ability to 'weight' your edges might be useful across the board.

Is there an accepted way of doing this? Just go to a quadstore? Intermediary items (list → listitem) with edges to an ordinality and a domain entity? Predicates from predicates to Weights?

Here's an example:

Example layout

double-beep
  • 3,889
  • 12
  • 24
  • 35
a p
  • 2,785
  • 2
  • 22
  • 40
  • 1
    An example might elicit more response. In particular, I'm not sure what you mean by plurality; I'm guessing that you understand the owl cardinality features and they won't do what you need - but I can't guess what you need. – Ed Staub Jun 25 '14 at 01:39
  • @EdStaub, yeah cardinality is good but I'm sort of looking for ordinality. An example is a list of tasks: `1. put on socks, 2. put on shoes, 3. leave the house`. I want to be able to encode order in my predicates. (In this situation, I'd have an entity in my schema called DoList which would have a Predicate from DoList to Tasks, with no max cardinality) – a p Jun 25 '14 at 01:41
  • Do you just want an encoding of a sequence? You can code up a list pretty easily, or you can make an tertiary relation, e.g., "hasTask(thing,rank,task)" such that "hasTask(taskList,1,socks), hasTask(taskList,2,shoes), etc." – Joshua Taylor Jun 25 '14 at 01:46
  • 1
    Possibly relevant for creating lists: [Difference Between OWL-LIST and RDF-LIST](http://stackoverflow.com/q/11681662/1281433), [Modelling OWL datatype property restrictions with a list of values](http://stackoverflow.com/q/18785499/1281433). – Joshua Taylor Jun 25 '14 at 01:48
  • 2
    Possibly relevant for n-ary relations: [Representing complicated sentences using RDF syntax](http://stackoverflow.com/q/16476051/1281433), [OWL Ontology Predicate Logic with Jena](http://stackoverflow.com/q/18560657/1281433), [Inferencing in protege](http://stackoverflow.com/q/16972311/1281433). – Joshua Taylor Jun 25 '14 at 01:49
  • Thanks for the links, Josh - I'll read through em. The idea is to avoid making tertiary+ relations if at all possible. – a p Jun 25 '14 at 01:51
  • You may prefer a list based solution then. It's easy enough to work with in SPARQL, but it'll be more awkward to with DL queries. – Joshua Taylor Jun 25 '14 at 15:45

1 Answers1

5

To represent something like what you've shown in your figure, you'd typically treat it as an n-ary relation. You should have a look at the W3C working note Defining N-ary Relations on the Semantic Web, but the short version is that you've got a 3-ary relation, and you're expressing

hasTask(list,1,socks)
hasTask(list,2,shoes)
hasTask(list,3,leash)

For each one of those, you'd have a resource, usually a blank node, but it could be a URI, too, and have properties relating it to the various components, and perhaps a type:

_:rel1 rdf:type :taskItem ;
       :hasList :list ;
       :hasord  1;
       :hasTask :socks .
_:rel2 rdf:type :taskItem ;
       :hasList :list ;
       :hasord  2;
       :hasTask :shoes .
_:rel3 rdf:type :taskItem ;
       :hasList :list ;
       :hasord  3;
       :hasTask :leash .

There's some variability here, of course. Rather than having the reified relation have the list, number, and task as property values, the list could be related to each task item:

:list :hasTaskItem [ rdf:type :taskItem ;
                     :hasord  1;
                     :hasTask :socks ] ,
                   [ rdf:type :taskItem ;
                     :hasord  2;
                     :hasTask :shoes ] ,
                   [ rdf:type :taskItem ;
                     :hasord  3;
                     :hasTask :leash ] .

The basic idea is the same though. Alternatively, you could use a list. In pure RDF, you can use RDF lists and leave the numbers implicit, like:

:list :hasTasks ( :socks :shoes :leash ) .

That's just shorthand for

:list :hasTasks [ rdf:first :socks ;
                  rdf:rest [ rdf:first :shoes ;
                             rdf:rest [ rdf:first :leash ;
                                        rdf:rest rdf:nil ]]].

In OWL, you can't use rdf:first and rdf:rest, but you can define your own analogous properties and implement the same structures. There's an example of specifying a list class in my answer ot Can I specify a range for rdf:List members? (where someone wanted a list all of whose elements had to be a certain type). If you do take this route, and you want to recover the position of each element in the list, you can actually do it using a SPARQL query over the RDF, as I've described in an answer to Is it possible to get the position of an element in an RDF Collection in SPARQL?.

Community
  • 1
  • 1
Joshua Taylor
  • 80,876
  • 9
  • 135
  • 306
  • Thanks again for the leads. I'm about to go home for the evening but will follow up (with questions?) and make sure you get your accept tomorrow. Cheers – a p Jun 25 '14 at 01:57
  • @ap could you please tell, are there any news about this case? – Nikita Danilov Jun 10 '18 at 07:05