python - 调用sync_reasoner时Owlready2解析错误
问题描述
本体是使用 protege 创建的,并使用 owlready2 库从数据库中填充数据。现在这一行给出了这个错误:
sync_reasoner(我的世界)
这是我遇到的错误:
无法解析本体。找不到合适的解析器,或者解析失败。请参阅下面的解析器日志以获取解释。尝试了以下解析器:1) RDFXMLParser 2) OWLXMLParser 3) OWLFunctionalSyntaxOWLParser 4) TurtleOntologyParser 5) OWLOBOParser 6) KRSS2OWLParser 7) ManchesterOWLSyntaxOntologyParser
详细日志:
Parser: RDFXMLParser
org.xml.sax.SAXParseException; systemId: file:///C:/Users/THARIN~2/AppData/Local/Temp/tmpin0r193y; lineNumber: 1; columnNumber: 8; Element type "http:" must be followed by either attribute specifications, ">" or "/>".
--------------------------------------------------------------------------------
Parser: OWLXMLParser
org.xml.sax.SAXParseException; systemId: file:///C:/Users/THARIN~2/AppData/Local/Temp/tmpin0r193y; lineNumber: 1; columnNumber: 8; Element type "http:" must be followed by either attribute specifications, ">" or "/>".
--------------------------------------------------------------------------------
Parser: OWLFunctionalSyntaxOWLParser
Encountered " <FULLIRI> "<http://www.semanticweb.org/yashoda/ontologies/2017/12/MovieOnto> "" at line 1, column 1.
Was expecting:
"Ontology" ...
(Line 0)
--------------------------------------------------------------------------------
Parser: TurtleOntologyParser
uk.ac.manchester.cs.owl.owlapi.turtle.parser.ParseException: Encountered " <ERROR> "< "" at line 64, column 1.
Was expecting:
<EOF>
--------------------------------------------------------------------------------
Parser: OWLOBOParser
org.coode.owlapi.obo.parser.ParseException: Encountered "<EOF>" at line 941, column 114.
Was expecting one of:
"[" ...
<TAG_NAME> ...
<QUOTED_STRING> ...
<STRING> ...
<TAG_VALUE_WS> ...
<COMMENT> ...
(Line 941)
--------------------------------------------------------------------------------
Parser: KRSS2OWLParser
de.uulm.ecs.ai.owlapi.krssparser.ParseException: Encountered " ">" "<http://www.semanticweb.org/yashoda/ontologies/2017/12/MovieOnto> "" at line 1, column 1.
Was expecting:
<EOF>
--------------------------------------------------------------------------------
Parser: ManchesterOWLSyntaxOntologyParser
Encountered <http://www.semanticweb.org/yashoda/ontologies/2017/12/MovieOnto> at line 1 column 1. Expected one of:
Individual:
AnnotationProperty:
Datatype:
DataProperty:
ObjectProperty:
DisjointProperties:
ValuePartition:
EquivalentClasses:
Import:
Prefix:
DisjointClasses:
Class:
SameIndividual:
DifferentIndividuals:
(Line 1)
解决方案
据我所知(我不是 Python 程序员)Owlready2 正在使用 HermiT 推理器版本 1.3.8 和嵌入式 OWLAPI 版本。这个版本非常古老——HermiT 1.3.8 使用的是 OWLAPI 3,现在已经不支持几年了。
本体这一部分的解析器错误:
<Movie rdf:about="#Wonder_Woman_">
<isMadeIn rdf:resource="#Hong Kong"/>
</Movie>
<Country rdf:about="#Hong Kong">
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#NamedIndividual"/>
</Country>
它在抱怨#Hong Kong
碎片——它无法应对空间。更改为:
<Movie rdf:about="#Wonder_Woman_">
<isMadeIn rdf:resource="#Hong_Kong"/>
</Movie>
<Country rdf:about="#Hong_Kong">
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#NamedIndividual"/>
</Country>
允许解析器应对。从长远来看,Owlready2 应该更新到更新的 HermiT 版本。OWLAPI 处理版本 4 中的文件,HermiT 1.3.8.413 是 Protege 中使用的版本。
推荐阅读
- microsoft-graph-api - 尝试使用来自外部域的用户名更改本地 Azure AD B2C 用户的密码时出现错误 AADSTS50034
- java - ParseFloat 字符串 Java
- unicode - unicode 中的两种阿拉伯字体表示
- angular - 为什么不能在 canActivate 方法的 catch 块中返回 Observable.of(false)?
- image-processing - 瞳孔中心在实时眼动追踪中表现出色
- ios - 在ios中录制视频时如何检测设备的移动速度
- java - File.isFile() 返回不正确的结果?
- javascript - 如何使用javascript访问create js并进行交互
- javascript - 当页面返回上一个时返回单击的元素
- jquery - 如何使用 jquery 从 json 生成数组中缺失的日期?