我有一个简单的 n3 本体
@prefix my: <http://www.codeproject.com/KB/recipes/n3_notation#>.
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
my:spec a rdfs:Class.
my:security a rdfs:Class; rdfs:subClassOf my:spec .
my:bluetooth a my:security;
my:preferedby my:BusinessPerson;
my:name "bluetooth".
我试图定义类规范并将安全类定义为规范的子类。
这是我在 dotNetRdf 库的帮助下使用的 sparql 查询
PREFIX my: <http://www.codeproject.com/KB/recipes/n3_notation#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT ?name WHERE {
[ a rdfs:subClassOf*/my:spec;
my:preferedby my:BusinessPerson;
my:name ?name].
}
我使用 dotnetrdf 库来查询我的本体和
Graph g2 = new Graph();
g2.LoadFromFile(@"C:\\Users\Ravindu Kottahachchi\Desktop\ontology.n3");
ISparqlDataset ds = new InMemoryDataset(g2);
LeviathanQueryProcessor processor = new LeviathanQueryProcessor(ds);
SparqlResultSet resul = processor.ProcessQuery(query1) as SparqlResultSet;
如果我在不使用任何标记指示路径基数的情况下查询查询,此设置工作正常
但是当我运行上述查询时,它给出了错误VDS.RDF.Parsing.Tokens.MultiplyToken' Token which is valid only after a Predicate to indicate Path Cardinality
我使用的 dotnetrdf 设置有问题吗?
我用这个
TripleStore store = new TripleStore();
Graph g = new Graph();
Notation3Parser parser = new Notation3Parser();
parser.Load(g, @"C:\\Users\Ravindu Kottahachchi\Desktop\ontology.n3");
store.Add(g);
SparqlQueryParser sparqlparser = new SparqlQueryParser();
SparqlResultSet results = store.ExecuteQuery(query) as SparqlResultSet;
它使用具有相同 sparql 查询的三重存储,但它也给出了相同的错误
有人可以帮我解决我犯错的地方提前谢谢