我有一个本体,它包含:
我想对ag.hasTime >= ac.hasTime和ag.hasMoney >= ac.hasMoney等所有个人进行分类,其中ag是Agent,ac是动作实例。
我想说的是,这些条件有几点:
我不想使用SWRL,因为我读到这不是一个标准,而且我可以始终使用SPARQL。
我想SPARQL可以做到,但我不知道怎么做。但我更喜欢的解决方案是点击在protege。或者用公理来制定规范。
发布于 2014-05-14 03:04:24
我觉得你的意思是这样的:
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX urPrefx :<http://YOUR ONTOLOGY PATH HERE>
SELECT ?r (COUNT( DISTINCT ?r) AS ?countNo)
WHERE
{
#Query 1.1 Where urPrefx:greaterOrEqualThan is a restricted property
?data_property_individual_categorie rdfs:subPropertyOf urPrefx:greaterOrEqualThan.
#Query 1.2 Get all the action classes with those restricted property
{SELECT DISTINCT * WHERE {?individuals_actions rdf:type ?ActionsClasses.?individuals_actions ?data_property_individual_categorie ?values_action}}
#Query 1.3 Get all the agents with those restricted property
{SELECT DISTINCT * WHERE {?individuals_agents rdf:type ?AgentClasses. ?individuals_agents ?data_property_individual_categorie ?values_agent}}
#Get all No and Yes
BIND(if( ?values_agent >=?values_action, urPrefx:Yes, urPrefx:No) AS ?r).
}GROUP BY ?r
您唯一需要指定的是“是”和“否”;您想用它做什么。您将需要使用命令构造来为类AgentRestrictions分配。
https://stackoverflow.com/questions/23626213
复制