0

我正在寻找方法/工具/语法来查询 RDF/OWL 本体中的注释。

我找到了搜索类、属性、个人的查询引擎,但我还没有找到一个会根据值进行搜索的引擎,例如 DC:Description

4

2 回答 2

1

如果您正在使用程序工具并且本体是 OWL,您可以使用 Manchester OWL API:

OWLClass classA = factory.getOWLClass(IRI.create("http://your/url/here#ClassA"));
OWLAnnotationProperty dcProperty = factory.getOWLAnnotationProperty(IRI.create("http://purl.org/dc/elements/1.1/description"));

for (OWLAnnotation annotation : classA.getAnnotations(ontology, dcProperty)) {
OWLLiteral literal = (OWLLiteral) annotation.getValue();
String literalString = literal.getLiteral()
                }

这将为您提供该特定财产的价值。这里的“工厂”是 OWLDataFactory 的一个实例。

希望能有所帮助!

于 2010-12-10T00:31:33.143 回答
1

使用 SPARQL,您应该能够通过您感兴趣的属性查询注释,例如:

PREFIX dc: <http://purl.org/dc/elements/1.1/>
SELECT ?x ?desc {
  ?x dc:description ?desc .
}

此方法还可用于检索具有特定注释值的所有实例,例如:

PREFIX dc: <http://purl.org/dc/elements/1.1/>
SELECT ?x {
  ?x dc:description "some description string" .
}

或者,您甚至可以尝试根据一些 REGEX 进行匹配:

PREFIX dc: <http://purl.org/dc/elements/1.1/>
SELECT ?x {
  ?x dc:description ?desc .
  FILTER REGEX(STR(?desc), "^Some regex") .
}
于 2010-09-08T06:34:19.647 回答