protege | source ontology editor that supports the latest OWL | Data Manipulation library
kandi X-RAY | protege Summary
Support
Quality
Security
License
Reuse
- Initialise the checkboxes
- Updates the view based on the given property
- Adds a setter to the given checkbox
- Configure the setters
- Initialize the wizard
- Displays the currently selected panel
- Sets the current panel to the specified object
- Initialize the UI
- Updates whether or not the given orcid is enabled or not
- Main method for testing
- Creates the center panel
- Loads imports and imports
- Rebuild the view menu items
- Initialise the preview
- Creates the center panel for the document
- Paints the icon
- Initialise the OL view
- Prepare the styles
- Provides a renderer for the given value
- Creates the UI
- Gets the tool tip text
- Layout the lines
- Update the node
- This method initialises the panel
- Create and copy the view
- Paint the action icon
protege Key Features
protege Examples and Code Snippets
Trending Discussions on protege
Trending Discussions on protege
QUESTION
I have a question about querying the object properties that can be defined between classes.I have created triples using the protege ontological approach where,I have created two classes named "A" and "B" with instances A1, A2, A3, and B1, B2, and B3 respectively.
I have added an object property "aToB". Now I want to write a Query that can query the instances under each class using the object property.for which I have written the following QUERY
PREFIX rdf:
PREFIX owl:
PREFIX rdfs:
PREFIX xsd:
PREFIX :
SELECT ?x ?y
WHERE { ?x :AtoB ?y}
however, upon doing this procedure nothing is returned can you tell me what is the issue?
I am adding the TTL code:
@prefix : .
@prefix ab: .
@prefix owl: .
@prefix rdf: .
@prefix xml: .
@prefix xsd: .
@prefix rdfs: .
@base .
rdf:type owl:Ontology .
#################################################################
# Object Properties
#################################################################
### http://www.semanticweb.org/arash#aToB
ab:aToB rdf:type owl:ObjectProperty ;
owl:inverseOf ab:bToA ;
rdfs:domain ab:A ;
rdfs:range ab:B .
### http://www.semanticweb.org/arash#bToA
ab:bToA rdf:type owl:ObjectProperty .
#################################################################
# Classes
#################################################################
### http://www.semanticweb.org/arash#A
ab:A rdf:type owl:Class .
### http://www.semanticweb.org/arash#B
ab:B rdf:type owl:Class .
#################################################################
# Individuals
#################################################################
### http://www.semanticweb.org/arash#A1
ab:A1 rdf:type owl:NamedIndividual ,
ab:A ;
ab:aToB ab:A1 .
### http://www.semanticweb.org/arash#A2
ab:A2 rdf:type owl:NamedIndividual ,
ab:A ;
ab:aToB ab:B2 .
### http://www.semanticweb.org/arash#A3
ab:A3 rdf:type owl:NamedIndividual ,
ab:A .
### http://www.semanticweb.org/arash#B1
ab:B1 rdf:type owl:NamedIndividual ,
ab:B ;
ab:aToB ab:A1 .
### http://www.semanticweb.org/arash#B2
ab:B2 rdf:type owl:NamedIndividual ,
ab:B .
### http://www.semanticweb.org/arash#B3
ab:B3 rdf:type owl:NamedIndividual ,
ab:B ;
ab:aToB ab:A3 ;
owl:topDataProperty "" .
[ ab:aToB ab:A1
] .
### Generated by the OWL API (version 4.5.9.2019-02-01T07:24:44Z) https://github.com/owlcs/owlapi
ANSWER
Answered 2022-Apr-03 at 18:52The prefix in your query is missing the closing #.
QUESTION
I have built a small ontology in Protege to test punning with a SPARQL query. The Ontology is:
And the SPARQL query that i am using to test the pun entity (GE) is:
SELECT ?y ?x ?z
WHERE {
?x a ?y.
?z a ?x.
?z :Lives_in :CPZ.
}
ANSWER
Answered 2022-Mar-11 at 14:06Harry is a GE, from your assertions. GE is both a class and an individual; so GE appears in other statements as well, and that's multiplying the answers you're seeing. It's analogous as joining across tables where the join value matches multiple rows in one of the tables involved.
QUESTION
Is the following interpreted as the intersection (AND) in the sense that members of class A are members of B and C; or as the disjunction (OR) that members of A are a member of B, or a member of C, or member of both?
A rdf:type owl:Class ;
rdfs:subClassOf some B;
rdfs:subClassOf only C.
Thanks for clarification how this is interpreted!
I found it as AND: Protege OWL Subclass of two classes
But Hermit breaks it and uses single axioms (e.g. A rdfs:subclassOf B) as explanation for A to B. I thought that would not be possible ...? Since I would say that A is a subclassOf (B and C) and not only A.
ANSWER
Answered 2022-Feb-01 at 00:33I can quote RDFS, and considering OWL should follow from that, I don't expect any difference there:
If a class C is a subclass of a class C', then all instances of C will also be instances of C'. The
rdfs:subClassOf
property may be used to state that one class is a subclass of another.
Class inheritance axioms in RDFS are built so that a contradiction can never occur, thus a statement like this can only be "additive" in a sense. Additionally, from the nature of triples in RDF, we know that A rdfs:subClassOf B, C.
means A rdfs:subClassOf B. A rdfs:subClassOf C.
.
Expressed in the language of sets, such a construction means A ⊆ B ∧ A ⊆ C. Any member of A is also a member of B, and any member of A is also a member of C, thus any member of A must be a member of both B and C. We can see that A ⊆ (B ∩ C), from the duality of set and logical operators.
Expressed equivalently, any member of B not found in C must also not be in A (and the same for B and C swapped).
QUESTION
ANSWER
Answered 2022-Jan-29 at 14:10Here is my approach based on this answer. See also this notebook for outputs.
import pandas as pd
from rdflib import Graph, URIRef, Namespace
d = {
"source": pd.Series(["Edwin", "Reema", "Ron", "Tomorrow"]),
"target": pd.Series(["football", "karate", "singer", "holiday"]),
"edge": pd.Series(["plays", "plays", "is", "is"]),
}
df = pd.DataFrame(d)
g = Graph()
n = Namespace('http://example.org/foo/')
for inded, row in df.iterrows():
# add triple to rdf-graph
g.add((URIRef(n+row["source"]), URIRef(n+row["edge"]), URIRef(n+row["target"])))
print(g.serialize(format='turtle'))
With some additional visualization code (based on https://stackoverflow.com/a/61483971/333403) you arrive at:
QUESTION
I tried to create different individual axiom using OWLAPI 5 in Java. What I want is simple triple using vocab owl:differentFrom like:
test:A owl:differentFrom test:B
But what I get is triple using owl:AllDifferent:
_:genid234 rdf:type owl:AllDifferent
_:genid234 owl:distinctMembers _:genid236
_:genid236 rdf:rest _:genid235
_:genid236 rdf:rest rdf:nil
_:genid235 rdf:first test:A
_:genid235 rdf:type rdf:List
_:genid236 rdf:first test:B
_:genid236 rdf:type rdf:List
And the simple code is:
OWLNamedIndividual op1 = factory.getOWLNamedIndividual(baseIRI + A);
OWLNamedIndividual op2 = factory.getOWLNamedIndividual(baseIRI + B);
ont.add(factory.getOWLDifferentIndividualsAxiom(op1, op2));
And I already tried it with Protege 5.5.0, it produce exactly the same triple as OWLAPI.
ANSWER
Answered 2021-Dec-23 at 13:03There is an alternative implementation of OWLAPI-v5 that provides a direct way to work with underlying RDF data - ONT-API (by the way, RDF based Protege version also exists). If working via OWLAPI interface for two operands it produces a single triple.
Also it is possible to copy ontology between ont-api manager and owl-api-impl managers, if you prefer to store the data in the form of OWL axioms and need to solve only this particular problem with serialization.
example:
String iri = "http://test#";
OWLDataFactory factory = OntManagers.getDataFactory();
Ontology ont = OntManagers.createManager().createOntology();
ont.asGraphModel().setNsPrefix("test", iri);
OWLNamedIndividual ia = factory.getOWLNamedIndividual(iri + "A");
OWLNamedIndividual ib = factory.getOWLNamedIndividual(iri + "B");
OWLNamedIndividual ic = factory.getOWLNamedIndividual(iri + "C");
ont.add(factory.getOWLDifferentIndividualsAxiom(ia, ib, ic));
ont.add(factory.getOWLDifferentIndividualsAxiom(ia, ic));
OntModel g = ont.asGraphModel();
g.createIndividual(iri + "D").addDifferentIndividual(g.createIndividual(iri + "C"));
g.createDifferentIndividuals(g.createIndividual(iri + "e"), g.createIndividual(iri + "g"));
g.write(System.out, "ttl");
System.out.println("=".repeat(42));
ont.axioms().forEach(System.out::println);
out:
@prefix owl: .
@prefix rdf: .
@prefix rdfs: .
@prefix test: .
@prefix xsd: .
[ rdf:type owl:AllDifferent ;
owl:members ( test:e test:g )
] .
test:g rdf:type owl:NamedIndividual .
test:B rdf:type owl:NamedIndividual .
[ rdf:type owl:Ontology ] .
test:e rdf:type owl:NamedIndividual .
test:C rdf:type owl:NamedIndividual .
test:A rdf:type owl:NamedIndividual ;
owl:differentFrom test:C .
test:D rdf:type owl:NamedIndividual ;
owl:differentFrom test:C .
[ rdf:type owl:AllDifferent ;
owl:distinctMembers ( test:A test:B test:C )
] .
==========================================
Declaration(NamedIndividual(test:g))
Declaration(NamedIndividual(test:e))
Declaration(NamedIndividual(test:D))
Declaration(NamedIndividual(test:C))
Declaration(NamedIndividual(test:B))
Declaration(NamedIndividual(test:A))
DifferentIndividuals(test:C test:D)
DifferentIndividuals(test:A test:C)
DifferentIndividuals(test:e test:g)
DifferentIndividuals(test:A test:B test:C)
QUESTION
We define a class A as owl:equivalentClass and a class A2 as rdfs:subClassOf based on the intersection (AND) of instances having a relation a_to_b and a_to_c with an instance of B or C respectively. Please see the example:
:A rdf:type owl:Class ;
owl:equivalentClass [ owl:intersectionOf ( [ rdf:type owl:Restriction ;
owl:onProperty :a_to_b ;
owl:someValuesFrom :B
]
[ rdf:type owl:Restriction ;
owl:onProperty :a_to_c ;
owl:someValuesFrom :C
]
) ;
rdf:type owl:Class
] .
Here as a subclass:
:A2 rdf:type owl:Class ;
rdfs:subClassOf [ owl:intersectionOf ( [ rdf:type owl:Restriction ;
owl:onProperty :a_to_b ;
owl:someValuesFrom :B
]
[ rdf:type owl:Restriction ;
owl:onProperty :a_to_c ;
owl:someValuesFrom :C
]
) ;
rdf:type owl:Class
] .
What is the reason to use owl:equivalentClass and when would I use rdfs:subClassOf? The distinction and what is really expressed at the end is not fully clear to me.
My further observation / questions:
a) When I create an instance x with triples: (x, a_to_b, b1) and (x, a_to_c, c1), x is automatically reasoned as a type of A but not of A2. (Using Protege with Hermit Reasoner) (c1 is type of C and b1 is type of B).
b) When I create an instance y and assign y the type A and A2 manually, would this be an issue if y has no relation to an instance of B via a_to_b and no relation to an instance of C via a_to_c? The Hermit Reasoner does not show any signs of an issue but is that not a necessary (must be fulfilled) condition for class A?
c) Are these statements true for A:
c1) If I know that z is from type A, it must have a relation a_to_b with an instance of B and it must have a relation a_to_C with an instance of C.
c2) If I know that z have a relation a_to_b with an instance of B and it have a relation a_to_C with an instance of C, z must be of type A.
c3) A is the class of all things that have a relation a_to_b with an instance of B and have a relation a_to_C with an instance of C.
Can I say c1 and c3 also about A2 or how to the statements change?
The meaning is not clear to me. I hope someone can clarify things. Thanks in advance
ANSWER
Answered 2021-Dec-23 at 09:25I think the first thing to be aware of is that equivalence, say D equivalentClass E
, is an abbreviation for D subClassOf E
and E subClassOf D
. The semantics of subClassOf
is subset. This means that the set D
is a subset of set E
and set E
is a subset of D
, which means set D
and set E
are exactly the same set. We say they are equivalent.
Note now the semantics of subClassOf
. If I know F subClassOf E
and G subClassOf E
, what can I say about how F
and G
relates to each other? Absolutely nothing. It is a bit like knowing a bicycle and a truck are both vehicles. That does not make a bicycle a truck or a truck a bicycle, though both are vehicles.
Thus, in your example, A
can be expanded to the 2 axioms
A subClassOf (a_to_b some B) and (a_to_c some C)
(a_to_b some B) and (a_to_c some C) subClassOf A
Answers to your questions:
(a) With the assertions for x
as you have it, we can see that x
is indeed an instance of A
. However, there is no information wrt x
that makes it possible for us to say x
is of type A2
. All we know is that both x
and A2
are subclasses of (a_to_b some B) and (a_to_c some C)
.
(b) This is due to the Open World Assumption, which means the reasoner does not make any assumptions based on the absence of information. If you have not stated explicitly that y
has no a_to_b
relation to B
, it will assume that an a_to_b
relation exists but is merely not known. This is as opposed to the closed world assumption made by databases usually. I.e., if no employer information exists for a client the assumption is often made that the client is not employed.
You can state that y
has no a_to_b
relation by stating that a_to_b max 0 B
. The reasoner will then give an inconsistency.
(c1) yes, but these may not be known currently due to the open world assumption.
(c2) yes, based on the semantics of equivalence
(c3) yes.
This is not true for A2
because it is merely a subclass rather than all things that have a relation a_to_b with an instance of B and have a relation a_to_C with an instance of C.
When to use equivalent vs subClassOf
Equivalence is used for definitions. That is when you want to state the necessary and sufficient conditions for something to be called an A
(from your example).
SubClassOf is used when you want to define a hierarchy from most general to most specific. I.e., it is typically what you see in taxonomies and in programming you will see it as object oriented class hierarchies.
QUESTION
I would like to infer an anonymous class definition for my Individuals in Protege.
I have a simple Ontology with the Classes Rain NoRain and Scene
, The object Property has_weather
. My desire is to be able to infer "has_weather(?x, ?noRain), NoRain(?noRain), Scene(?x) -> (has_weather exactly 0 Rain)(?x)
which i wrote in the Rules tab, where i can mix SWRL and OWL Expressions.
I am using Pellet Reasoner, however I also tried with OnTop and Hermit and none works. For example if I do the rule the other way around:
`has_weather(?x, ?noRain), (has_weather exactly 0 Rain)(?x), Scene(?x) -> Test(?x)`
It works without problems.
Is the problem, that Protege just can't infer anonymous classes? Is there any workaround? Thank you in Advance!
here is the code to the ontology
0
`
ANSWER
Answered 2021-Sep-08 at 11:05In general a set of axioms has an infinite amout of entailments. See for example this paper. For this reason reasoners restrict inferences to known classes (not anonymous classes). I suspect this holds true for rules as well.
I therefore suggest you add a class NoRain
that you set equivalent to has_weather 0 Rain
and change your SWRL rule to use the class NoRain
.
QUESTION
I am using Protege
to explore the SSN ontology,
but a lot of classes like the survivalRange seem to be missing from the main file.
How could I import all the classes and entities of the ssn-system
,
without importing them manually one by one by the IRI?
ANSWER
Answered 2021-May-27 at 05:50You can import http://www.w3.org/ns/ssn/systems/
, which itself imports http://www.w3.org/ns/ssn/
.
QUESTION
I am reading an XML/OWL file (generated from Protege) in Jupyter notebook.
I can read the root element, but for children its showing error/blank.
from xml.dom.minidom import parse
DOMTree = parse("pressman.owl")
collection = DOMTree.documentElement
if collection.hasAttribute("shelf"):
print("Root element : %s" % collection.getAttribute("owl:ObjectProperty"))
for objectprop in collection.getElementsByTagName("owl:ObjectProperty"):
if objectprop.hasAttribute("rdf:about"):
propertytext = objectprop.getAttribute("rdf:about")
property = propertytext.split('#',2)
print ("Property: %s" % property[1])
type = objectprop.getElementsByTagName('rdf:resource')
print ("Type: %s" % type)
and the pressman.owl
file (abridged):
The output fis
Property: hasAdvice Type: [] Property: hasDefinition Type: [] Property: hasDiagram Type: []
ANSWER
Answered 2021-May-24 at 06:46You have this structure
and you're using
type = objectprop.getElementsByTagName('rdf:resource')
This cannot work, because rdf:resource
is not an element, it's an attribute. I assume the one you're interested in belongs to . So we need to go one more level down:
rdf_type = objectprop.getElementsByTagName('rdf:type')
Now rdf_type
is a node list - after all the method is called "get elements by tag name", and minidom cannot know that there only might be a single in your case. We take the first one, if it exists:
rdf_type = rdf_type[0] if len(rdf_type) > 0 else None
Now rdf:resource
is an attribute on that element. Attributes are accessed through .getAttribute()
in minidom.
In theory, the rdf:resource
attribute could be is missing in the XML, so let's make sure it exists before using it:
if rdf_type is not None and rdf_type.hasAttribute('rdf:resource'):
rdf_resource = rdf_type.getAttribute('rdf:resource')
else:
rdf_resource = None
print(rdf_resource)
QUESTION
I'm trying to produce entailment for the rule in OWL 2 RL 'The Semantics of Equality' using owl-api. I already tried to follow: Why the inferences visualised in Protege differ from the exported inferred axioms
genInferred.add(new InferredSubClassAxiomGenerator());
genInferred.add(new InferredClassAssertionAxiomGenerator());
genInferred.add(new InferredDisjointClassesAxiomGenerator());
genInferred.add(new InferredEquivalentClassAxiomGenerator());
genInferred.add(new InferredEquivalentDataPropertiesAxiomGenerator());
genInferred.add(new InferredEquivalentObjectPropertyAxiomGenerator());
genInferred.add(new InferredInverseObjectPropertiesAxiomGenerator());
genInferred.add(new InferredObjectPropertyCharacteristicAxiomGenerator());
genInferred.add(new InferredPropertyAssertionGenerator());
genInferred.add(new InferredSubDataPropertyAxiomGenerator());
genInferred.add(new InferredSubObjectPropertyAxiomGenerator());
And try to precomputed the same individual inference:
reasoner.precomputeInferences(InferenceType.SAME_INDIVIDUAL);
ontologyInf.addAxioms(reasoner.getPendingAxiomAdditions());
I already try using Openllet and hermit as reasoner.
But I still can't produce entailment like this:
If:
T(?x, owl:sameAs, ?y)
T(?y, owl:sameAs, ?z)
Then:
T(?x, owl:sameAs, ?z)
or anything in Semantics of Equality.
ANSWER
Answered 2021-May-16 at 14:02There is no inferred axiom generator that materialises the sameAs
relations. You could write one yourself, based e.g., on InferredPropertyAssertionGenerator
, or you can open an issue on the OWLAPI GitHub repo for the functionality to be added to the library.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install protege
You can use protege like any standard Java library. Please include the the jar files in your classpath. You can also use any IDE and you can run and debug the protege component as you would do with any other Java program. Best practice is to use a build tool that supports dependency management such as Maven or Gradle. For Maven installation, please refer maven.apache.org. For Gradle installation, please refer gradle.org .
Support
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesExplore Kits - Develop, implement, customize Projects, Custom Functions and Applications with kandi kits
Save this library and start creating your kit
Share this Page