incomplete output in reading N-Triples (.nt) files in Fuseki and SPARQL - sparql

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:
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:
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:
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> .

Related

How to retrieve anonymous subclass from OWL in SPARQL

I am unsure of the SPARQL query needed to replicate the results of DL Query "has part some benzamide".
That query should return all entities that have some part that is a benzamide or a subclass of benzamide.
My SPARQL attempt:
PREFIX opioid: <https://mac389.github.io/ontology#>
SELECT ?substance ?substance_label
{ ?substance rdfs:subClassOf* opioid:chemical_entity.
?substance rdfs:subClassOf* / opioid:has_part / owl:someValuesFrom opioid:benzamide.
?substance rdfs:label ?substance_label }
Link to OWL as RDF/XML
In this code the 1st and 3rd lines work as intended, retrieving a list of all chemical entities and their labels. When I add the second line, the query returns no answers (there should be 21 items which is what the DL Query in Protege returns).
How does one query for anonymous subclasses like this?
I have looked at this question but I am looking for a subclass that only fulfills one of the property restrictions. I don't fully understand the answer to this question, but mine seems very related.

Getting children of an objects connected through link objects in SPARQL

I'm trying to figure out a SPARQL query for getting all children of an object in a system based on a rdf store where links between objects might have properties, and therefore designed that every link is a separate object and is connected with corresponding objects by "parent" and "child" predicates like so (illustration link) :
#prefix o: <http://helloworld.org/object#> .
#prefix r: <http://helloworld.org/relation#> .
#prefix l: <http://helloworld.org/link#> .
l:link1-11
r:parent o:object1 ;
r:child o:object11 .
l:link1-12
r:parent o:object1 ;
r:child o:object12 .
l:link12-121
r:parent o:object12 ;
r:child o:object121 .
I'm relatively new to graph DBs so i'm not sure if such recursive query is possible with current links design (i've come up only with a finite-depth query with many unions). Is it possible to make such a query or should i somehow redo the design?

BIND values from Documents to a SPARQL Variable (MarkLogic)

I am currently trying to see if it's possible to extract a certain value from a document and bind it to a variable in SPARQL
For example if i have such a document in MarkLogic.
/person/John
<person_data>
<name>John</name>
<age>25</age>
</person_data>
using this data I attempted various ways to bind it such as using XPath in sem:sparql as shown below
xquery version "1.0-ml";
import module namespace sem = "http://marklogic.com/semantics" at "/MarkLogic/semantics.xqy";
sem:sparql('
PREFIX fn : <http://www.w3.org/2005/xpath-functions>
SELECT *
WHERE {
?s ?p ?o .
BIND (fn:doc("/person/John")//name/text() AS ?name)
}
',
(),
(),
()
)
However, this resulted in an error. Hence, I greatly appreciate any advise given on accomplishing this.
The SPARQL engine has no access to documents, but there is a better solution anyhow. You can use Template Driven Extraction for this. It can expose an SQL view on documents, but also 'Identify Triples in Documents'. It effectively means that particular values can be projected into the triple index, and will become accessible as RDF data like any other RDF data in your database.
HTH!

Topology query in geosparql

I have inspired this articles and created an ontology with using geosparql ontology. Two classes named Area and Park were created as subclasses of the Feature class of geosparql. 3 Area instances and 1 Park instance were added to the ontology. Then, geometry instances were created (asWKT) as a subclass of Polygon class of geosparql. And the geometry instances were related with the Park and Area instances via hasGeometry object property (The created ontology and instances).
I have tried to make a topology query to find out which Area instances are within the Park instance. So, I have run the below query with using the sparql query plugin of Protégé 4.3.
PREFIX geosparql: http://www.opengis.net/ont/geosparql#
PREFIX su: http://www.example.org/su#
SELECT ?x ?y
WHERE {
?x a su:Area ;
geosparql:hasGeometry ?xgeo .
?y a su:Park ;
geosparql:hasGeometry ?ygeo .
?xgeo geosparql:sfWithin ?ygeo .
}
No results return but I know that there are two Area instances within the Park instance. I did not find out the problem. Do not I query topological relations with using geosparql and protégé?
The problem is you don't import the "good" use of sfWithin entity.
There is a difference between
http://www.opengis.net/ont/geosparql#sfWithin and http://www.opengis.net/def/function/geosparql/sfWithin.
Actually, I don't understand yet how to proceed in Protégé with this statement, I'm sorry about that.
If you really need to use such a topology query, you can use GraphDB instead, which implements a good working plugin for GeoSPARQL.

protege v 3.4.8 does not recognize transitive property

I have created object property hasSibling where A hasSibling B, B hasSibling C.I have made this property as transitive and symmetric,
but in inferred instances it is not showing A hasSibling C.
This is showing correctly in protege v4.3 but I am using protege v3.4.8
in my project where i have to use transitive and symmetric object properties.
I have tried Sparql query also but it is showing result for symmetric not for transitive.
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX uni:<http://www.owl-ontologies.com/aa.owl#>
select * where {
?x uni:hasSibling ?y .
}
this is giving result as:
Where in inferred tab nothing came
Kindly suggest how to overcome this problem.
Given the query:
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX uni:<http://www.owl-ontologies.com/aa.owl#>
select * where {
?x uni:hasSibling ?y .
}
You need to have a reasoning that understands the semantics of the uni:hasSibling relation which is more than likely described in the ontology identified by the URI: http://www.owl-ontologies.com/aa.owl# .
If you were using Virtuoso, this would require the following:
Derive and Inference Rule from
http://www.owl-ontologies.com/aa.owl#
Execute your query with a pragma for invoking the Inference Rule
created in the first step plus another pragma for loading your data
(collection of subject and objects connected by uni:hasSibling
relationship type)
I provide a similar example in my post that demonstrates Reasoning & Inference using British Royal Family relationship types. Also note a recent follow-on post that shows how you can create your own Custom Inference Rules.