現在、音楽推薦システムを構築中です。最初のステップ私はFOAF(友人の友人)を使って個人的なユーザープロファイルを作成したいのですが、SPARQLを使うとfoafを得ることができません:ファイルの関心はユーザープロファイルです。foafを取得:ユーザープロフィールの興味
<?xml version="1.0"?>
<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
xmlns:foaf="http://xmlns.com/foaf/0.1/"
xmlns:admin="http://webns.net/mvcb/">
<foaf:PersonalProfileDocument rdf:about="">
<foaf:maker rdf:resource="#me"/>
<foaf:primaryTopic rdf:resource="#me"/>
<admin:generatorAgent rdf:resource="http://www.ldodds.com/foaf/foaf-a-matic"/>
<admin:errorReportsTo rdf:resource="mailto:[email protected]"/>
</foaf:PersonalProfileDocument>
<foaf:Person rdf:ID="me">
<foaf:name>Pham Hai</foaf:name>
<foaf:title>Mr</foaf:title>
<foaf:givenname>Pham</foaf:givenname>
<foaf:family_name>Hai</foaf:family_name>
<foaf:nick>HaiLeader</foaf:nick>
<foaf:mbox_sha1sum>c900f594220ceebb386c02ad2e157cef0fb397b2</foaf:mbox_sha1sum>
<foaf:homepage rdf:resource="http://facebook.com.vn"/>
<foaf:depiction rdf:resource="http://cms.kienthuc.net.vn/zoom/1000/uploaded/manhtu/2016_03_17/hg/anh-noi-y-giuong-chieu-nong-bong-cua-hot-girl-sai-thanh.jpg"/>
<foaf:phone rdf:resource="tel:0962354550"/>
<foaf:interest rdf:resource="http://www.w3.org/2001/sw/"/>
</foaf:Person>
これが私のクエリです。私はバグを修正した
Model model = FileManager.get().loadModel(FILE_NAME);
showLogAndToast(model.toString());
String queryString =
"PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> " +
"PREFIX foaf: <http://xmlns.com/foaf/0.1/> " +
"SELECT * WHERE { " +
" ?p foaf:interest ?interest ." +
"}";
Query query = QueryFactory.create(queryString);
QueryExecution qexec = QueryExecutionFactory.create(query, model);
try {
ResultSet results = qexec.execSelect();
while (results.hasNext()){
QuerySolution solution = results.nextSolution();
showLogAndToast(solution.toString());
//Literal name = solution.getLiteral("interest");
//showLogAndToast(name.getString());
}
} finally {
qexec.close();
}
EDIT 。その前に私はSPARQLクエリで間違っていました。 ありがとうございます。
を呼び出すことはありませんか?どのSPARQLクエリが機能しないのですか?クエリを表示してください。 – AKSW
お返事ありがとうございます。私はその後、私のクエリを更新しました。 –
あなたはあなたの問題を解決しましたか?このソリューションは他の誰かにとって有益でしょうか、それともあなたの質問には問題はなかったのですか? – unor