Problem in Infer Data Property in Protege - ontology

I have a two disjoint ontology classes Book and Learner.
hasRated is an object property that links Learner with book
e.g. Learner hasRated Book
withRatingValue is a data property with Domain as Learner
e.g. Learner withRatingValue 5
How to infer withRatingValue of Book by the Learner?
I want to infer:
Learner (Class) hasRated (Object Property) Book (Class) withRatingValue (DataProperty) 5 (Value)

This situation matches a general pattern, i.e., how to define an n-ary relationship, where you have two individuals and want to describe a relation between the two that has extra attributes. The common solution to this is to introduce an anonymous individual representing the relation, with object and data property departing from the anonymous individual.
See https://www.w3.org/TR/swbp-n-aryRelations/#useCase1 for examples.

Related

Fetching all attribute names that have the same value in Core Data

Say you have a Core Data model with Entity Subjects and Attributes Algebra, Biology, Calculus, Chemistry, Physics, like this:
Subjects
======
Algebra (Boolean)
Biology (Boolean)
Calculus (Boolean)
Chemistry (Boolean)
Physics (Boolean)
Let's say that Algebra, Calculus, and Physics are true while Biology and Chemistry haven't yet been assigned values. How can I get the array: ["Algebra", "Calculus", "Physics"]? I would think it involves NSPredicate but I'm really not sure how to do it.
And as a side question, would default values matter here? i.e., should I make everything start off as false?
Thank you!
You propose an entity named Subjects, with attributes named Algebra, Biology, etc, each of which is a boolean that represents whether the user has "learned" that subject. From that, you wish to compose an array comprising all the names of the subjects that the user has learnt.
Although that is possible, it's quite difficult. I recommend instead defining your Subject entity as:
Subject
=======
name (String)
learnt (boolean)
(Note the convention that entity names are usually singular and start with uppercase, whereas attribute names begin with lowercase.) In the first run of your app you might then create a number of instances of the Subject entity, with the required default values:
name learnt
==== ======
"Algebra" false
"Biology" false
"Calculus" false
... ...
This has the advantage that you can add further subjects at a later date, without needing to modify the structure of your data: it is a simple matter of creating an additional instance with the appropriate name.
As your user progresses through their learning in the app, you can set the value for the learnt attribute to true for the relevant Subject instance. To obtain an array containing only those Subject instances which the user has successfully learnt, you can then use a fetch request with a predicate:
fetchRequest.predicate = NSPredicate(format:"learnt == true")
The array that is returned contains the relevant instances of the Subject entity. It is then simple to obtain the names for display purposes.
You mention in comments having further information about all the subjects. If you model all that in CoreData (eg. having Topic, Lesson, Test entities, etc - I speculate, that's for you to design) you can create relationships to that data from your Subject entity. For example, a Subject might have a relationship to many Topics, each of which has many Lessons and many Tests, etc. That way, when your app starts, you can fetch all the Subject instances and display them in a tableView (showing the name attribute). When the user taps a Subject to begin or continue their learning, you have the relevant Subject instance which provides the link (via the relevant relationship) for you to display the material for the chosen subject.

Is the major difference between RDF and Labelled Property Graph?

For example, Barack Obama, in Labelled Property Graph, the birth date (1965) would be modeled as a Property of the entity BarackObama, without using a relation. But in RDF, i.e. freebase, BarackObama is linked through a relationship (birth_date) to a value '1965'. In these two cases, the former involves only one entity without relationship, but the latter, two entities are involved, "BarackObama" and "1965" with a relationship.
Is this the major difference?

Reasoning over an ontology in jena

I am new in the field of ontologies and reasoning in Jena and I am in desperate need for help to get the logic of how to do the following. I am building and owl ontology with the following classes:
-A person hasInterests Interests
- A person hasMessage Message
- A message hasCategory Category ( or subclass of message)
- A message can be spam or ham ( subclasses of message)
I want to say if the message's category is the same as the person's interests then the message is ham
Q1: I wanted to build the ontology such that the reasoner would infer this so I thought of defining ham as an intersection of class category and interests and that spam is complemet to this intersection class . Is this applicable using a reasoner or shall I need SPARQL queries
Q2:How to create individuals and do the following inference :
hana is a person
message1 is a message
sports is a category
movies is an interest
how to infer that since the sport is not equal to movies then message1 is spam.
I am in desperate need to be directed how to implement this and what exactly to refer to to do so for my masters thesis
The easiest way of doing so (I'm a newbie, but I just succeeded to make inference in ontologies x_x), is by creating your ontology with Protégé and thinking about the concepts you want to link...
You have categories and interests that are pretty abstract, compared to message and person. You have to think about how to link them, and to which classes they belong.
Concrete vs Abstract... Objects vs LivingBeing... Animals vs Plants...
It's an example.
When you are okay with these, you can implement them with Protégé (as it's a graphical tool, it's easier at the beginning) : check the "Entities" tab, and the "Classes" subtab.
Then, you put rules and properties. (the hardest part)
Typically, what is concrete is NOT abstract... so you have to disjoint the two within their properties.
And if you expect some relations to make a "real" ontology, you have to define your own properties (a person can "own" objects, for example... but an object does not "owns" a person).
When you have your basic ontology builded. You have to check if some inferences can be done (search within protégé the "reasoner" menu, and activate one of them, and synchronise it regularly).
Finally, you can add individuals inside, and fill their properties (search for a subtab named "Individuals").

Is it possible to have a specialization in EER Model that is purely attribute/condition defined

In EER modelling is it possible and correct to have a disjoint specialization where none of the sub-classes have any specific attributes(local to them) but are entirely grouped on the basis of a defining attribute.For example we can have a USER entity with some attributes of which one is "role".Based on value of role(admin or author or editor) we will have the subclass entities ADMIN ,AUTHOR and EDITOR.None of them has any attributed which are only specific to them.Also please note that the specialization is disjoint and the superclass entity USER has total participation.
And if this is possible, can I convert it to relational model by creating a single relation for the superclass entity USER
Yes, it's possible and valid to do so if you want to record relationships that are restricted to the subtypes. If you don't have subtype-specific attributes or relationships, there's no point in distinguishing subtypes in the ER model. A simple role attribute on the User is sufficient for queries.
If you define subtypes in the ER model, this converts to a relation per subtype in the relational model. If you're looking for something like dependent types, you won't find it in the relational model, which corresponds to first-order logic. ER is even more limited.

What is the difference between Named Entity Recognition and Named Entity Extraction?

Please help me understand the difference between Named Entity Recognition and Named Entity Extraction.
Named Entity Recognition is recognition of the surface form of an Entity (person, place, organization), i.e. "George Bush" or "Barack Obama" are "PERSON" entities in this text string.
Entity Extraction will extract additional information as attributes from the text string. For example in the sentence "George W. Bush was president before President Obama" recognizing "Obama" as a person with attribute "title=president".
But if you look at software the distinction is often blurred.
There is no such a thing as Named Entity Extraction.
Paraphrasing better the sentence I would say that Named Entity Extraction is simple the process of concrete extracting previously recognized named entities. So, in a sense, there is no real theoretical knowledge that is relevant to this task, is just a matter of defining the mechanical operation.
If we are instead interested in extracting all the specific entities or the additional information regarding them from a piece text, than we have to look at information or knowledge extraction.
For information extraction you could for example ask to extract all the names of cities, or e-mail addresses, that appear in a corpus of documents. For such a task Named Entity Extraction could be used. You could even go much more generic, asking simply to extract general knowledge, for example in the form of relations (relation extraction).
For more details I would suggest the Natural Language Processing chapter of the book Artificial Intelligence: A Modern
Approach.

Resources