GithubHelp home page GithubHelp logo

Comments (2)

bearloga avatar bearloga commented on July 17, 2024

First, thank you very much! :)

Second, good question! I specifically wanted to use what I think is the best package for HTTP requests (httr) -- and one I am most comfortable with -- but especially because I wanted my package to have an MIT license, rather than GPL-3 (which I would be forced to use if I had depended on SPARQL).

But yeah, you can totally even just use the SPARQL package instead:

sparql_query <- 'PREFIX wd: <http://www.wikidata.org/entity/>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX wikibase: <http://wikiba.se/ontology#>
SELECT DISTINCT ?genre ?genreLabel WHERE {
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
  ?film wdt:P31 wd:Q11424.
  ?film rdfs:label "The Cabin in the Woods"@en.
  ?film wdt:P136 ?genre.
}'

x <- SPARQL::SPARQL(url = "https://query.wikidata.org/bigdata/namespace/wdq/sparql", query = sparql_query)
x$results
genre genreLabel
http://www.wikidata.org/entity/Q200092 "horror film"@ en
http://www.wikidata.org/entity/Q471839 "science fiction film"@ en
http://www.wikidata.org/entity/Q224700 "comedy horror"@ en
http://www.wikidata.org/entity/Q859369 "comedy-drama"@ en
http://www.wikidata.org/entity/Q1342372 "monster film"@ en

compared to

y <- WikidataQueryServiceR::query_wikidata(sparql_query)
y
genre genreLabel
http://www.wikidata.org/entity/Q200092 horror film
http://www.wikidata.org/entity/Q471839 science fiction film
http://www.wikidata.org/entity/Q224700 comedy horror
http://www.wikidata.org/entity/Q859369 comedy-drama
http://www.wikidata.org/entity/Q1342372 monster film

Hope that helps!

from wikidataqueryservicer.

briatte avatar briatte commented on July 17, 2024

That helps a lot, thanks—and it confirms that your package produces more ergonomic code, too!

Thanks again.

from wikidataqueryservicer.

Related Issues (12)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.