-1

私は現在、音楽レコメンデーション システムを構築しています。最初のステップは FOAF (friend of a friend) を使用して個人のユーザー プロファイルを作成したいのですが、SPARQL を使用すると 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:leigh@ldodds.com"/>
</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 クエリで間違っていました。本当にありがとう。

4

1 に答える 1