dbpedia

path between two resources

别来无恙 提交于 2019-11-27 07:06:53
问题 Is it possible to count the number of the edges that connect two instance with a SPARQL query? I want to find a path. 回答1: You count the number of edges in a unique path using SPARQL's property paths and aggregate functions. For instance, with data like this, which contains two paths that we care about ( a to c with two edges, and d to g with three edges): @prefix : <https://stackoverflow.com/questions/19587520/sparql-path-between-two-instance/> . :a :p :b . # a to c is a path of length 2 :b

get latitude and longitude of a place dbpedia

自古美人都是妖i 提交于 2019-11-27 02:07:25
I want to get the latitude and longitude of a place whose name I already know by PREFIX geo: <http://www.w3.org/2003/01/geo/wgs84_pos#> PREFIX dbo: <http://dbpedia.org/ontology/> SELECT * WHERE { ?s a dbo:Place . ?s geo:lat ?lat . ?s geo:long ?long . } where the name of the place ( ?s ) is something like Graves Park. How would one go about implementing the same in Jena where the name of the place might vary? You can use Jena's ARQ to execute queries against remote SPARQL endpoints. The process is described in ARQ — Querying Remote SPARQL Services . Using ParameterizedSparqlStrings in SELECT

Why is dbpedia-owl:wikiPageRedirects not returning the full set of redirect links? (Sparql)

我怕爱的太早我们不能终老 提交于 2019-11-26 23:12:44
I am using the following query : select ?value where { <http://dbpedia.org/resource/Paris> dbpedia-owl:wikiPageRedirects* ?value } in order to retrieve the wikiPageRedirects property of Paris. Based on dbpedia Paris has more than 20 redirect links. Why am I only retrieving the first one? Artemis Your direction was wrong. select distinct * where { ?x dbpedia-owl:wikiPageRedirects <http://dbpedia.org/resource/Paris> } Joshua Taylor Artemis's answer is right; the "direction" in the query is wrong. It's worth explaining that a bit more, though. On the DBpedia "page", you'll see lots of data like:

finding common superclass and length of path in class hierarchies

て烟熏妆下的殇ゞ 提交于 2019-11-26 17:53:18
问题 I have two classes, A and B, from DBpedia. How can I calculate the distance (number of edges) from each class to a common superclass C, and how can I find this common superclass? 回答1: You can do this, but a couple of things should be noted first: Two classes may have lots of superclasses in common, not necessarily just one. This means that there may not be a unique most specialized common superclass. If some class C is a superclass of A and B, then every superclass of C is also a superclass

How to get all companies from DBPedia?

雨燕双飞 提交于 2019-11-26 16:26:12
问题 I'm new to querying DBPedia. How can I get all companies from http://dbpedia.org/sparql? This query returns only 50'000 organizations: SELECT DISTINCT * WHERE {?company a dbpedia-owl:Company} 回答1: You're right that your query isn't returning all the companies. The pattern is correct, though. Notice that this query which only counts the companies returns 88054: prefix dbpedia-owl: <http://dbpedia.org/ontology/> select (count(distinct ?company) as ?count) where { ?company a dbpedia-owl:Company

DBpedia Jena Query returning null

谁都会走 提交于 2019-11-26 15:31:36
I'm just trying to run a small query on DBpedia, the query itself works, see it here , but I don't why its returning when doing so with Jena, I'm getting null. String service = "http://dbpedia.org/sparql"; String queryString = ""; queryString = "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> SELECT ?label" + "WHERE {" + "<http://dbpedia.org/resource/Quatre_Bornes> <http://dbpedia.org/ontology/country> ?y ."+ "?y rdfs:label ?label ."+ "FILTER (LANG(?label) = 'en')"+ "}"; Query query = QueryFactory.create(queryString); QueryEngineHTTP qexec = QueryExecutionFactory.createServiceRequest

get latitude and longitude of a place dbpedia

喜欢而已 提交于 2019-11-26 09:58:01
问题 I want to get the latitude and longitude of a place whose name I already know by PREFIX geo: <http://www.w3.org/2003/01/geo/wgs84_pos#> PREFIX dbo: <http://dbpedia.org/ontology/> SELECT * WHERE { ?s a dbo:Place . ?s geo:lat ?lat . ?s geo:long ?long . } where the name of the place ( ?s ) is something like Graves Park. How would one go about implementing the same in Jena where the name of the place might vary? 回答1: You can use Jena's ARQ to execute queries against remote SPARQL endpoints. The

How to extract information from a Wikipedia infobox?

你离开我真会死。 提交于 2019-11-26 04:52:31
There is this fancy infobox in <some Wikipedia article>. How do I get the value of <this field and that>? Tgr The wrong way: trying to parse HTML Use (cURL/jQuery/file_get_contents/requests/wget/ more jQuery ) to fetch the HTML article code of the article, then use a DOM parser to extract table.infobox tr[3] td / use a regex . This is actually a really bad idea most of the time. Wikipedia's HTML code is not particularly parsing-friendly (especially infoboxes which are a system of hand-written templates), the exact structure changes from infobox to infobox, and the structure of an infobox might

DBpedia Jena Query returning null

安稳与你 提交于 2019-11-26 04:27:41
问题 I\'m just trying to run a small query on DBpedia, the query itself works, see it here, but I don\'t why its returning when doing so with Jena, I\'m getting null. String service = \"http://dbpedia.org/sparql\"; String queryString = \"\"; queryString = \"PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> SELECT ?label\" + \"WHERE {\" + \"<http://dbpedia.org/resource/Quatre_Bornes> <http://dbpedia.org/ontology/country> ?y .\"+ \"?y rdfs:label ?label .\"+ \"FILTER (LANG(?label) = \'en\')\"+ \"}

How to extract information from a Wikipedia infobox?

大城市里の小女人 提交于 2019-11-26 01:49:49
问题 There is this fancy infobox in <some Wikipedia article>. How do I get the value of <this field and that>? 回答1: The wrong way: trying to parse HTML Use (cURL/jQuery/file_get_contents/requests/wget/more jQuery) to fetch the HTML article code of the article, then use a DOM parser to extract table.infobox tr[3] td / use a regex. This is actually a really bad idea most of the time. Wikipedia's HTML code is not particularly parsing-friendly (especially infoboxes which are a system of hand-written