Hi Gi-Won Chung,

On 27/12/10 16:38, Gi-Won Chung wrote:
Dear Jena developers!
I have a somewhat simple example, but I cant see why it doesnt work.
The code is running, but I get no results.
It would be nice if you could help me out, thank you!!!
There are two basic problems with your example.

First, your query asks for objects of the triple pattern

?x lib:speaks ?y

but there are no such triples in your ontology. I think what you are tryng to do is find the set of languages spoken by (at a guess) authors of novels. However, you haven't asserted any information about authors. What you have defined is a class of authors:

<owl:Class rdf:about="#S.Meyer">
 <rdfs:subClassOf>
  <owl:Class>
   <owl:intersectionOf rdf:parseType="Collection">
    <rdf:Description rdf:about="#Author"/>
    <owl:Restriction>
     <owl:onProperty rdf:resource="#speaks"/>
     <owl:someValuesFrom>
       <owl:Class>
        <owl:intersectionOf rdf:parseType="Collection">
         <rdf:Description rdf:about="#English"/>
         <rdf:Description rdf:about="#German"/>
        </owl:intersectionOf>
       </owl:Class>
      </owl:someValuesFrom>
     </owl:Restriction>
    </owl:intersectionOf>
   </owl:Class>
  </rdfs:subClassOf>
</owl:Class>

This defines #S.Meyer as the class - i.e. set of possible instances - of authors who speak both English and German. The fact that you have named this class using a name suggesting a single author hints to me that you've not quite got the modelling right yet. Irrespective of that, just defining the class does not mean that you have any instances yet: the set of German and English speaking authors could be empty.

If all you want to do is assert that S.Meyer is an author who speaks both English and German, you want something rather simpler:

<lib:Author rdf:ID="S.Meyer">
  <lib:speaks rdf:about="#English"/>
  <lib:speaks rdf:about="#German"/>
</lib:Author>

This would then provide two solutions to your query.

The second potential problem that you may run into in future, is that in Jena you need to enable a reasoner (aka inference engine) if you want to be able get results from complex expressions like intersection class descriptions. You would need to change this line:

OntModel model = ModelFactory.createOntologyModel();

to, for example:

OntModel model = ModelFactory.createOntologyModel( OntModelSpec.OWL_MEM_MICRO_RULE_INF);

which enables one of the OWL reasoners (and MICRO RULE INF is typically the best one to start with)

Ian

--
____________________________________________________________
Ian Dickinson                   Epimorphics Ltd, Bristol, UK
mailto:[email protected]        http://www.epimorphics.com
cell: +44-7786-850536              landline: +44-1275-399069
------------------------------------------------------------
Epimorphics Ltd.  is a limited company registered in England
(no. 7016688). Registered address: Court Lodge, 105 High St,
              Portishead, Bristol BS20 6PT, UK

Reply via email to