Comments (2)
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.
That helps a lot, thanks—and it confirms that your package produces more ergonomic code, too!
Thanks again.
from wikidataqueryservicer.
Related Issues (12)
- Queryng a variables instead of strings to Wikidata using WikidataQueryServiceR HOT 4
- Limit API call rate HOT 2
- query_wikidata may drop results
- Allow wdqs_requester() and query_wikidata() to request other instances HOT 1
- Notable deaths HOT 3
- "smart" formatting yields a "cannot open the connection" error
- Switch to WikipediR for extracting query examples
- Return POSIXct for date-times
- Switch from GET to POST
- Submit new version to CRAN HOT 1
- Lint checking and unit tests
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from wikidataqueryservicer.