0

I have 3 classes: Reptile, Mammal and Cat, with Cat is a subclass of Mammal.

I have an "or" class expression:

Reptile or Mammal or Cat

How can I infer with a reasoner to get the most representative classes for any given "or" class expression? Like in this case, they're Reptile and Mammal.

MiP
  • 499
  • 1
  • 7
  • 16
  • How do you define "representative"? – UninformedUser Mar 07 '17 at 10:03
  • @AKSW I meant the superclasses, e.g. `Reptile` and `Mammal` classes can represent the expression `Reptile or Mammal or Cat [or or ]`. I don't meant only their direct subclasses, but all of their subclasses. – MiP Mar 07 '17 at 11:21

2 Answers2

1

It seems that getDirectSubclasses(yourOrExpression) gives you the answers you are looking for.

Dmitry Tsarkov
  • 768
  • 4
  • 11
  • So I have 2 scenarios: The first is the `or` expression, I can use `getDirectSubclasses`. And the other is when the expression only contains one class, which method should I use to get that class in the expression? – MiP Mar 07 '17 at 13:47
  • @MiP you should really provide (in the question) a complet example of what you expect (including cases with more than one level in the taxonomy). Really I 'm not sure of what you want, why you do not validate the answer of Dmitry Tsarkov. – Galigator Mar 07 '17 at 16:44
  • @MiP Indeed,it would help if you provide an example of the query and expected result. You second scenario is unclear to me. If you have an `or`expression with just one argument (which is, by the way, not a legal OWL 2), which is a named class, then you would receive that argument as a result. You can then apply the same procedure to the definition of that class. – Dmitry Tsarkov Mar 07 '17 at 20:17
  • An expression with only one class is not an "and" or an "or". The OWL specifications say that such constructs require two or more elements. – Ignazio Mar 07 '17 at 20:22
  • @DmitryTsarkov for new lurkers, the correct answer is `OWLReasoner::getSubClasses(orClassExpression, true)`. – MiP Mar 12 '17 at 14:25
1

Another approach: given a disjunction, generate all disjunctions which have one less element than the original and check if they are equivalent. If true, then the element that was removed is 'redundant' - either subclass of another class in the disjunction, or included in the disjunction of two or more elements (thus covered by the other elements).

The same applies to conjunctions.

You can repeat the process - it will terminate when no element can be removed without making the new expression not equivalent to the old one.

Ignazio
  • 10,504
  • 1
  • 14
  • 25