problem in instantiation SKOSReasoner

71 views
Skip to first unread message

Paola Montorio

unread,
May 17, 2012, 3:35:02 AM5/17/12
to skos...@googlegroups.com
Hi,
when I create the object SKOSReasoner with the follwing steps :

            manager = new SKOSManager();
            dataset = manager.loadDataset(URI.create("file:c:/my_owl.owl"));
            SKOStoOWLConverter converter = new SKOStoOWLConverter();
            OWLReasoner reasoner=new
            Reasoner.ReasonerFactory().createReasoner(converter.getAsOWLOntology(dataset));
            skosreasoner = new SKOSReasoner(manager, reasoner);

the last step   skosreasoner = new SKOSReasoner(manager, reasoner);  The exception is generated :

-----------------------------------------------------
Can't load SKOS data model from SKOSURI: http://www.w3.org/2009/08/skos-reference/skos-owl1-dl.rdf
org.semanticweb.owlapi.io.OWLOntologyCreationIOException: connect timed out
    at uk.ac.manchester.cs.owl.owlapi.ParsableOWLOntologyFactory.loadOWLOntology(ParsableOWLOntologyFactory.java:173)
    at uk.ac.manchester.cs.owl.owlapi.OWLOntologyManagerImpl.loadOntology(OWLOntologyManagerImpl.java:687)
    at uk.ac.manchester.cs.owl.owlapi.OWLOntologyManagerImpl.loadOntology(OWLOntologyManagerImpl.java:628)
    at uk.ac.manchester.cs.owl.owlapi.OWLOntologyManagerImpl.loadOntology(OWLOntologyManagerImpl.java:602)
    at org.semanticweb.skosapibinding.SKOSReasoner.<init>(SKOSReasoner.java:74)
    at itslab.api.skos.navigation.SkosDriver.<init>(SkosDriver.java:47)
    at itslab.api.skos.navigation.SkosDriver.main(SkosDriver.java:300)
Caused by: java.net.SocketTimeoutException: connect timed out

-------------------------------------------------

the file http://www.w3.org/2009/08/skos-reference/skos-owl1-dl.rdf is invoked in the SKOSReasoner.class.
How can I fixed this exception?

bye
Paola




Message has been deleted

Simon

unread,
May 17, 2012, 7:48:36 AM5/17/12
to skos...@googlegroups.com
Hi Paola, 

I'm also experiencing some problems working with the HermiT reasoner. I switched to another reasoner (Pellet) and 
everything seems to work. Using the latest SKOS API v3, OWL API v3 and Pellet 2.3.0 [1], the following example code should work for you. 

----

SKOSDataset skosCoreOntology = manager.loadDataset(URI.create ("file://skos-owl1-dl.rdf"));

SKOSDataset dataSet = manager.loadDatasetFromPhysicalURI(URI.create("file://your_skos_file.owl"));

SKOStoOWLConverter converter = new SKOStoOWLConverter();
OWLOntology mySkosAsOWLOntology = converter.getAsOWLOntology(dataSet);

// your skos dataset needs to  import the skos core ontology, we do this using the OWL API 
OWLImportsDeclaration importsDec = manager.getOWLManger().getOWLDataFactory().getOWLImportsDeclaration(IRI.create ("http://www.w3.org/2004/02/skos/core"));

// create the pellet reasoner
OWLReasoner reasoner= new com.clarkparsia.pellet.owlapiv3.PelletReasonerFactory().createReasoner(converter.getAsOWLOntology(dataSet));

// pass the pellet reasoner and the SKOS ontology file to the SKOSReasoner
 SKOSReasoner skosreasoner = new SKOSReasoner(manager, reasoner, converter.getAsOWLOntology(skosCoreOntology));

// example of getting inferred skos:narrowerTransitive concepts
 for (SKOSConcept con : skosreasoner.getSKOSConcepts()) {

                System.out.println("Concept:" + con.getURI());

                for (SKOSConcept broaderCon : skosreasoner.getSKOSNarrowerTransitiveConcepts(con)) {
                    for (SKOSAnnotation literal : broaderCon.getSKOSAnnotationsByURI(dataSet, manager.getSKOSDataFactory().getSKOSPrefLabelProperty().getURI())) {
                        System.out.println("Narrower concepts: " + literal.getAnnotationValueAsConstant().getLiteral());
                    }
                }
 }


----



Reply all
Reply to author
Forward
0 new messages