0

我正在尝试使用 OWL API 运行 DL 查询,使用 DL 查询示例(http://sourceforge.net/p/owlapi/code/ci/aef6981535f07a2d0d44c394b9f4d5415f36025a/tree/contract/src/test/java/org/coode /owlapi/examples/DLQueryExample.java )

hasExperience some (Experience and hasYearsOfExperience some int[>=1])

这运行良好并在 Protege 中显示预期结果,但在 Java 中返回以下错误:

Exception in thread "AWT-EventQueue-0" java.lang.RuntimeException: Prefix not registered for prefix name: :
    at org.semanticweb.owlapi.util.DefaultPrefixManager.getIRI(DefaultPrefixManager.java:199)
    at org.coode.owlapi.manchesterowlsyntax.ManchesterOWLSyntaxEditorParser.getIRI(ManchesterOWLSyntaxEditorParser.java:3112)
    at org.coode.owlapi.manchesterowlsyntax.ManchesterOWLSyntaxEditorParser.getOWLDatatype(ManchesterOWLSyntaxEditorParser.java:563)
    at org.coode.owlapi.manchesterowlsyntax.ManchesterOWLSyntaxEditorParser.parseDataRangePrimary(ManchesterOWLSyntaxEditorParser.java:1032)
    at org.coode.owlapi.manchesterowlsyntax.ManchesterOWLSyntaxEditorParser.parseDataUnionOf(ManchesterOWLSyntaxEditorParser.java:1013)
    at org.coode.owlapi.manchesterowlsyntax.ManchesterOWLSyntaxEditorParser.parseDataIntersectionOf(ManchesterOWLSyntaxEditorParser.java:995)
    at org.coode.owlapi.manchesterowlsyntax.ManchesterOWLSyntaxEditorParser.parseDataRange(ManchesterOWLSyntaxEditorParser.java:988)
    at org.coode.owlapi.manchesterowlsyntax.ManchesterOWLSyntaxEditorParser.parseDataRestriction(ManchesterOWLSyntaxEditorParser.java:908)
    at org.coode.owlapi.manchesterowlsyntax.ManchesterOWLSyntaxEditorParser.parseNonNaryClassExpression(ManchesterOWLSyntaxEditorParser.java:787)
    at org.coode.owlapi.manchesterowlsyntax.ManchesterOWLSyntaxEditorParser.parseUnion(ManchesterOWLSyntaxEditorParser.java:688)
    at org.coode.owlapi.manchesterowlsyntax.ManchesterOWLSyntaxEditorParser.parseIntersection(ManchesterOWLSyntaxEditorParser.java:663)
    at org.coode.owlapi.manchesterowlsyntax.ManchesterOWLSyntaxEditorParser.parseNestedClassExpression(ManchesterOWLSyntaxEditorParser.java:1212)
    at org.coode.owlapi.manchesterowlsyntax.ManchesterOWLSyntaxEditorParser.parseObjectRestriction(ManchesterOWLSyntaxEditorParser.java:819)
    at org.coode.owlapi.manchesterowlsyntax.ManchesterOWLSyntaxEditorParser.parseNonNaryClassExpression(ManchesterOWLSyntaxEditorParser.java:783)
    at org.coode.owlapi.manchesterowlsyntax.ManchesterOWLSyntaxEditorParser.parseUnion(ManchesterOWLSyntaxEditorParser.java:688)
    at org.coode.owlapi.manchesterowlsyntax.ManchesterOWLSyntaxEditorParser.parseIntersection(ManchesterOWLSyntaxEditorParser.java:663)
    at org.coode.owlapi.manchesterowlsyntax.ManchesterOWLSyntaxEditorParser.parseNestedClassExpression(ManchesterOWLSyntaxEditorParser.java:1212)
    at org.coode.owlapi.manchesterowlsyntax.ManchesterOWLSyntaxEditorParser.parseObjectRestriction(ManchesterOWLSyntaxEditorParser.java:819)
    at org.coode.owlapi.manchesterowlsyntax.ManchesterOWLSyntaxEditorParser.parseNonNaryClassExpression(ManchesterOWLSyntaxEditorParser.java:783)
    at org.coode.owlapi.manchesterowlsyntax.ManchesterOWLSyntaxEditorParser.parseUnion(ManchesterOWLSyntaxEditorParser.java:688)
    at org.coode.owlapi.manchesterowlsyntax.ManchesterOWLSyntaxEditorParser.parseIntersection(ManchesterOWLSyntaxEditorParser.java:663)
    at org.coode.owlapi.manchesterowlsyntax.ManchesterOWLSyntaxEditorParser.parseClassExpression(ManchesterOWLSyntaxEditorParser.java:650)
    at org.coode.owlapi.examples.DLQueryParser.parseClassExpression(DLQueryManager.java:413)
    at org.coode.owlapi.examples.DLQueryEngine.getInstances(DLQueryManager.java:324)
    at org.coode.owlapi.examples.DLQueryManager.getInstances(DLQueryManager.java:127)

任何想法如何解决这一问题?

4

1 回答 1

1

问题似乎来自您处理前缀的方式,而不是来自 DL 查询。

确保您的默认前缀存在:您可以查看 .owl 文件的顶部,其中声明了前缀映射。

在您的代码中,您也应该有类似的内容:

String base = "http://example.com/";
PrefixManager pm = new DefaultPrefixManager(base);

您还可以查看文档以了解有关前缀的更多信息。

于 2013-02-15T09:38:17.887 回答