处理dl查询中的数据值限制

时间:2013-02-14 21:24:44

标签: java semantic-web owl dlquery owl-api

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

hasExperience(经验和hasYearsOfExperience一些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)

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

1 个答案:

答案 0 :(得分:1)

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

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

在你的代码中你也应该有这样的东西:

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

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