I have noticed that most properties have an inverse property such as:
http://vocab.getty.edu/ontology#ulan1511_child_of
the inverse is:
http://vocab.getty.edu/ontology#ulan1512_parent_of
Is there a way to automatically create that property ex: Alice is the childOf John is in the knowledge Graph
How can it automatically create the property John is the parentOf Alice?
Is it possible with inferencing?
If it is just one of two properties, you can do this SPARQL Update:
PREFIX ont: <http://vocab.getty.edu/ontology#>
INSERT { ?o ont:ulan1512_parent_of ?s }
WHERE { ?s ont:ulan1511_child_of ?o }
You can even do this in the parser input stream (needs some java to be writtern).
If it is more complex, you can use a Jena reasoner.
Related
I have an ontology in Protege.
When I add an object property like X worksFor Y, and then load the rdf to graphdb, it generates 3 triples with subject = blank node, property = owl:someValuesFrom, owl:onProperty, owl:rdfType, and then it adds a triple that states X rdf:subClassOf Y.
Is this correct?
What is the logic behind this?
Here is an example of what I'm doing:
This is the ontology in Protege. I made a small version that addresses this specific issue. I save it as rdf and then load it in GraphDb
And here is what I get in GraphDb after loading the rdf from the ontology.
I hope this helps to better understand the question.
The query output that you obtain is perfectly meaningful.
By stating that personaCliente (subject) is a SubClass Of (predicate) worksFor some empresaCliente (object), you're saying that if p is a client person then it must work for some client company.
Note that the object is not a simple super-class, but a complex class expressed by a property restriction.
In other words, you're stating that every client person p works for some blank node _, such that _ is a client company. If you know description logics, read this as persona ⊑ ∃worksFor.empresaCliente.
Now, by querying ?s ?p ?o, you're searching for all the possible triples of your ontology.
Let's focus on the following subset of results:
row s p o
1 _:node31 owl:someValuesFrom :empresaCliente
2 _:node31 owl:onProperty :worksFor
3 _:node31 rdf:type owl:Restriction
9 :personaCliente rdfs:subClassOf _:node31
This bunch of triples means the same as above: every personaCliente is a subClassOf a certain blank node [9], such that this blank node is a subclassOf owl:Restriction (which is a particular OWL class) [3]. This restriction involves property worksFor [2] and states that its range, in this particular case, must be empresaCliente [1].
Further reading:
https://www.w3.org/TR/owl2-syntax/#Object_Property_Restrictions
https://www.cs.vu.nl/~guus/public/owl-restrictions/
I have a problem that is specific. After I load the triples from RDF file thanks to plugin, some properties or relations are look like:
Relation Example ===> [:Country.city]
Property Example ==> city.name
there is a dot in property name and relation name. They can be created thanks to plugin There is no problem. But when i write query from this 127.0.0.1:7474 interface, i cant write dot '.' in property name or relation name. But the property name is contain dot. I need to write it .
Result : Syntax error invalid input '.'
How can I write correctly this property or relation name?
Escape the entire relationship type or property name with backticks.
MATCH (x)-[:`Country.city`]->(y) RETURN x,y
...
MATCH (x)-[:Contain]->(y) WHERE x.`city.name`="London" RETURN x,y
I'd like to make a cypher query that generates a specific json output. Part of this output includes an object with a dynamic amount of keys relative to the children of a parent node:
{
...
"parent_keystring" : {
child_node_one.name : child_node_one.foo
child_node_two.name : child_node_two.foo
child_node_three.name : child_node_three.foo
child_node_four.name : child_node_four.foo
child_node_five.name : child_node_five.foo
}
}
I've tried to create a cypher query but I do not believe I am close to achieving the desired output mentioned above:
MATCH (n)-[relone:SPECIFIC_RELATIONSHIP]->(child_node)
WHERE n.id='839930493049039430'
RETURN n.id AS id,
n.name AS name,
labels(n)[0] AS type,
{
COLLECT({
child.name : children.foo
}) AS rel_two_representation
} AS parent_keystring
I had planned for children.foo to be a count of how many occurrences of each particular relationship/child of the parent. Is there a way to make use of the reduce function? Where a report would generate based on analyzing the array proposed below? ie report would be a json object where each key is a distinct RELATIONSHIP and the property value would be the amount of times that relationship stems from the parent node?
Thank you greatly in advance for guidance you can offer.
I'm not sure that Cypher will let you use a variable to determine an object's key. Would using an Array work for you?
COLLECT([child.name, children.foo]) AS rel_two_representation
I think, Neo4j Server API output by itself should be considered as any database output (like MySQL). Even if it is possible to achieve, with default functionality, desired output - it is not natural way for database.
Probably you should look into creating your own server plugin. This allows you to implement any custom logic, with desired output.
I'm using below query to find all properties with domain of city (or superclasses of city) or range of country (or superclasses of country) from DBPedia ontology. when I use path with fixed length there is no problem but when I put * to define paths with arbitrary length, I get this error:
Virtuoso 37000 Error SP031: SPARQL compiler: Variable
'_::trans_subj_6_4' is used in subexpressions of the query but not
assigned
my SPARQL:
define sql:signal-void-variables 1
define input:default-graph-uri <http://dbpedia.org>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX dbo: <http://dbpedia.org/ontology/>
PREFIX res: <http://dbpedia.org/resource/>
PREFIX owl:<http://www.w3.org/2002/07/owl#>
PREFIX rdfs:<http://www.w3.org/2000/01/rdf-schema#>
select ?property where{
{ ?property rdfs:domain/^rdfs:subClassOf* dbo:City }
UNION
{ ?property rdfs:range/^rdfs:subClassOf* dbo:Country }
}
Also when I put any number instead of *, I get same error. I'm using Virtuoso as DBPedia SPARQL endpoint.
Use VALUES instead of UNION (when you can)
The error Virtuoso is giving you is more about its implementation of property paths and union than the actual SPARQL query. The SPARQL part of the query looks correct. (I can't speak to the Virtuoso specific defines.)
In many places that required union in the original SPARQL standard, you can now use values to specify the particular values that variables can have. It typically leads to more readable queries (at least, in my opinion), and some endpoints, such as Virtuoso, seem to handle it better.
Using values (and using the dbpedia-owl prefix that the web interface to the endpoint uses), you query becomes the following, and Virtuoso returns what you're looking for:
select ?property where {
values (?p ?v) { (rdfs:domain dbpedia-owl:City)
(rdfs:range dbpedia-owl:Country) }
?property ?p ?class .
?class ^rdfs:subClassOf* ?v .
}
SPARQL results
Other Notes
Also when I put any number instead of *, I get same error. I'm using
Virtuoso as DBPedia SPARQL endpoint.
While Virtuoso accepts the {n,m} notation for lengths of property paths, do be aware that while those appeared in some drafts of property paths, they didn't actually make it into the SPARQL 1.1 standard. Virtuoso still accepts them, but if you use them, you might not be able to use your query with other endpoints.
I am a newbie to Neo4j, I have created two nodes with the below Cypher , how can I create a relationship between them ?
CREATE (Someone { name:'Abhilash',from :'Kerala',knows:'java' }) return someone;
CREATE (Someone { name:'Theo',worked :'WALMART',from:'kUNOOR' });return someone;
The relationship is 'Team: QualityControl'.
Second Question
Also I have seen in some create node queries that are using back tick (`) symbols in code.
e.g.
CREATE (_1:`Someone` { `name`:"Abhilash",`from`:"Kerala":,`knows`:"java" })
Whats the difference between the first create statement and the above create statement ?
Can we create properties of nodes as
{key:'Values'} or {<back tick> key <back tick>:"Values"}
where < back tick > is `
Am much confused with the different ways of using tick(`) , double Quote ("") ans single quote (') inside the query . Can any one help me to understand the right scenarios of using these characters ?
Update
thanks for the clarification . i used the below query to create the relationship , but its not returning any result or creating a relationship between my nodes . this is my statement,
MATCH (a:someone),(b:someone)
WHERE a.name = 'Abhilash' AND b.name = 'Theo'
CREATE a-[r:RELTYPE]->b
RETURN r
Backtick is only used if you have a character in a property name or reltype that isn't valid to cypher, such as spaces or hyphens. I recommend avoiding the need to use backticks.
Double quotes and single quotes are interchangeable to represent strings, similar to JavaScript. I usually go the route of using double quotes and escaping internal double quotes with backslash: {dialog:"Joe said, \"Hello World.\""}...
As an aside, you probably don't want to use "Team: Quality Control" as a relationship. That should probably be a node with relationships to each team member.