Re: [protege-user] people example
Michael DeBellis <[email protected]>
| Newsgroups | gmane.comp.misc.ontology.protege.owl |
|---|---|
| Message-ID | <CALGFikcUZ=jzC56B1NZVD7Xp8=MmNGXEFLaPmTuuidgJrMC2vw@mail.gmail.com> |
>
> 1)considering the owa whats the proper use of max and exactly cardinality
> restrictions cause i dont see the reasoner to classify new individuals
It's an interesting question. The simple answer is that they can still tell
you when there is an inconsistency. E.g., if you say Miss_Haversham is an
instance of Hermit but she has more than 0 social relations there is a
problem with your model. You can also find problems with class definitions.
E.g., you may (probably incorrectly) define vehicle as something with
exactly 4 wheels and then add a subclass called SemiTruck that has 6 wheels
or Motorcycle with 2 wheels. These simple examples are trivial but when you
get into complex domains like modeling genes those kinds of axioms can be
useful. Those kinds of axioms can also play a role in redefining the class
hierarchy. With a complex ontology it can often be the case that the
inferred hierarchy is different than the user specified hierarchy.
2)in your tutorial you mention an alternative with insert and delete (page
> 71) can you give an example
That wasn't about the OWA but its equally annoying cousin: monotonic
reasoning. In a logical system you can't say X = 0 then later say X = 1.
That's a contradiction. Since SWRL uses the OWL reasoner, you can't use
SWRL to change the value of a property. E.g., a SWRL rule like: hasAge(?p,
?age) ^ hasBirthDayToday(?p, true) ^ swrlb:add(?new_age, ?age, 1) ->
hasAge(?p, ?new_age) won't do what you want. It won't replace the current
age value but will add another triple with a new value for hasAge. Since
hasAge should be functional that would cause an inconcistency. One way to
deal with this if you want to get fancy is temporal reasoning. Rather than
just saying something is true you say something is true at time T. But an
easier way is to use SPARQL (or a programming language that can access the
knowledge graph) because those aren't constrained to do monotonic reasoning
(or the OWA), i.e., they can change values, not just add them. In SPARQL
(of course this is a toy example, in reality you would use the utilities to
get the current date, compare it to the birthdate, etc.) you could do:
DELETE {?p :hasAge ?age}
> INSERT {?p :hasAge ?new_age}
> WHERE {?p :hasAge ?age
> :hasBirthDateToday true.
> BIND(?age + 1 AS ?new_age)}
That will remove the current value (i.e. triple) for the Person's age and
add a new one with the updated age. I.e., it changes the value rather than
adding a new one.
3)is it possible to add many values to a property from ui?
I've actually mentioned this myself. I think it would be good to have
something similar to the Create Class Hierarchy or Create Property
Hierarchy where you add multiple instances of the same class all at once. I
added this as a feature request on the Protege Github repo a while ago:
https://github.com/protegeproject/protege/issues/1195 There is a matrix
plugin that has an Individuals Matrix. I'm not sure if you can copy and
paste values into that. I just tried and couldn't do it but I thought I
remembered at one point it was possible, perhaps I'm not doing it right.
Here's what it looks like. One drawback is it doesn't have inferred values,
that's why all the is_author_of values are empty below. Best thing is to
use Cellfie or if you can access your ontology from a programming language
use the csv library in Python or some other tool to write a little program
that reads in values. That's what I do because it gives you the most
control.
[image: Individuals Matrix.png]
4)i found something called rif and sparql-based constraints that can help
> with owa is there a plugin for them?
Is it "rif" or "rdf"? In any case I don't know what those are and to my
knowledge there is no plugin for them. Anyone else know??
5)in my ontology i want to make some arithmetic using the snap sparql query
> but dont seem to support it, also tried union,bind,not nothing seems to work
> i want to make a simple query that sum the credits from some courses and
> return (48-sum)/6
> any help would appreciated
There are, unfortunately, a lot of things that Snap SPARQL doesn't support.
E.g., it is often useful to have a wildcard for the predicate ":Joe ?p ?o"
would find all the property values for the instance :Joe but that won't
work in Snap SPARQL either. The other SPARQL tab also doesn't support the
full SPARQL specification. For the most part, I only use SPARQL in Protege
to do queries and to add instances and data using CONSTRUCT. Other than
that, when I have anything non-trivial to do I use a different tool. You
might try one of the commercial triplestores. I mostly use AllegroGraph.
They have a tool called Gruff where you can do a SPARQL query and then
visualize the graph of matching objects and manipulate the graph in endless
ways. The free version of AllegroGraph never times out and supports all the
AllegroGraph features. The limitation is it only supports up to 5M triples
which is a lot. Protege can handle ontologies with that many triples but
when you get to that level, especially if you have lots of axioms, Protege
starts to get slow. Not a criticism of Protege, it's a modeling tool not a
database. With AllegroGraph you also get Java and Python clients (and even
Lisp which alas no one uses anymore). That's what I usually use to write
Python programs like the one I mentioned to load data from a CSV file.
Stardog and OntoText are also very good. I like the Stardog UI much better
than the AllegroGraph one. Just my opinion but Stardog seems to be targeted
more towards casual users where as AllegroGraph is targeted toward hard
core nerds. The Stardog equivalent of Gruff looks much cooler (and I've
used it for some demos for that reason) but Gruff offers at least an order
of magnitude more options for manipulating the graph both visually and
changing the actual triples. I don't know Stardog and Ontotext as well so
take this with a grain of salt but I think Stardog's free version limits
you to 1M triples. One nice thing about Stardog is it has a real IDE for
writing SPARQL. That's what I mean about AllegroGraph being for the hard
core nerds. Guys who think real programmers use VI.
I think OntoText has no limit on their free version, they only constrain
you on number of concurrent users. But I just saw a presentation from
Ontotext today and they have merged with another vendor called Pool Party.
The new company is called GraphWise. Pool Party is also a Semantic Web
company but they have tools, not a triplestore, although I think they had a
default one as well but what you paid for with Pool Party were their tools
for tagging, content and knowledge management. My point is that the merger
may affect the OntoText policy on their free version. There is also Apache
Jena: https://jena.apache.org/ It has a library so you don't have to use a
triplestore if you don't need one, but it also has a triplestore database
called TDB. Of course since its Apache it is free and open source.
Michael
https://www.michaeldebellis.com/blog
On Wed, Feb 5, 2025 at 9:05 AM stathoula terzidou <[email protected]>
wrote:
> thanks i finished the pizza tutorial, very helpful guide, just trying to
> make an ontology and facing some issues about:
> 1)considering the owa whats the proper use of max and exactly cardinality
> restrictions cause i dont see the reasoner to classify new individuals
> 2)in your tutorial you mention an alternative with insert and delete (page
> 71) can you give an example
> 3)is it possible to add many values to a property from ui?
> 4)i found something called rif and sparql-based constraints that can help
> with owa is there a plugin for them?
> 5)in my ontology i want to make some arithmetic using the snap sparql
> query but dont seem to support it, also tried union,bind,not nothing seems
> to work
> i want to make a simple query that sum the credits from some courses and
> return (48-sum)/6
> any help would appreciated
>
> Στις Τρί 4 Φεβ 2025 στις 4:11 μ.μ., ο/η Michael DeBellis <
> [email protected]> έγραψε:
>
>> I have a People ontology on my blog and I talk about the OWA and give
>> examples of how certain axioms that one would expect to trigger reasoning
>> (e.g., a Hermit is a subclass of Person with 0 hasSocialRelation) don't due
>> to the OWA:
>> https://www.michaeldebellis.com/post/the-people_example-ontology But I
>> never wrote SHACL to show how to correctly deal with such constraints for
>> the ontology (although I have thought about doing it, just never got around
>> to it). I do mention SHACL in the document that describes the ontology but
>> I just double checked and I don't actually walk through how to use the
>> SHACL plugin in that document.
>>
>> In the revised Pizza tutorial:
>> https://www.michaeldebellis.com/post/new-protege-pizza-tutorial I do
>> have SHACL examples in chapter 11 (e.g., each Employee at the Pizza
>> restaurant must have exactly one socialSecurityNumber and it must have the
>> format NNN-NN-NNNN, where N is an integer). I think it would be rather
>> straight forward to take those examples and make them work with the People
>> ontology. If you want to do that take a look at what I wrote and give it a
>> shot and if you have problems let me know, I can probably help you get it
>> to work.
>>
>> Michael
>> https://www.michaeldebellis.com/blog
>>
>> On Tue, Feb 4, 2025 at 12:24 AM stathoula terzidou <[email protected]>
>> wrote:
>>
>>> Hello think i saw somewhere a tutorial with workarounds for owa about
>>> the people example but cant find it now anyone have it?
>>> _______________________________________________
>>> protege-user mailing list
>>> [email protected]
>>> https://mailman.stanford.edu/mailman/listinfo/protege-user
>>>
>> _______________________________________________
>> protege-user mailing list
>> [email protected]
>> https://mailman.stanford.edu/mailman/listinfo/protege-user
>>
> _______________________________________________
> protege-user mailing list
> [email protected]
> https://mailman.stanford.edu/mailman/listinfo/protege-user
>
_______________________________________________
protege-user mailing list
[email protected]
https://mailman.stanford.edu/mailman/listinfo/protege-user
Individuals Matrix.png
(image/png, 104.7 KB) - not displayed