0
나는 has_answer 및 has_choice 속성을 두 개인 개인을 보유하고 있습니다. 내가 원하는 무엇sparql을 사용하여 여러 속성을 표시하는 개인
<!-- http://www.semanticweb.org/myontology#Which_of_the_following_planet_has_the_average_speed_of_about_30Km/Seconds -->
<owl:NamedIndividual rdf:about="&myontology;Which_of_the_following_planet_has_the_average_speed_of_about_30Km/Seconds">
<rdf:type rdf:resource="&myontology;Question"/>
<rdfs:label>Which of the following planet has the average speed of about 30Km/Seconds ?</rdfs:label>
<myontology:QuestionNumber>1</myontology:QuestionNumber>
<myontology:has_answer rdf:resource="http://dbpedia.org/resource/Earth"/>
<myontology:has_choice rdf:resource="http://dbpedia.org/resource/Mars"/>
<myontology:has_choice rdf:resource="http://dbpedia.org/resource/Moon"/>
<myontology:has_score rdf:resource="&myontology;4_points"/>
<myontology:has_Level rdf:resource="&myontology;Expert"/>
</owl:NamedIndividual>
나에게 다음과 같은 결과를주는 개인
+ "SELECT distinct ?Qs ?CorrAns ?Choice "
+ "WHERE {?Question rdf:type owl:NamedIndividual."
+ "?Question rdfs:label ?Qs. "
+ "?Question myontology:has_answer ?CorrAns."
+ "?Question myontology:has_choice ?Choice."
//
+ "}"
// + "GROUP BY ?Qs"
+ "";
...
while (rs.hasNext()) {
QuerySolution soln = rs.nextSolution();
String Qs = soln.getLiteral("Qs").getString();
RDFNode choice = soln.get("Choice");
String ans = choice.asNode().getLocalName();
RDFNode Canswer = soln.get("CorrAns");
String cans = Canswer.asNode().getLocalName();
....
에서 속성 목록을 얻을 수 있습니다 :
Which of the following planet has the average speed of about 30Km/Seconds ? Choice : Mars CorrectAns: Earth
Which of the following planet has the average speed of about 30Km/Seconds ? Choice : Moon CorrectAns: Earth
내 질문에 내가 할 수있는 방법입니다 다음과 같이 한 줄에 결과를 얻으십시오 :
Which of the following planet has the average speed of about 30Km/Seconds ? || choice 1 : Mars || choice 2 : Moon || CorrecAns : Earth
Sparql에서 그렇게 할 수 있습니까?
네? Question' – AKSW
'에 의해 그룹화 동안 내가 어떻게 표시되지 않습니다 @AKSW의 답변에 따라 내 질문을 해결하고 내 OWL 파일에 몇 가지 문제를 해결 "select ...? choice"+ "WHERE {..."''choiceWHERE'라는 변수가 생길 때 당신이 기대하는 결과를 얻습니다. –
@JoshuaTaylor 재방송을 해주셔서 감사합니다. 그것은 단지 여기에 "~ choice"+ "WHERE ..."와 같은 에스패드가 내 코드에 없다 ... –