0

我尝试使用来自 OWL-API 的 ManchesterOWLSyntaxParser。我需要将曼彻斯特语法中的 String 转换为 OWL Axiom,我可以将其添加到现有的本体中。问题是,我总是得到 Parser Exception(如下所示):

    Exception in thread "main" org.semanticweb.owlapi.manchestersyntax.renderer.ParserException: Encountered Class: at line 1 column 1. Expected one of:
Class name
Object property name
Data property name
inv
Functional
inverse
InverseFunctional
(
Asymmetric
Transitive
Irreflexive
{
Symmetric
Reflexive

at org.semanticweb.owlapi.manchestersyntax.parser.ManchesterOWLSyntaxParserImpl$ExceptionBuilder.build(ManchesterOWLSyntaxParserImpl.java:2802)
at org.semanticweb.owlapi.manchestersyntax.parser.ManchesterOWLSyntaxParserImpl.parseAxiom(ManchesterOWLSyntaxParserImpl.java:2368)
at Main.main(Main.java:29)

我在 w3c 网站上阅读了有关曼彻斯特语法的信息,但我不知道问题出在哪里。也许曼彻斯特解析器应该以不同的方式使用。

我试图解析的曼彻斯特语法中的字符串示例代码。

OWLOntology o = ontologyManager.loadOntologyFromOntologyDocument(new File("family.owl"));
OWLDataFactory df = o.getOWLOntologyManager().getOWLDataFactory();
ManchesterOWLSyntaxParser parser = new ManchesterOWLSyntaxParserImpl(ontologyManager.getOntologyConfigurator(), df);
parser.setStringToParse("Class: <somePrefix#Father>" +
                "   EquivalentTo: \n" +
                "        <somePrefix#Male>\n" +
                "         and <somePrefix#Parent>");
OWLAxiom ax = parser.parseAxiom();
4

1 回答 1

0

本体没有片段中的类和属性的声明。解析器无法在不知道所涉及的实体的情况下解析片段。

就像解析整个本体一样,类、属性和数据类型需要在本体对象中声明公理。

于 2021-04-19T23:02:38.980 回答