I'm using pizza ontology, and there is this object property called hasCountryOfOrigin. This object property doesn't have specific domain and range, probably because the domain can be pizza or pizzaTopping. For other object properties, for example hasBase, I can find where it's used with ontology.getAxioms(AxiomType.OBJECT_PROPERTY_DOMAIN) because it has domain and range. So how can I find where hasCountryOfOrigin is used using OWLAPI?
You can use:
Searcher.values(ontology.axioms(AxiomType.OBJECT_PROPERTY_ASSERTION), property);
This will provide all assertions that have property as the property, e.g., all axioms of the form subject property value.
You can then iterate over the axioms and check the types for the subject and object to infer possible domains and ranges from usage.
(Note that these do not force the property to have these classes as domains or ranges; it's just that those classes would not surprise a reasoner or a human looking at the ontology, if they were to be asserted to be domains or ranges of the property.)
Related
I have some complex property types such as polygon in my RDBMS, and I want to convert them into neo4j, but in reading the official documentation, I find that the property type should be bool/byte/short/int/log/float/double/char/string. I am wondering, does neo4j support complex property types?
It depends on how "complex" the data needs to be. In addition to the scalar types that you listed, a neo4j property can also contain an array of one of those types.
So, for instance, you could store the coordinates of an N-vertex polygon in an array of size 2*N, where each X/Y pair is stored as consecutive numbers. No "complex" type is really needed.
is there any way individual (instance) connect to class with object property? For example, individual in this case is module name: Web Programming. Object property : isClassified. Class: Network.
I've tried to define Web Programming as class, and it works because the domain and range are both classes. Same goes if I define both Web Programming & Network as individuals, it works. If the domain is a class and the range is individual, it still works. But what if the domain is individual and the range is class? Is there any way I can connect it with object property: isClassifiedIn?
Protégé is an OWL 2 DL editor (since version 4). In OWL 2 DL, an individual cannot be a class, and an object property must relate individuals to individuals only. So what you want cannot be expressed in the way you formulate it. However, you could do two things:
use an annotation property instead of an object property. This may not be ideal because an OWL DL reasoner must ignore annotation properties in the reasoning process. They are just that: annotations, similar to comments in a programming code.
relate the individual to another individual that has the same name as the class. Let me give details about this.
In OWL 2 DL, although it is not possible for individuals to be classes, it is possible for individual names to be class names at the same time. For instance, one can say (in Turtle syntax):
ex:Module a owl:Class .
ex:Network a owl:Class, owl:Thing .
ex:isClassified a owl:ObjectProperty .
ex:webProgramming a ex:Module;
ex:isClassified ex:Network .
Note that ex:webProgramming here is not related to a class. It is related to an individual of type owl:Thing. This individual has nothing to do, a priori, with the class named ex:Network, although it has the same name. This is called "punning" in the OWL 2 specification.
There is a third way: change your knowledge model such that you do not encounter this problem. I do not know your ontology, but it could be hinting at an antipattern that you should avoid.
You have to use "value".
Write your own expression using the class expression editor.
Select the class Than write:
"property" value "individual"
In my Neo4j/SDN project I have to implement a following task - I have a parent Node(let's say ParentNode) that must define a set of product characteristics, for example:
weight: Double
size: Integer
license: String
active: Boolean
Also, new product characteristics(with any new name and type) can be added during the application runtime.
ParentNode can have a set of child nodes(let's say ProductNode) and each of these nodes can provide an own value for a certain characteristic defined by a ParentNode.
Based on these characteristics names and values I need to have possibility to filter a ProductNode nodes.
Previously this structure have been implemented by me by SDN3 DynamicProperties but AFAIK - DynamicProperties support has been removed from SDN 4.
So my question is - how to implement the following structure based on SDN 4 ?
UPDATED
Also, how about the idea to define every ParentNode characteristic as a separate node(let's say CharacteristicNode)
for example
CharacteristicNode.name = weight
CharacteristicNode.type = Double
CharacteristicNode.name = license
CharacteristicNode.type = String
...
and every ProductNode can provide a value node(CharacteristicValueNode) associated with ProductNode and CharacteristicNode.
The main question here how to support different types for CharacteristicValueNode and how to filter ProductNode nodes based on different characteristic and their values?
In SDN 4, you can model these properties as a Map of (property name, value) and write a custom converter. This will convert the Map to a String property on the node (json style perhaps), and then from the graph back to your Map.
The downside to this is that it is not easy to write a custom query for these dynamic properties because they're not really stored in the graph as independent properties- rather, your converter will squash them into a single one.
Update
If you were to define each Characteristic type as a node (in your example, you would have 4 nodes- one representing each of weight,size,active,license), then you don't need an intermediate CharacteristicValueNode to relate the ProductNode and the CharacteristicNode. Instead, you can model the value of the produce for the characteristic on the relationship between the ProductNode and CharacteristicNode.
For example, if the ProductNode had only weight and size, then you would have two relationships- one from ProductNode to the weight CharacteristicNode with the weight value on the relationship, and another from the ProductNode to the size CharacteristicNode with the size value on that relationship.
In SDN 4, these would be modelled as RelationshipEntities. For example,
#RelationshipEntity(type="CHARACTERISTIC")
public class ProductCharacteristic {
Long id;
#StartNode ProductNode product;
#EndNode CharacteristicNode characteristic;
int value;
...
}
The ProductNode would contain a collection of these relationship entities
Set<ProductCharacteristic> characteristics;
Then you can query for products related to characteristics with a certain name. Or query for ProductCharacteristic with findByCharacteristicName
I haven't really tried this approach out, but it is worth thinking about the change that this forces in your underlying graph model to support dynamic properties.
Is possible to define a data property of a class as the number of individuals of another class, and this number is computed automatically.
There is no functionality for counting already available, far as I know.
It could be implemented for asserted axioms, but I don't think it can be guaranteed to work reliably. The open world assumption and the default non unique name assumption mean that it's impossible to say if there are unknown individuals or if any of the known individuals are sameAs each other.
The W3C TAG published the Working Draft URLs in Data Primer last month. It specifies a solution for the httpRange-14 issue.
Now vocabularies should specify categories for their properties, i.e. if a property applies to the document or to an entity described by the document.
How should/could RDF vocabularies specify the categories for properties today?
It says that metaformats (→ RDF) should specify a default category for properties and schema languages (→ RDFS) "should include mechanisms for indicating the category of a property". But I guess it will take some time until those specifications are updated.
Generally, I think that there is no such standardised method today, because right now you still need to differ between a thing and a document that holds a description of the thing. However, you may specify/create an owl:AnnotationProperty to indicate the type of a property in an RDF vocabulary.