rdf

How do I make a SPARQL query to find the highest value for a property?

十年热恋 提交于 2019-12-19 18:22:25
问题 Lets say I have a predicate like 'age' where the values of all age triples are integer literals. What SPARQL query would return the subject with the highest age in the data? 回答1: You just need to do order by desc with the age predicate and then limit to just get the first one. PREFIX ns: <http://namespace.org/ontology/> SELECT ?s ?age WHERE { ?s ns:age ?age } ORDER BY DESC(?age) LIMIT 1 See the semantics of order by in SPARQL here With the next version of SPARQL , 1.1, that is already

Can't retrieve movies with high IDs from LinkedMDB with SPARQL

折月煮酒 提交于 2019-12-19 08:52:24
问题 I'm running the following query at the LinkedMDB SPARQL endpoint and it works. With it, I get all the information that I need about the director of the movie with id 72, which is Titanic , so I get information about James Cameron. PREFIX mdb: <http://data.linkedmdb.org/resource/movie/> SELECT ?director?nombre_director?id_director WHERE { ?pelicula mdb:filmid ?id . ?pelicula <http://data.linkedmdb.org/resource/movie/director> ?director . ?director <http://data.linkedmdb.org/resource/movie

XPATH - Select all child nodes with a specific attribute

风格不统一 提交于 2019-12-19 08:05:37
问题 What would be the xpath query to find all child nodes with a specific attribute value, but starting from a node with a specific attribute value? This is kind of related to a question I posted earlier about parsing an rdf xml file - I thought I had solved it but not quite yet. For example, I am trying to parse and grab all of the rdf:about attribute values. I have this working fine. I need to add the following condition though - parsing needs to start after a specific rdf:about value is found.

Jena read from turtle fails

…衆ロ難τιáo~ 提交于 2019-12-19 08:05:31
问题 I have just imported jena libraries to eclipse to work on rdf-s and it is my first try, but I cannot read a turtle (.ttl) file. I tried it in the following way: import java.io.*; import java.util.*; import com.hp.hpl.jena.rdf.model.*; public class Simpsons { public static void main(String[] args) throws IOException { Model model=ModelFactory.createDefaultModel(); model.read(new FileInputStream("simpsons.ttl"),null); } } The error I get is the following: Exception in thread "main" org.apache

Rdf duplicate triples

冷暖自知 提交于 2019-12-19 04:24:06
问题 I have a question a about RDF and duplicate triples. From perusing the internet it seems as if duplicate triples are somehow "bad" or a violation of some rule. But duplicate triples seem to me, on the surface, meaningful. Suppose I want to represent the fact: Susy(subject) mentions(predicate) Bob(object). Suppose that I further wanted to represent that Susy mentions Bob on five times. Wouldn't have 5 triples of Susy mentions Bob allow me to represents this? A later query that wants to know

Find lists containing ALL values in a set?

試著忘記壹切 提交于 2019-12-19 03:16:08
问题 How can I find lists that contain each of a set of items in SPARQL? Let's say I have this data: <http://foo.org/test> <http://foo.org/name> ( "new" "fangled" "thing" ) . <http://foo.org/test2> <http://foo.org/name> ( "new" "york" "city" ) . How can I find the items whose lists contain both "new" and "york"? The following SPARQL doesn't work, since filter works on each binding of ?t , not the set of all of them. PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> SELECT ?s ?p WHERE { ?s

RDF representation of sentences

纵饮孤独 提交于 2019-12-18 13:40:53
问题 I need to represent sentences in RDF format. In other words "John likes coke" would be automatically represented as: Subject : John Predicate : Likes Object : Coke Does anyone know where I should start? Are there any programs which can do this automatically or would I need to do everything from scratch? 回答1: It looks like you want the typed dependencies of a sentence, e.g. for John likes coke : nsubj(likes-2, John-1) dobj(likes-2, coke-3) I'm not aware of any dependency parser that directly

Equal relationship between ontology properties

ぃ、小莉子 提交于 2019-12-18 09:28:58
问题 I have 2 properties, e.g. 'hasColor' and 'hasFinish'. I want to express with ontology that in case of ontology class A are properties 'hasColor' and 'hasFinish' equal (owl:equivalentProperty). But in case of ontology class B the properties 'hasColor' and 'hasFinish' are NOT equal. How can I achieve this? One way probably is to create 'hasColor' and 'hasFinish' properties with class A as a range and set them to be equal. Then create another ones 'hasColor' and 'hasFinish' properties with class

Encoding mathematical properties in RDF

核能气质少年 提交于 2019-12-18 09:01:03
问题 I have been trying to find a solution to adding relationships, such as X has unit A < 20 into an existing ontology, but, could not find a solution so far. An existing knowledge graph - RDF - has many concepts and relationships. In an attempt improve the accuracy of inferences, we are trying to add some key properties to few of the concepts. Example: Concept X causes concept Y. And, we now know that concept Y has property ABC < 30 always. Please suggest on how to add this kind of relationships

SPARQL query to get only results with the most recent date

半世苍凉 提交于 2019-12-18 08:46:17
问题 I am learning basics of SPARQL with recent RDF-database released by the Finnish Ministry of Justice. It contains Finnish law data. There are statutes, which have versions, which have a date and topics. I want to get the most recent versions that have a "gun" topic. So, I wrote this: PREFIX sfl: <http://data.finlex.fi/schema/sfl/> PREFIX eli: <http://data.europa.eu/eli/ontology#> PREFIX skos: <http://www.w3.org/2004/02/skos/core#> PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>