SPARQL | Lib PHP for SPARQL | Data Manipulation library
kandi X-RAY | SPARQL Summary
kandi X-RAY | SPARQL Summary
Very simple SparqlClient for PHP.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Compare the result of two arrays .
- send multipart post data
- Execute a SPARQL query
- Calculates the difference between two arrays .
- Convert a turtle to an array .
- Convert CSV to array
- Get url port
- Initializes the resources
- Add an error .
- Convert namespaces to SPARQL
SPARQL Key Features
SPARQL Examples and Code Snippets
Community Discussions
Trending Discussions on SPARQL
QUESTION
Im trying to query a knowledge graph and im trying print the max occurrence of ?n in the result and i have tried running following query but it just doesn't prints anything
here is my SPARQL Query
...ANSWER
Answered 2022-Apr-04 at 21:39You can try this
QUESTION
I'm using Wikidata query service to obtain values and this is the code:
...ANSWER
Answered 2022-Mar-12 at 14:23results
is a dictionary, that is a python data structure which you can't invoke a method to_csv
on.
For safely storing a csv from a python dictionary you can use external libraries (see also the documentation on python.org).
The specific solution depends on which (meta)data you exactly want to export. In the following I assume that you want to store the value
for org
and orgLabel
.
QUESTION
I am trying to retrieve samples of coordinates in Wikidata via SPARQL but am having a very difficult time trying to achieve it. I would want to get only a single pair of coordinates per place and display the result in a column, and the latitude and longitude of the said coordinates sample in their own columns.
The following code (link to WQS) I use below works, but it does not get the coordinates values labels in Point(5.936111111 51.21)
format. When I replace p:P625
with wdt:P625
, no items are retrieved. Additionally, Borculo (Q1025685) appears twice in the results with two unique coordinates:
ANSWER
Answered 2022-Mar-07 at 13:18Use ps:P625
for obtaining the coordinates in the desired format (see also the manual on Wikibooks).
Also, it is not sufficient to sample the coordinates statement if you also group by ?lat
and ?long
. Hence, you'd better to sample it in a subquery.
Final result:
QUESTION
How do I get the instance type(s) (i.e., property=P31 and associated labels) for multiple Wikidata IDs in a single query? Ideally, I want to output a list with the columns: Wikidata ID | P31 ID | P31 Label, with multiple rows used if a Wikidata ID has more than one P31 attached.
I am using the web query service, which works well in part, but I am struggling to understand the syntax. I have so far managed to work out how to process a list of items, and return each one as a row (simple I know!), but I can't work out how to generate a new column that gives the P31 item:
...ANSWER
Answered 2022-Mar-04 at 12:28If I correctly understood your problem, you can use the following query:
QUESTION
I'm using the Wikidata SPARQL Query Service with the following query:
...ANSWER
Answered 2021-Nov-10 at 21:43wd:Q367204 is missing from the results because "there isn't an image", but also because there isn't an "instance of" statement (P31). Therefore, you can get results for both instances by wrapping both of these in an OPTIONAL block, with just ?item and ?itemLabel for Q367204, and all variables for Q1:
QUESTION
I am trying to retrieve some municipalities from Wikidata using SPARQL but several items returned have much of their fields empty despite these items having these data. I do not understand what is wrong with the query below (link to WQS). For example, the municipality Almelo has its coordinates (P625
), and parent place (P131
) erroneously missing in the results:
ANSWER
Answered 2022-Feb-11 at 11:10You have to declare OPTIONAL
each statement independently:
QUESTION
Im a very beginner in sparql, just started doint it a couple hours ago. Howewer, after some practicing i don't know why the following query is not working:
...ANSWER
Answered 2022-Feb-25 at 16:34Use this
QUESTION
I want to extract story plots from the English Wikipedia. I'm only looking for a few (~100) and the source of the plots doesn't matter, e.g. novels, video games, etc.
I briefly tried a few things that didn't work, and need some clarification on what I'm missing and where to direct my efforts. It would be nice if I could avoid manual parsing and could get just issue a single query.
Things I tried 1. markriedl/WikiPlotsThis repo downloads the pages-articles
dump, expands it using wikiextractor, then scans each article and saves the contents of each section whose title contains "plot". This is a heavy-handed method of achieving what I want, but I gave it a try and failed. I had to run wikiextractor inside Docker because there are known issues with Windows, and then wikiextractor failed because there is a problem with the --html flag.
I could probably get this working but it would take a lot of effort and there seemed like better ways.
2. WikidataI used the Wikidata SPARQL service and was able to get some queries working, but it seems like Wikidata only deals with metadata and relationships. Specifically, I was able to get novel titles but unable to get novel summaries.
3. DBpediaIn theory, DBpedia should be exactly what I want because it's "Wikipedia but structured", but they don't have nice tutorials and examples like Wikidata so I couldn't figure out how to use their SPARQL endpoint. Google wasn't much help either and seemed to imply that it's common to setup your own graph DB to query, which is beyond my scope.
4. QuarryThis is a new query service that lets you query several Wikimedia databases. Sounds promising but I was again unable to grab content.
5. PetScan & title downloadThis SO answer says I can query PetScan to get Wikipedia titles, download HTML from Wikipedia.org, then parse that HTML. This sounds like it would work, but PetScan looks intimidating and this involves HTML parsing that I want to avoid if possible.
...ANSWER
Answered 2022-Feb-18 at 21:32There's no straightforward way to do this as Wikipedia content isn't structured as you would like it to be. I'd use petscan to get a list of articles based on the category, feed them in to e.g. https://en.wikipedia.org/w/api.php?action=parse&page=The%20Hobbit&format=json&prop=sections iterate through the sections and if the 'line' attribute == 'Plot' then call e.g. https://en.wikipedia.org/w/api.php?action=parse&page=The%20Hobbit&format=json&prop=text§ion=2 where 'section' = 'number' of the section titled plot. That gives you html and I can't figure out how to just get the plain text, but you might be able to make sense of https://www.mediawiki.org/w/api.php?action=help&modules=parse
QUESTION
Imagine I would like to query all descendants of Otto Bismarck until generation 3. How could I write the sparql code with regex? In this tutorial it says that we can use regex but I don't know how.
I tried to use "{3}":
...ANSWER
Answered 2022-Feb-10 at 18:21It's not possible to write queries with REGEX, but the REGEX syntax can look similar to property paths, hence why you might have been confused.
As for writing paths of length of up to 3, the syntax you are using did not actually make it in the standard, even though it does appear in a few documents.
I'd use something like:
QUESTION
I have following concepts in turtle file. I would like to extract preferred label and ids for parent node (DOID_4159) and all its child from below concepts. I have written following SPARQL query to fetch the information, but it will not give all the child nodes.
...ANSWER
Answered 2022-Feb-09 at 08:27here we have some issues
- The .ttl file you posted is not correct. There is an error on the definition of the 1st entity which is missing of the
.
at the end. So you have to update the definition from:
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install SPARQL
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page