0

I am loading a N-triple(.nt) file in Fuseki and then using SPARQL query to query the data. The N-triple file I am using is - linkedct-dump-2010-02-10.zip at this link.

When I view the same file in Protege ontology editor (link here) I see following:

enter image description here

As can be seen there are Classes within Entities. I am currently working with trials class. When I click on any of the Instances of trials class I see following: enter image description here

So it can be seen that there are Classes within the data and each class has instances. Now when in Fuseki I try to get all the classes through following SPARQL query:

PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>

SELECT DISTINCT ?type
WHERE {
  ?s a ?type.
}

The output I see is just a list of urls something like this:

enter image description here

How do I get the Classes within the data and then get instances within a specific class(in my case trials class) and then select any Individual Annotations (in pic 2 you can see individual annotation for a specific instance in trials class as viewed in protege editor) within a specific instance?

Update: Following is a sample data i see when I open the .nt file in wordpad:

<http://data.linkedct.org/resource/trials/NCT00000102> <http://data.linkedct.org/resource/linkedct/condition> <http://data.linkedct.org/resource/condition/3196> .
<http://data.linkedct.org/resource/trials/NCT00000104> <http://data.linkedct.org/resource/linkedct/condition> <http://data.linkedct.org/resource/condition/7149> .
<http://data.linkedct.org/resource/trials/NCT00000105> <http://data.linkedct.org/resource/linkedct/condition> <http://data.linkedct.org/resource/condition/2080> .
user2966197
  • 2,793
  • 10
  • 45
  • 77
  • 1. Technically, your query returns all RDF resources that are used in triples with the predicate `rdf:type`. Basically, and via inference, those are classes. 2. If you want to have all instances of a given class, you have to reflect this in your query, i.e. `?s a lct:trials`. 3. If you want additional information about those instances, again, just do this in your query, i.e. add another triple pattern `?s ?p ?o.` and don't forget to `SELECT` what you need. – UninformedUser Aug 08 '17 at 18:13
  • @AKSW I am very new to SPARQL so can you explain through an example query like if i wanted to select `trials` class and instance `Trial NCT00000102` and within this instance an annotation called `condition` then how should my SPARQL query look like? – user2966197 Aug 08 '17 at 18:20
  • How about `?s a ?type . ?type a owl:Class` ? – Joshua Taylor Aug 08 '17 at 21:15
  • @JoshuaTaylor When I execute` SELECT DISTINCT ?type WHERE { ?s a ?type . ?type a owl:Class. }` I get 0 results – user2966197 Aug 08 '17 at 21:18
  • 1
    Well, OWL isn't RDF, even though OWL can be serialized as RDF. The same OWL ontology might have multiple RDF serializations. Since you're using an RDF query language (SPARQL) to query OWL serialized as RDF, you'll probably need to take a look into that particular RDF document. Given that it's 1.6G, it's not really likely that a casual StackOverflow user is going to examine it for you in order to answer a question. Can you post some of the relevant RDF content from that file? – Joshua Taylor Aug 08 '17 at 21:20
  • @JoshuaTaylor I apologize but I am unable to understand what you mean(I just started with SPARQL today). Can you explain it through an example. For example if i want to get class 'trials' and then instance in that class 'Trial NCT00000102' and say a annotation in that called 'condition' then how can I do that? – user2966197 Aug 08 '17 at 21:24
  • @JoshuaTaylor I have posted the link to the file I am using in my post above. – user2966197 Aug 08 '17 at 21:26
  • @user2966197 Yes, I know you did. That's the only way that I knew (as I mentioned) that it's a 1.6G file. That's bigger than most people are going to look at just to answer a StackOverflow question. Since you already have the file, could you post a snippet that you think contains triples that should be appearing for your query? – Joshua Taylor Aug 08 '17 at 21:28
  • @JoshuaTaylor I have added a sample data (in my post above) i see when I open the .nt file in wordpad. – user2966197 Aug 08 '17 at 21:39
  • That is not helpful. Indeed that's how N-Triples look like. I guess Joshua wanted to see the schema triples. I can tell you that there is no proper triple ` rdf:type owl:Class` that's why Joshua's query doesn't work here. So you can only use your initial query to get all classes. – UninformedUser Aug 09 '17 at 06:01
  • Regarding your question, I already gave you the answer. You can get all instance of a given class with `?s rdf:type .` . And if you have a given instance `s`, you can get the (outgoing) data by using it as subject of a triple pattern, i.e. ` ?p ?o .`, and if you want to have just a particular property `p`, indeed replace the `?p` by the URI, i.e. `

    ?o .` Hope this helps.

    – UninformedUser Aug 09 '17 at 06:04
  • Anyways, you should start with an RDF and SPARQL tutorial. That's how you can learn to write those rather simple queries. Anything else doesn't make sense because otherwise, you'll come back here for any other query that you need. – UninformedUser Aug 09 '17 at 06:04
  • [SPARQL Endpoint](http://yasgui.org/#query=PREFIX+rdf%3A+%3Chttp%3A%2F%2Fwww.w3.org%2F1999%2F02%2F22-rdf-syntax-ns%23%3E%0A%0ASELECT+DISTINCT+%3Ftype%0AWHERE+%7B%0A++%3Fs+a+%3Ftype.%0A%7D&contentTypeConstruct=text%2Fturtle&contentTypeSelect=application%2Fsparql-results%2Bjson&endpoint=http%3A%2F%2Fstatic.linkedct.org%2Fsparql&requestMethod=POST&tabTitle=Query+1&headers=%7B%7D&outputFormat=table) – Stanislav Kralin Aug 09 '17 at 08:24
  • Also, http://static.linkedct.org/snorql/ – Stanislav Kralin Aug 09 '17 at 08:31

0 Answers0