简体   繁体   English

用SPARQL构造推断

[英]Inference with SPARQL CONSTRUCT

I am modeling an ontology in Protégé 5.1.0. 我正在Protégé5.1.0中为本体建模。 I want to model something that, once the inference-engince is running, it is inferred that, under certain circumstances an instance be of class A. 我想对某种模型进行建模,一旦推理引擎开始运行,就可以推断出在某些情况下实例属于A类。

<owl:Class rdf:about="http://example.org#classA">
    <owl:equivalentClass>
        <owl:Restriction>
            <owl:onProperty rdf:resource="http://example.org#meetsRequirements"/>
            <owl:hasValue rdf:datatype="http://www.w3.org/2001/XMLSchema#boolean">true</owl:hasValue>
        </owl:Restriction>
    </owl:equivalentClass>
</owl:Class>

However, these "restrictions" are not as simple as the one shown in the example. 但是,这些“限制”并不像示例中所示的那么简单。 One of the restrictions, for example, is an operator "greater than" which, as far as I know, cannot be modeled in OWL-DL. 例如,限制之一是运算符“大于”,据我所知,该运算符无法在OWL-DL中建模。 (Is that correct?) (那是对的吗?)

Surfing on the Internet, I found the SPARQL CONSTRUCT type of query. 在Internet上冲浪时,我发现了SPARQL CONSTRUCT类型的查询。 So, I come up with a query such as: 因此,我提出了一个查询,例如:

CONSTRUCT {?ins rdf:type <http://example.org#classA}
FROM http://example.org/myBase
WHERE {?ins example:hasValue ?val}
FILTER (?val > 10^^xsd:double)}

I think that this query should return a Graph where all instances with example:hasValue > 10 are of type ClassA . 我认为此查询应返回一个Graph,其中所有example:hasValue > 10实例均为ClassA类型。

I want this result to be reflected on my Graph (where all my triples are). 我希望这个结果能反映在我的图表上(我的所有三元组都在其中)。 Is there any possibility for that? 有可能吗? Has anyone dealt with this kind of situation? 有没有人处理过这种情况?

I see two options. 我看到两个选择。

One, run the CONSTRUCTs that build inferred knowledge, save the results on files (eg, as Turtle) and load them into your triple store (in a separated graph, so that you can deal with updates). 首先,运行构建推断知识的CONSTRUCT,将结果保存在文件中(例如,保存为Turtle),然后将其加载到三元组存储中(在单独的图中,以便您可以处理更新)。 This approach makes queries performant, although it creates redundancy in your storage backend and it's static, you typically do it periodically and you cannot afford to do things this way for each small change you make on the explicit knowledge base. 这种方法使查询性能出色,尽管它在存储后端中创建了冗余并且是静态的,但通常会定期执行此操作,并且您不能为在显式知识库上进行的每个小更改以这种方式进行操作。 Clearly, you could run these CONSTRUCT rules while creating RDF (eg, from SQL/XML/CSV converters), which typically allows you to do it on small data sets and exploiting parallelism. 显然,您可以在创建RDF时运行这些CONSTRUCT规则(例如,通过SQL / XML / CSV转换器),这通常允许您在小型数据集上进行并利用并行性。

Option two, most triple stores (eg, Virtuoso, Fuseki/Jena) have rules to rewrite SPARQL queries and get more results than you do without rules. 选择二,大多数三元组存储(例如,Virtuoso,Fuseki / Jena)都具有重写SPARQL查询的规则,并且比没有规则时得到更多的结果。 The problem is that this approach usually is not very performant and, in case of engines like Fuseki/Jena, doesn't work very well with large data sets, because their reasoning engine (as most of OWL reasoners) need to load the whole base data set in memory, before being able to apply any inference. 问题在于这种方法通常性能不佳,而且对于像Fuseki / Jena这样的引擎,在大型数据集上也无法很好地工作,因为它们的推理引擎(与大多数OWL推理机一样)需要加载整个基础数据在内存中设置后,才能进行任何推理。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM