Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
263 views
in Technique[技术] by (71.8m points)

rdf - Inferencing in protege

I have a simple ontology as follows

<?xml version="1.0"?>
<!DOCTYPE rdf:RDF [
<!ENTITY owl "http://www.w3.org/2002/07/owl#" >
<!ENTITY xsd "http://www.w3.org/2001/XMLSchema#" >
<!ENTITY rdfs "http://www.w3.org/2000/01/rdf-schema#" >
<!ENTITY rdf "http://www.w3.org/1999/02/22-rdf-syntax-ns#" >
<!ENTITY assignment "http://www.semanticweb.org/shadowman/ontologies/2013/5/assignment#" >
]>

<rdf:RDF xmlns="http://www.semanticweb.org/shadowman/ontologies/2013/5/assignment#"
 xml:base="http://www.semanticweb.org/shadowman/ontologies/2013/5/assignment"
 xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
 xmlns:assignment="http://www.semanticweb.org/shadowman/ontologies/2013/5/assignment#"
 xmlns:owl="http://www.w3.org/2002/07/owl#"
 xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
 xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
<owl:Ontology rdf:about="http://www.semanticweb.org/shadowman/ontologies/2013/5/assignment"/>

<!-- 
///////////////////////////////////////////////////////////////////////////////////////
//
// Object Properties
//
///////////////////////////////////////////////////////////////////////////////////////
 -->

<!-- http://www.semanticweb.org/shadowman/ontologies/2013/5/assignment#channel_of -->
<owl:ObjectProperty rdf:about="&assignment;channel_of">
    <rdfs:domain rdf:resource="&assignment;Channels"/>
    <rdfs:range rdf:resource="&assignment;Television"/>
    <owl:inverseOf rdf:resource="&assignment;has_channels"/>
</owl:ObjectProperty>

<!-- http://www.semanticweb.org/shadowman/ontologies/2013/5/assignment#has_channels -->
<owl:ObjectProperty rdf:about="&assignment;has_channels">
    <rdfs:range rdf:resource="&assignment;Channels"/>
    <rdfs:domain rdf:resource="&assignment;Television"/>
</owl:ObjectProperty>

<!-- http://www.semanticweb.org/shadowman/ontologies/2013/5/assignment#has_inet_connection -->
<owl:ObjectProperty rdf:about="&assignment;has_inet_connection">
    <rdfs:range rdf:resource="&assignment;InternetConnection"/>
    <rdfs:domain rdf:resource="&assignment;Person"/>
</owl:ObjectProperty>

<!-- http://www.semanticweb.org/shadowman/ontologies/2013/5/assignment#has_television -->
<owl:ObjectProperty rdf:about="&assignment;has_television">
    <rdfs:domain rdf:resource="&assignment;Person"/>
    <rdfs:range rdf:resource="&assignment;Television"/>
    <owl:inverseOf rdf:resource="&assignment;ownes_by"/>
</owl:ObjectProperty>

<!-- http://www.semanticweb.org/shadowman/ontologies/2013/5/assignment#internet_connection_owned_by -->
<owl:ObjectProperty rdf:about="&assignment;internet_connection_owned_by">
    <rdfs:domain rdf:resource="&assignment;InternetConnection"/>
    <rdfs:range rdf:resource="&assignment;Person"/>
    <owl:inverseOf rdf:resource="&assignment;has_inet_connection"/>
</owl:ObjectProperty>

<!-- http://www.semanticweb.org/shadowman/ontologies/2013/5/assignment#ownes_by -->
<owl:ObjectProperty rdf:about="&assignment;ownes_by">
    <rdfs:range rdf:resource="&assignment;Person"/>
    <rdfs:domain rdf:resource="&assignment;Television"/>
</owl:ObjectProperty>

<!-- http://www.semanticweb.org/shadowman/ontologies/2013/5/assignment#watched_by -->
<owl:ObjectProperty rdf:about="&assignment;watched_by">
    <rdfs:domain rdf:resource="&assignment;Channels"/>
    <rdfs:range rdf:resource="&assignment;Person"/>
    <owl:inverseOf rdf:resource="&assignment;watches"/>
</owl:ObjectProperty>

<!-- http://www.semanticweb.org/shadowman/ontologies/2013/5/assignment#watches -->
<owl:ObjectProperty rdf:about="&assignment;watches">
    <rdfs:range rdf:resource="&assignment;Channels"/>
    <rdfs:domain rdf:resource="&assignment;Person"/>
</owl:ObjectProperty>

<!-- 
///////////////////////////////////////////////////////////////////////////////////////
//
// Data properties
//
///////////////////////////////////////////////////////////////////////////////////////
 -->

<!-- http://www.semanticweb.org/shadowman/ontologies/2013/5/assignment#yh -->
<owl:DatatypeProperty rdf:about="&assignment;yh"/>

<!-- 
///////////////////////////////////////////////////////////////////////////////////////
//
// Classes
//
///////////////////////////////////////////////////////////////////////////////////////
 -->

<!-- http://www.semanticweb.org/shadowman/ontologies/2013/5/assignment#Advanced -->
<owl:Class rdf:about="&assignment;Advanced">
    <rdfs:subClassOf rdf:resource="&assignment;Coloured"/>
    <rdfs:subClassOf>
        <owl:Restriction>
            <owl:onProperty rdf:resource="&assignment;ownes_by"/>
            <owl:allValuesFrom rdf:resource="&assignment;Rich"/>
        </owl:Restriction>
    </rdfs:subClassOf>
</owl:Class>

<!-- http://www.semanticweb.org/shadowman/ontologies/2013/5/assignment#Antena -->
<owl:Class rdf:about="&assignment;Antena">
    <rdfs:subClassOf rdf:resource="&assignment;Channels"/>
</owl:Class>

<!-- http://www.semanticweb.org/shadowman/ontologies/2013/5/assignment#BlackAndWhite -->
<owl:Class rdf:about="&assignment;BlackAndWhite">
    <rdfs:subClassOf rdf:resource="&assignment;Television"/>
</owl:Class>

<!-- http://www.semanticweb.org/shadowman/ontologies/2013/5/assignment#CRT -->
<owl:Class rdf:about="&assignment;CRT">
    <rdfs:subClassOf rdf:resource="&assignment;Coloured"/>
    <rdfs:subClassOf>
        <owl:Restriction>
            <owl:onProperty rdf:resource="&assignment;ownes_by"/>
            <owl:allValuesFrom rdf:resource="&assignment;Mid"/>
        </owl:Restriction>
    </rdfs:subClassOf>
</owl:Class>

<!-- http://www.semanticweb.org/shadowman/ontologies/2013/5/assignment#Channels -->
<owl:Class rdf:about="&assignment;Channels"/>

<!-- http://www.semanticweb.org/shadowman/ontologies/2013/5/assignment#Coloured -->
<owl:Class rdf:about="&assignment;Coloured">
    <rdfs:subClassOf rdf:resource="&assignment;Television"/>
</owl:Class>

<!-- http://www.semanticweb.org/shadowman/ontologies/2013/5/assignment#High -->
<owl:Class rdf:about="&assignment;High">
    <rdfs:subClassOf rdf:resource="&assignment;InternetConnection"/>
</owl:Class>

<!-- http://www.semanticweb.org/shadowman/ontologies/2013/5/assignment#Internet -->
<owl:Class rdf:about="&assignment;Internet">
    <rdfs:subClassOf rdf:resource="&assignment;Channels"/>
    <rdfs:subClassOf>
        <owl:Restriction>
            <owl:onProperty rdf:resource="&assignment;channel_of"/>
            <owl:allValuesFrom rdf:resource="&assignment;Advanced"/>
        </owl:Restriction>
    </rdfs:subClassOf>
</owl:Class>

<!-- http://www.semanticweb.org/shadowman/ontologies/2013/5/assignment#InternetConnection -->
<owl:Class rdf:about="&assignment;InternetConnection"/>

<!-- http://www.semanticweb.org/shadowman/ontologies/2013/5/assignment#LCD -->
<owl:Class rdf:about="&assignment;LCD">
    <rdfs:subClassOf rdf:resource="&assignment;Coloured"/>
    <rdfs:subClassOf>
        <owl:Restriction>
            <owl:onProperty rdf:resource="&assignment;ownes_by"/>
            <owl:someValuesFrom rdf:resource="&assignment;Rich"/>
        </owl:Restriction>
    </rdfs:subClassOf>
</owl:Class>

<!-- http://www.semanticweb.org/shadowman/ontologies/2013/5/assignment#LED -->
<owl:Class rdf:about="&assignment;LED">
    <rdfs:subClassOf rdf:resource="&assignment;Coloured"/>
    <rdfs:subClassOf>
        <owl:Restriction>
            <owl:onProperty rdf:resource="&assignment;ownes_by"/>
            <owl:someValuesFrom rdf:resource="&assignment;Rich"/>
        </owl:Restriction>
    </rdfs:subClassOf>
</owl:Class>

<!-- http://www.semanticweb.org/shadowman/ontologies/2013/5/assignment#Medium -->
<owl:Class rdf:about="&assignment;Medium">
    <rdfs:subClassOf rdf:resource="&assignment;InternetConnection"/>
</owl:Class>

<!-- http://www.semanticweb.org/shadowman/ontologies/2013/5/assignment#Mid -->
<owl:Class rdf:about="&assignment;Mid">
    <rdfs:subClassOf rdf:resource="&assignment;Person"/>
    <owl:disjointWith rdf:resource="&assignment;Rich"/>
</owl:Class>

<!-- http://www.semanticweb.org/shadowman/ontologies/2013/5/assignment#Person -->
<owl:Class rdf:about="&assignment;Person"/>

<!-- http://www.semanticweb.org/shadowman/ontologies/2013/5/assignment#Rich -->
<owl:Class rdf:about="&assignment;Rich">
    <rdfs:subClassOf rdf:resource="&assignment;Person"/>
</owl:Class>

<!-- http://www.semanticweb.org/shadowman/ontologies/2013/5/assignment#Television -->
<owl:Class rdf:about="&assignment;Television"/>

<!-- 
///////////////////////////////////////////////////////////////////////////////////////
//
// Individuals
//
///////////////////////////////////////////////////////////////////////////////////////
 -->

<!-- http://www.semanticweb.org/shadowman/ontologies/2013/5/assignment#John -->
<owl:NamedIndividual rdf:about="&assignment;John"/>

<!-- http://www.semanticweb.org/shadowman/ontologies/2013/5/assignment#SLTA -->
<owl:NamedIndividual rdf:about="&assignment;SLTA">
    <rdf:type rdf:resource="&assignment;Advanced"/>
</owl:NamedIndividual>

<!-- http://www.semanticweb.org/shadowman/ontologies/2013/5/assignment#Youtube -->
<owl:NamedIndividual rdf:about="&assignment;Youtube">
    <rdf:type rdf:resource="&assignment;Internet"/>
    <watched_by rdf:resource="&assignment;John"/>
</owl:NamedIndividual>
</rdf:RDF>
<!-- Generated by the OWL API (version 3.4.2) http://owlapi.sourceforge.net -->

Now, I am going to infer that person John is a Rich Person. I tried various restrictions, but only I am getting that 'John is a person'.

My initial ontology idea is this, if person watches an Internet channel from his TV, then he has an advanced TV, advancedTV s are ONLY owned_by Rich people.

Now in our Instance, John watches YouTube, YouTube is an internet channel, so internet channels only available in advanced TV, and advanced TV s are owned only by rich, therefore John should be rich. But as stated earlier, I keep getting that John is a person

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I do not think that you can express this in your current class hierarchy using OWL alone. If I understand correctly, you already have the axioms

John watches YouTube
YouTube a InternetChannel
InternetChannel availableOn only AdvancedTV
AdvancedTV inverse owns only RichPerson

but cannot infer the intermediate inference John a (owns some AdvancedTV) that would let you conclude that John a RichPerson.

If you had the additional axiom “if some person P watches some channel C, then P owns some television T and C is available on T,” then the reasoning would work as follows: “Since John watches YouTube, John would have to own some television on which YouTube is available. Since YouTube is an internet channel, the television would have to be an advanced television. Since John would then own an advanced television, he would be a rich person.”

The limitation in OWL

However, I do not think that that axiom can be expressed in OWL. Descriptions logics (of which OWL is one) are a subset of first-order logic, and can only express first-order sentences that use only two variables. The axiom above seems to require three:

  • ∀ p, c: watches(p,c) → (∃ t: owns(p,t) &wedge; availableOn(c,t))

I have not been able to rewrite that in such a way that it uses only two variables, so I do not think that it can be expressed in OWL. That means that you will need to change something in your ontology to make this work. As I see it, there are a few options:

  • You could turn your channel class hierarchy and introduce some individuals to represent channel types.
  • Instead of using a watches relationship that only related persons and channels, you could use a three place relation watchesOn that relates a person, the channel that they watch, and the television on which they watch the channel.

The first option might be a bit quicker to implement, but I think that the second option is a bit more flexible in the long run, better represents the information at hand, and makes for a cleaner overall representation.

Representing Channel Types with Individuals

If you changed the channel subclass hierarchy into a collection of channel types, e.g., instead of YouTube a InternetChannel, you were to say YouTube hasChannelType Internet, then you say things like

watches some (hasChannelType value Internet) SubClassOf owns some AdvancedTV

which says that “if someone watches something that has channel type internet, then that someone owns an advanced television.” Since John watches YouTube, and YouTube has channel type Internet, then John owns an advanced television. Since advanced televisions are owned only by rich people, John must be a rich person.

That axiom is a general class axiom. It does not have a simple class name on the left hand side, but rather a class expression. These do not come up all that often, but as discussed in Being complex on the left-hand-side: General Concept Inclusion, they are very useful on occasion.
That article provides an example of creating them in Protégé, as well. To enter a general class axiom in Protégé, go to the Active Ontology tab, and find the General class axioms tab within it. Then you can enter the axiom verbatim, and it should look like this:

General class axiom in Protégé

Changing watches to watchesOn

Alternatively, you can replace the binary relation watches with a 3-place relation watchesOn which would associate a person with with the channel that they watch and the television on which they watch it. This has the nice advantage that in the case where an individual owns multiple televisions, some can still be primitive while others are advanced. (The first solution just says that if someone watches an internet channel, then they own an advanced television, but it doesn't capture the fact that the person uses that television to watch the internet channel.) To replace the binary relation watches(Person,Channel) with the tertiary watchesOn(Person,Channel,Television) we follow the approach given in the W3C Working Group Note, Defining N-ary Relations on the Semantic Web. We introduce a class (not a property) watchesOn, each of whose instances represents an occurrence of the watchesOn relationship, and three properties, hasWatcher, hasWatchedChannel, hasWatchedTelevision which relate instance of watchesOn with the person, channel, and television, respectively, that are involved in the relationship. Instances of watchesOn will often be blank nodes. For instance, watchesOn(John,YouTube,JohnsTelevision) can be represented in RDF as:

[] a :watchesOn ;
   :hasWatcher :John ;
   :hasWatchedChannel :YouTube ;
   :hasWatchedTelevision :JohnsTelevision .

With this kind of representation, we can state lots of useful facts. For instance, to say that if a person watches something on a television, then they own that television, we assert:

inverse(hasWatcher) o hasWatchedTelevision SubPropertyOf owns

This is like saying

hasWatcher(?w,?person) &wedge; hasWatchedTelevision(?w,?television) → owns(?person,?television) .

You can also say that televisions on which internet channels are watched are advanced televisions. This requires a general class axiom, as in the first solution, but in this case, it is:

inverse (hasWatchedTelevision) some (hasWatchedChannel some InternetChannel) SubClassOf AdvancedTV

which is like saying

hasWatchedTelevision(?w,?television) &wedge; hasWatchedChannel(?w,?channel) &wedge; InternetChannel(?channel) → AdvancedTV(?television) .

With both of those axioms in place, we can infer that John owns JohnsTelevision and that JohnsTelevision a AdvancedTV. If we add one more class axiom, namely that if a person owns an advanced television, then they are rich, i.e.,

owns some AdvancedTV SubClassOf RichPerson

then we can infer that John a RichPerson.

This kind of representation is nice in that using restrictions, we can assert, for instance, that John watches YouTube on some television, without stating which television he watches it on. This requires adding a type assertion to John, namely:

John a inverse hasWatcher some (hasWatchedChannel value YouTube and
                                hasWatchedTelevision some Television)

This says that John watches YouTube on some television, but does not say which television. By our earlier axioms, the reasoner can still infer that whatever television it happens to be, it must be an advanced television, and John must own it. The reasoner can then still infer that John is a rich person.

A reasoner in Protégé confirms that John is a RichPerson

This works even one step farther. We do not even need to specify which channel John watched, but just that it is an internet channel:

John a inverse hasWatcher some (hasWatchedChannel some InternetChannel and
                                hasWatchedTelevision some Television)

and the reasoner can still infer that John is rich person. To top things off, the class expression

inverse hasWatcher some (hasWatchedChannel some InternetChannel and
                         hasWatchedTelevision some Television)

consists of those individuals that watch some internet channel on some television. The reasoner can tell us that this class expression is a subclass of RichPerson, which means that these kinds of inferences work not just for John, but anything in this class:

Pellet confirms in Protégé that anyone who watches some internet channel on some television is a RichPerson


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...