What does partial mean in owl - semantic-web

I have been reading this document and i encountered the following:
Class(a:adult partial
annotation(rdfs:comment "Things that are adult.")
I understand annotation but what is partial/complete and is it used these days?

partial here means the class adult is a specialization of the annotation, like in Class(a:Cat partial a:Animal)).
The complete specifier means an equivalence, like in the example given in your link:
Class(a:animal_lover complete
intersectionOf(restriction(a:has_pet minCardinality(3)) a:person))
which states that an animal_lover is a person who has at least 3 pets.

Related

Protege 5.0 - OWL : How can I link the sameAs individual property with some other properties?

I am new to ontology design, and I have a project that requires me to match some individuals if they point to the same values for some of their properties.
I've posted some screenshots with the classes, object properties, data properties and individuals here:
https://imgur.com/a/Ak4og
A more "in detail" explanation(CAN ALSO BE DEDUCED FROM THE PICS): I have the class Person, who has a subclass Expert. There are also class FieldOfPractice(subclasses: computer_science, engineering, public_administration, etc.), Expertise(very_low,low,moderate,high,very_high) and Certification(A,B,C,D), Book and Expertise_Community classes.
I have as data properties firstName, lastName, dateAdded, bookName, communityName.
Each Person (so also Expert) has to have hasCertification, hasExpertise, hasFieldOfPractice properties which will all have the obvious range.
The Expert has to have recommendedBooks() and isInExpertCommunity properties.
The requirement: Create some Individuals of type Person, Expert, Book,etc. Make an "inference algorithm" such that for each person who has the same certification, expertise and field of practice as any of the experts, recommendedBooks() and isInExpertCommunity properties are inferred from the corresponding Expert Individuals to the Person Individual.
So for example lets say that: We have an individual Person: Mr.A , who has as object properties hasFieldOfPractice() computer_science, hasCertification() B, hasExpertise() very_low.
We also have an individual Expert: Expert5 with the same values for hasFieldOfPractice(), hasCertification() and hasExpertise() as Mr.A. Expert5 has as recommendedBooks() book1, book6 and for isInExpertiseCommunity() community4.
The "inference algorithm" should infer to Mr.A the recoomendedBooks() book1, book6 and isInExpertiseCommunity() community4. It should also do this if Mr.A matches with another expert who points at different books for reccomendedBooks() and/or another expertise community.
I have also found some similar questions but haven't been able to link the answers properly to my problem:
How to infer isBrotherOf property between two individuals - very good answers, but I need to change the SameAs() property instead of hasBrother() from the question.
Using Property Chains to get inferred Knowledge in an OWL Ontology(Protege) - same problem, but here my SameAs() which I think its predefined, corresponds with the example's employs().
From what I've seen I have to link somehow the sameAs() -> property chain -> rollification concepts, but I don't really get it yet.

Spring Data Neo4j Cypher get entity type or class name

In my SDN 4 project I have a following Cypher query(a part of query):
(entity)<-[:COMMENTED_ON]-(comg:CommentGroup)
for example I can get id of entity with a following Cypher function id(entity)
How to get entity name or class name ?
Use the labels function
match (entity)<-[:COMMENTED_ON]-(comg:CommentGroup) return id(entity), labels(entity)
For each row returned, you'll get the Neo4j id and array of labels.
Assuming your NodeEntity class labels match at least one of these labels, you can then iterate and load the appropriate class instance yourself.
Generally speaking you shouldn't need to do this however.
If (entity) is polymorphic, SDN/OGM will hydrate the correct objects for you. It pretty much does under the hood what I described above, but it also handles matching on interfaces, subclasses, etc.

UML Design class diagram: Class with another class as attribute?

I'm having a pretty hard time trying to figure out how to model a certain scenario as a UML design class diagram.
Suppose I have the following situation:
I have a class named CPoint that has two attributes: x and y (coordinates in a R2 plane). Additionally, I have a class named CLine that should have two CPoint as attributes.
This is pretty straight forward to code (I'll use C++ in my example):
class CPoint{
float x;
float y;
//Constructor, gets and sets here
}
And for CLine:
class CLine{
CPoint p1;
CPoint p2;
//Constructor, gets and sets here
}
Now my question is: How do I model such a thing in UML?
I thought of something similar to this:
But then I was told that this is violating the principles of object oriented modeling, so then I did this:
But it does not convince me at all. Additionally, I was reading about design patterns and came to this UML design while reading about singletons:
Which makes me think my initial approach was just right. Additionally, I'm able to see that my first approach is just alright if I think about it as a C++ program. In Java, however, I'd still have to create the object by doing new CPoint(0, 0) in the CLine's constructor. I'm really confused about this.
So, how do I model this situation? Am I perhaps being too concrete when I attempt to model the situation?
Thanks in advance! This isn't letting me sleep at night
In UML an association or an attribute (property) are more or less the same thing, so they are both correct.
In most UML tools however they are different things.
There is not really a rule here, but there are best practices.
My UML Best Practice: Attribute or Association says:
Use Associations for Classes and Attributes for DataTypes
If your CLine has exactly two ends represented by point, than you can define it in UML as class CLine with attributes (just like your CLine on the first example is OK but without association "has") or you can design it as CLine class with two association to CPoint. Multiplicity at CPoint will be 1 with role p1 for the first one and p2 for the second one at the CPoint side.
There is not one best solution. It depends on the context and what you want to model. I agree with Vladimir that you would have two relations with roles p1 and p2. The members x and y should be private I guess (-x, -y) and not public (+x, +y). Furthermore you could model the relation as aggregate or composite (open or closed diamond symbol) but if a single point can be the endpoint of two lines then that is not appropriate. Again, this depends on what you want to model. If construct a new point in the line constructor as stated in the question, then you probably want to use a composition relation as these points do not exist without the line.
(Btw, in the code the coordinates are float and in the diagram ints).

ArrayList or Aggregation with specified multiplicity

I am just starting with UML (StarUML 5) so please excuse this really basic question.
Let's say a Person has multiple Characteristics, each of which has a Name and a Value. (This is just to keep things simple.) Suppose I create the Characteristic class accordingly.
I want to generate Java class Person with a property something like ArrayList(Characteristic).
Should I add an attribute to the Person class like ArrayList(Characteristic), or should I just use an Aggregation relationship between Person and Characteristic and specify the multiplicity as 0..* ?
On the first (ArrayList) approach I don't even model the multiplicity. On the second (Aggregation) approach the Java code creates a property in Person of type Characteristic but not a "List-like" property, i.e. it ignores the multiplicity in the diagram.
Thank you.
I agree with Dave, this is a composition, a kind of UML association. Setting the composition as Ordered and not unique allows to generate the Java attribute as a List. It means you have a composition at the design level and a List at the implementation level. That's the code generator - or you if you don't use code generation - which correctly translates the UML diagram.
Here's what I would design in your case and the Java code I generated (feel free to fork):
public class Person
{
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* #generated
* #ordered
*/
public List<Characteristic> characteristic;
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* #generated
*/
public Person(){
super();
}
}
Notice you can import StarUML projects in GenMyModel if you'd like to quickly design generate online.
This sounds like a composition relationship to me. In my opinion you're better off with the second approach using Aggregation/Composition. Here is an interesting read on one take on Attribute vs Association. Regarding the failure of StarUML to implement the relationship correctly, you might be better off just implementing the List yourself.

Extra info for model with several types

I want to do some unusual in Django orm.
I have the model Car. How can I extend it with additional information, separated by type, storing in another model?
For example, for entry of Car "My Truck", which type is truck, i want to extend it with TruckInfo model.
Another entry "My Bus" i want to extend with BusInfo model.
In other words, i want to make a floating relationship.
It could be implemented by adding to Car column with type, and performing SELECT twice: 1) for selecting cars, 2) for selecting extra info using Car.Type field. But it is terrible solution. I want to make it in a single query.
Maybe you know solution in pure SQL, it will be useful too. Thx.
It's going to be pretty hard to give you a definitive answer without asking a lot more about your particular needs. However, there's nothing in Django's ORM that prevents you from doing this.
Here's a way to do it -- note that I don't by any means claim that it's the only way, and I might recommend something else if given more clarification on your goals:
class Automobile(models.Model):
[...]
type = models.ChoiceField(choices=(
('car', 'Car'),
('truck', 'Truck'),
('bus', 'Bus'),
))
#property
def detail(self):
return getattr(self, self.type)
class Car(Automobile):
[...]
class Truck(Automobile):
[...]
class Bus(Automobile):
[...]
Be sure that, if you go this route, you'll want to read the documentation on multi-table inheritance: https://docs.djangoproject.com/en/1.3/topics/db/models/#multi-table-inheritance
You also may or may not want the top-level model to be an actual table (see the text just above in the link I gave you for a discussion of abstract models). I can't tell you which to use -- it's specific to what you're trying to do.
You'll also probably want some custom signals that enforce data accuracy -- for instance, to make sure you don't save a Bus record for an automobile of type Truck.
I guess you can also do this:
class Automobile(models.Model):
# ...
class Truck(models.Model):
automobile = models.OneToOneField(Automobile, primary_key=True)
# ...
class Bus(models.Model):
automobile = models.OneToOneField(Automobile, primary_key=True)
# ...
Some explanations here: OneToOneField reference
and an example with more details can be found here: One-to-one relationship example