如何使用owlready2调用sync\u reasoner?

2024-09-30 22:19:53 发布

您现在位置:Python中文网/ 问答频道 /正文

我正试着给sync\u reasoner打电话来获取一个本体论

(doid.owl->http://purl.obolibrary.org/obo/doid.owl), which includes another ontology(ext.owl->https://github.com/Faiail/HumanDiseaseOntology/blob/master/src/ontology/ext.owl).

我使用的代码是:

import owlready2 as owl
owl.onto_path.append("D:\\raffaele\\UNIVERSITA\\3_anno\\IC\\syn_and_dis")
doid = owl.get_ontology("doid.owl")
doid.load()
owl.sync_reasoner(doid)

遵循错误日志:

File "D:\Anaconda\Anaconda_dwd\lib\site-packages\owlready2\reasoning.py", line 138, in sync_reasoner_hermit
    raise OwlReadyJavaError("Java error message is:\n%s" % (e.stderr or e.output or b"").decode("utf8"))

OwlReadyJavaError: Java error message is:
Exception in thread "main" org.semanticweb.owlapi.model.OWLRuntimeException: org.coode.owlapi.rdfxml.parser.TranslatedUnloadedImportException: Could not load imported ontology: <(cannot post the link (the file is ext.owl))> Cause: Problem parsing (cannot post the link (the file is ext.owl))
Could not parse ontology.  Either a suitable parser could not be found, or parsing failed.  See parser logs below for explanation.
The following parsers were tried:
1) RDFXMLParser
2) OWLXMLParser
3) OWLFunctionalSyntaxOWLParser
4) TurtleOntologyParser
5) OWLOBOParser
6) KRSS2OWLParser
7) ManchesterOWLSyntaxOntologyParser


Detailed logs:
--------------------------------------------------------------------------------
Parser: RDFXMLParser
org.xml.sax.SAXParseException; systemId: (cannot post the link (the file is ext.owl)); lineNumber: 1; columnNumber: 50; Sono richiesti spazi tra publicId e systemId.

--------------------------------------------------------------------------------
Parser: OWLXMLParser
org.xml.sax.SAXParseException; systemId: http://purl.obolibrary.org/obo/doid/obo/ext.owl; lineNumber: 1; columnNumber: 50; Sono richiesti spazi tra publicId e systemId.

--------------------------------------------------------------------------------
Parser: OWLFunctionalSyntaxOWLParser
Encountered " <ERROR> "< "" at line 1, column 1.
Was expecting:
    "Ontology" ...
     (Line 0)

--------------------------------------------------------------------------------
Parser: TurtleOntologyParser
uk.ac.manchester.cs.owl.owlapi.turtle.parser.ParseException: Encountered "" at line 1, column 1.
Was expecting one of:


--------------------------------------------------------------------------------
Parser: OWLOBOParser
org.coode.owlapi.obo.parser.TokenMgrError: Lexical error at line 1, column 51.  Encountered: "\n" (10), after : ""

--------------------------------------------------------------------------------
Parser: KRSS2OWLParser
de.uulm.ecs.ai.owlapi.krssparser.ParseException: Encountered " ">" "<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN\"> "" at line 1, column 1.
Was expecting:
    <EOF> 


--------------------------------------------------------------------------------
Parser: ManchesterOWLSyntaxOntologyParser
Encountered '<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">' at line 1 column 1.  Expected either 'Ontology:' or 'Prefix:' (Line 1)


org.semanticweb.owlapi.model.UnloadableImportException: Could not load imported ontology: <(cannot post the link (the file is ext.owl))> Cause: Problem parsing (cannot post the link (the file is ext.owl))
Could not parse ontology.  Either a suitable parser could not be found, or parsing failed.  See parser logs below for explanation.
The following parsers were tried:
1) RDFXMLParser
2) OWLXMLParser
3) OWLFunctionalSyntaxOWLParser
4) TurtleOntologyParser
5) OWLOBOParser
6) KRSS2OWLParser
7) ManchesterOWLSyntaxOntologyParser


Detailed logs:
--------------------------------------------------------------------------------
Parser: RDFXMLParser
org.xml.sax.SAXParseException; systemId: (cannot post the link (the file is ext.owl)); lineNumber: 1; columnNumber: 50; Sono richiesti spazi tra publicId e systemId.

--------------------------------------------------------------------------------
Parser: OWLXMLParser
org.xml.sax.SAXParseException; systemId: (cannot post the link (the file is ext.owl)); lineNumber: 1; columnNumber: 50; Sono richiesti spazi tra publicId e systemId.

--------------------------------------------------------------------------------
Parser: OWLFunctionalSyntaxOWLParser
Encountered " <ERROR> "< "" at line 1, column 1.
Was expecting:
    "Ontology" ...
     (Line 0)

--------------------------------------------------------------------------------
Parser: TurtleOntologyParser
uk.ac.manchester.cs.owl.owlapi.turtle.parser.ParseException: Encountered "" at line 1, column 1.
Was expecting one of:


--------------------------------------------------------------------------------
Parser: OWLOBOParser
org.coode.owlapi.obo.parser.TokenMgrError: Lexical error at line 1, column 51.  Encountered: "\n" (10), after : ""

--------------------------------------------------------------------------------
Parser: KRSS2OWLParser
de.uulm.ecs.ai.owlapi.krssparser.ParseException: Encountered " ">" "<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN\"> "" at line 1, column 1.
Was expecting:
    <EOF> 


--------------------------------------------------------------------------------
Parser: ManchesterOWLSyntaxOntologyParser
Encountered '<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">' at line 1 column 1.  Expected either 'Ontology:' or 'Prefix:' (Line 1)


    at uk.ac.manchester.cs.owl.owlapi.turtle.parser.OWLRDFConsumerAdapter.handleTriple(OWLRDFConsumerAdapter.java:92)
    at uk.ac.manchester.cs.owl.owlapi.turtle.parser.TurtleParser.parseObject(TurtleParser.java:335)
    at uk.ac.manchester.cs.owl.owlapi.turtle.parser.TurtleParser.parseObjectList(TurtleParser.java:310)
    at uk.ac.manchester.cs.owl.owlapi.turtle.parser.TurtleParser.parsePredicateObjectList(TurtleParser.java:257)
    at uk.ac.manchester.cs.owl.owlapi.turtle.parser.TurtleParser.parseTriples(TurtleParser.java:185)
    at uk.ac.manchester.cs.owl.owlapi.turtle.parser.TurtleParser.parseStatement(TurtleParser.java:178)
    at uk.ac.manchester.cs.owl.owlapi.turtle.parser.TurtleParser.parseDocument(TurtleParser.java:130)
    at uk.ac.manchester.cs.owl.owlapi.turtle.parser.TurtleOntologyParser.parse(TurtleOntologyParser.java:100)
    at uk.ac.manchester.cs.owl.owlapi.ParsableOWLOntologyFactory.loadOWLOntology(ParsableOWLOntologyFactory.java:206)
    at uk.ac.manchester.cs.owl.owlapi.OWLOntologyManagerImpl.loadOntology(OWLOntologyManagerImpl.java:880)
    at uk.ac.manchester.cs.owl.owlapi.OWLOntologyManagerImpl.loadOntology(OWLOntologyManagerImpl.java:800)
    at uk.ac.manchester.cs.owl.owlapi.OWLOntologyManagerImpl.loadOntology(OWLOntologyManagerImpl.java:758)
    at org.semanticweb.HermiT.cli.CommandLine.main(CommandLine.java:798)
Caused by: org.coode.owlapi.rdfxml.parser.TranslatedUnloadedImportException: Could not load imported ontology: <(cannot post the link (the file is ext.owl))> Cause: Problem parsing (cannot post the link (the file is ext.owl))
Could not parse ontology.  Either a suitable parser could not be found, or parsing failed.  See parser logs below for explanation.
The following parsers were tried:
1) RDFXMLParser
2) OWLXMLParser
3) OWLFunctionalSyntaxOWLParser
4) TurtleOntologyParser
5) OWLOBOParser
6) KRSS2OWLParser
7) ManchesterOWLSyntaxOntologyParser


Detailed logs:
--------------------------------------------------------------------------------
Parser: RDFXMLParser
org.xml.sax.SAXParseException; systemId: (cannot post the link (the file is ext.owl)); lineNumber: 1; columnNumber: 50; Sono richiesti spazi tra publicId e systemId.

--------------------------------------------------------------------------------
Parser: OWLXMLParser
org.xml.sax.SAXParseException; systemId: (cannot post the link (the file is ext.owl)); lineNumber: 1; columnNumber: 50; Sono richiesti spazi tra publicId e systemId.

--------------------------------------------------------------------------------
Parser: OWLFunctionalSyntaxOWLParser
Encountered " <ERROR> "< "" at line 1, column 1.
Was expecting:
    "Ontology" ...
     (Line 0)

--------------------------------------------------------------------------------
Parser: TurtleOntologyParser
uk.ac.manchester.cs.owl.owlapi.turtle.parser.ParseException: Encountered "" at line 1, column 1.
Was expecting one of:


--------------------------------------------------------------------------------
Parser: OWLOBOParser
org.coode.owlapi.obo.parser.TokenMgrError: Lexical error at line 1, column 51.  Encountered: "\n" (10), after : ""

--------------------------------------------------------------------------------
Parser: KRSS2OWLParser
de.uulm.ecs.ai.owlapi.krssparser.ParseException: Encountered " ">" "<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN\"> "" at line 1, column 1.
Was expecting:
    <EOF> 


--------------------------------------------------------------------------------
Parser: ManchesterOWLSyntaxOntologyParser
Encountered '<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">' at line 1 column 1.  Expected either 'Ontology:' or 'Prefix:' (Line 1)


org.semanticweb.owlapi.model.UnloadableImportException: Could not load imported ontology: <(cannot post the link (the file is ext.owl))> Cause: Problem parsing (cannot post the link (the file is ext.owl))
Could not parse ontology.  Either a suitable parser could not be found, or parsing failed.  See parser logs below for explanation.
The following parsers were tried:
1) RDFXMLParser
2) OWLXMLParser
3) OWLFunctionalSyntaxOWLParser
4) TurtleOntologyParser
5) OWLOBOParser
6) KRSS2OWLParser
7) ManchesterOWLSyntaxOntologyParser


Detailed logs:
--------------------------------------------------------------------------------
Parser: RDFXMLParser
org.xml.sax.SAXParseException; systemId: (cannot post the link (the file is ext.owl)); lineNumber: 1; columnNumber: 50; Sono richiesti spazi tra publicId e systemId.

--------------------------------------------------------------------------------
Parser: OWLXMLParser
org.xml.sax.SAXParseException; systemId: (cannot post the link (the file is ext.owl)); lineNumber: 1; columnNumber: 50; Sono richiesti spazi tra publicId e systemId.

--------------------------------------------------------------------------------
Parser: OWLFunctionalSyntaxOWLParser
Encountered " <ERROR> "< "" at line 1, column 1.
Was expecting:
    "Ontology" ...
     (Line 0)

--------------------------------------------------------------------------------
Parser: TurtleOntologyParser
uk.ac.manchester.cs.owl.owlapi.turtle.parser.ParseException: Encountered "" at line 1, column 1.
Was expecting one of:


--------------------------------------------------------------------------------
Parser: OWLOBOParser
org.coode.owlapi.obo.parser.TokenMgrError: Lexical error at line 1, column 51.  Encountered: "\n" (10), after : ""

--------------------------------------------------------------------------------
Parser: KRSS2OWLParser
de.uulm.ecs.ai.owlapi.krssparser.ParseException: Encountered " ">" "<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN\"> "" at line 1, column 1.
Was expecting:
    <EOF> 


--------------------------------------------------------------------------------
Parser: ManchesterOWLSyntaxOntologyParser
Encountered '<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">' at line 1 column 1.  Expected either 'Ontology:' or 'Prefix:' (Line 1)


    at org.coode.owlapi.rdfxml.parser.OWLRDFConsumer.statementWithResourceValue(OWLRDFConsumer.java:1704)
    at uk.ac.manchester.cs.owl.owlapi.turtle.parser.OWLRDFConsumerAdapter.handleTriple(OWLRDFConsumerAdapter.java:89)
12 more
Caused by: org.semanticweb.owlapi.model.UnloadableImportException: Could not load imported ontology: <(cannot post the link (the file is ext.owl))> Cause: Problem parsing (cannot post the link (the file is ext.owl))
Could not parse ontology.  Either a suitable parser could not be found, or parsing failed.  See parser logs below for explanation.
The following parsers were tried:
1) RDFXMLParser
2) OWLXMLParser
3) OWLFunctionalSyntaxOWLParser
4) TurtleOntologyParser
5) OWLOBOParser
6) KRSS2OWLParser
7) ManchesterOWLSyntaxOntologyParser


Detailed logs:
--------------------------------------------------------------------------------
Parser: RDFXMLParser
org.xml.sax.SAXParseException; systemId: (cannot post the link (the file is ext.owl)); lineNumber: 1; columnNumber: 50; Sono richiesti spazi tra publicId e systemId.

--------------------------------------------------------------------------------
Parser: OWLXMLParser
org.xml.sax.SAXParseException; systemId: (cannot post the link (the file is ext.owl)); lineNumber: 1; columnNumber: 50; Sono richiesti spazi tra publicId e systemId.

--------------------------------------------------------------------------------
Parser: OWLFunctionalSyntaxOWLParser
Encountered " <ERROR> "< "" at line 1, column 1.
Was expecting:
    "Ontology" ...
     (Line 0)

--------------------------------------------------------------------------------
Parser: TurtleOntologyParser
uk.ac.manchester.cs.owl.owlapi.turtle.parser.ParseException: Encountered "" at line 1, column 1.
Was expecting one of:


--------------------------------------------------------------------------------
Parser: OWLOBOParser
org.coode.owlapi.obo.parser.TokenMgrError: Lexical error at line 1, column 51.  Encountered: "\n" (10), after : ""

--------------------------------------------------------------------------------
Parser: KRSS2OWLParser
de.uulm.ecs.ai.owlapi.krssparser.ParseException: Encountered " ">" "<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN\"> "" at line 1, column 1.
Was expecting:
    <EOF> 


--------------------------------------------------------------------------------
Parser: ManchesterOWLSyntaxOntologyParser
Encountered '<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">' at line 1 column 1.  Expected either 'Ontology:' or 'Prefix:' (Line 1)


    at uk.ac.manchester.cs.owl.owlapi.OWLOntologyManagerImpl.makeLoadImportRequest(OWLOntologyManagerImpl.java:1315)
    at org.coode.owlapi.rdfxml.parser.TPImportsHandler.handleTriple(TPImportsHandler.java:89)
    at org.coode.owlapi.rdfxml.parser.OWLRDFConsumer.handleStreaming(OWLRDFConsumer.java:1742)
    at org.coode.owlapi.rdfxml.parser.OWLRDFConsumer.statementWithResourceValue(OWLRDFConsumer.java:1701)
13 more
Caused by: org.semanticweb.owlapi.io.UnparsableOntologyException: Problem parsing (cannot post the link (the file is ext.owl))
Could not parse ontology.  Either a suitable parser could not be found, or parsing failed.  See parser logs below for explanation.
The following parsers were tried:
1) RDFXMLParser
2) OWLXMLParser
3) OWLFunctionalSyntaxOWLParser
4) TurtleOntologyParser
5) OWLOBOParser
6) KRSS2OWLParser
7) ManchesterOWLSyntaxOntologyParser


Detailed logs:
--------------------------------------------------------------------------------
Parser: RDFXMLParser
org.xml.sax.SAXParseException; systemId: (cannot post the link (the file is ext.owl)); lineNumber: 1; columnNumber: 50; Sono richiesti spazi tra publicId e systemId.

--------------------------------------------------------------------------------
Parser: OWLXMLParser
org.xml.sax.SAXParseException; systemId: (cannot post the link (the file is ext.owl)); lineNumber: 1; columnNumber: 50; Sono richiesti spazi tra publicId e systemId.

--------------------------------------------------------------------------------
Parser: OWLFunctionalSyntaxOWLParser
Encountered " <ERROR> "< "" at line 1, column 1.
Was expecting:
    "Ontology" ...
     (Line 0)

--------------------------------------------------------------------------------
Parser: TurtleOntologyParser
uk.ac.manchester.cs.owl.owlapi.turtle.parser.ParseException: Encountered "" at line 1, column 1.
Was expecting one of:


--------------------------------------------------------------------------------
Parser: OWLOBOParser
org.coode.owlapi.obo.parser.TokenMgrError: Lexical error at line 1, column 51.  Encountered: "\n" (10), after : ""

--------------------------------------------------------------------------------
Parser: KRSS2OWLParser
de.uulm.ecs.ai.owlapi.krssparser.ParseException: Encountered " ">" "<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN\"> "" at line 1, column 1.
Was expecting:
    <EOF> 


--------------------------------------------------------------------------------
Parser: ManchesterOWLSyntaxOntologyParser
Encountered '<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">' at line 1 column 1.  Expected either 'Ontology:' or 'Prefix:' (Line 1)


    at uk.ac.manchester.cs.owl.owlapi.ParsableOWLOntologyFactory.loadOWLOntology(ParsableOWLOntologyFactory.java:236)
    at uk.ac.manchester.cs.owl.owlapi.OWLOntologyManagerImpl.loadOntology(OWLOntologyManagerImpl.java:880)
    at uk.ac.manchester.cs.owl.owlapi.OWLOntologyManagerImpl.loadOntology(OWLOntologyManagerImpl.java:800)
    at uk.ac.manchester.cs.owl.owlapi.OWLOntologyManagerImpl.loadImports(OWLOntologyManagerImpl.java:1278)
    at uk.ac.manchester.cs.owl.owlapi.OWLOntologyManagerImpl.makeLoadImportRequest(OWLOntologyManagerImpl.java:1309)
16 more

我该怎么修


Tags: theorgparserlinecolumncsowlext