Exemplo n.º 1
0
def main():

    recsys = MovieRecommender().Instance()
    #print ml.get_DBpedia_mapped_movie_list()
    #print ml.get_avg_movie_rating_by_dbpedia_uri('http://dbpedia.org/resource/Roman_Holiday')
    #print ml.get_avg_movie_rating_by_dbpedia_uri('http://dbpedia.org/resource/Wag_the_Dog')
    #r_list = recsys.get_movie_recommendations('http://dbpedia.org/resource/Wag_the_Dog')

    user_id = '100'
    (rated_movies,r_list) = recsys.recommendation_for_user(user_id)
    #print r_list
    print "Recommedations for the user:"******"|explanation:",dbp_id
        
            print util.url_unquote(movie_uri), confidence, "|explanation:",util.url_unquote(dbp_id)
        except Exception, e:
            print "----------ERROR--------"
            print movie_uri, dbp_id
            break
Exemplo n.º 2
0
from SPARQLWrapper import SPARQLWrapper, JSON
import util
sparql = SPARQLWrapper("http://dbpedia-test.inria.fr/sparql")
queryStr = """
SELECT ?m count(?m) AS ?num
WHERE
{
    <http://dbpedia.org/resource/Catch_Me_If_You_Can> dcterms:subject ?o.
    ?m dcterms:subject ?o.
    ?m a dbpedia-owl:Film.
    FILTER (?m != <http://dbpedia.org/resource/Catch_Me_If_You_Can>)

}

GROUP BY ?m ORDER BY DESC(?num)
LIMIT 50
""";
sparql.setQuery(queryStr)
sparql.setReturnFormat(JSON)
results = sparql.query().convert()

for result in results["results"]["bindings"]:
    print util.url_unquote(result["m"]["value"]), result["num"]["value"]
    #print result["m"]["value"], result["num"]["value"]