У меня есть игра викторины, в которой пользователь должен отвечать на такие вопросы, как: Что такое название столицы Германии? Варианты: Berlin Madrid London Данные находятся в моем файле совы.Как фильтровать запрос SPARQL с переменными Java
У меня есть еще одна онтология, в которой у меня есть rdfs: комментарий ресурсов (варианты вопросов для викторины), например rdfs: комментарий в Берлине, Лондон и т. Д. Я хочу, если пользователь выберет неправильный вариант, т. Е. Лондон, rdfs: комментарий справа опция должна отображаться пользователю, в данном случае в Берлине.
The right (correct) option I have is in java variable 'correct' and if user click wrong option, I want to show the rdfs:comment of correct option as:
"SELECT * " +
" WHERE { ?x rdfs:comment ?y " + "FILTER regex(?x ,'"+correct+"') " +
"}";
System.out.println(queryString);
Query query = QueryFactory.create(queryString);
QueryExecution qexec = QueryExecutionFactory.create(query, model) ;
ResultSet results = qexec.execSelect() ;
while (results.hasNext())
{
QuerySolution binding = results.nextSolution();
Literal l=binding.getLiteral("y");
String s=l.toString();
The problem is that it does not show me the filtered value rdfs:comment. When I remove Filter, it shows all rdfs:comment of resources but with Filter value, it simply does not work.
When I print the query, it shows the options values but does not display the rdfs:comment of that resources.
PREFIX rdfs:<http://www.w3.org/2000/01/rdf-schema#> prefix dbr: <http://dbpedia.org/page/>PREFIX rdf:<http://www.w3.org/1999/02/22-rdf-syntax-ns#> SELECT * WHERE { ?x rdfs:comment ?y FILTER regex(?x ,"Berlin") }
PREFIX rdfs:<http://www.w3.org/2000/01/rdf-schema#> prefix dbr: <http://dbpedia.org/page/>PREFIX rdf:<http://www.w3.org/1999/02/22-rdf-syntax-ns#> SELECT * WHERE { ?x rdfs:comment ?y FILTER regex(?x ,"Rome") }
My owl for rdfs:comment is like: Berlin--> rdfs:comment
Rome--> rdfs:comment etc
Сколько студентов в вашем университете выполняют одно и то же упражнение/проект? Я почти уверен, что вы уже спрашивали список рассылки Jena кем-то из вашего класса. – AKSW