I have owl file containing some axioms :
<rdfs:subClassOf>
<owl:Restriction>
<owl:onProperty rdf:resource="namespace#Gender"/>
<owl:hasValue>M</owl:hasValue>
</owl:Restriction>
</rdfs:subClassOf>
<rdfs:subClassOf>
<owl:Restriction>
<owl:onProperty rdf:resource="namespace#Address"/>
<owl:minQualifiedCardinality rdf:datatype="&xsd;nonNegativeInteger">1</owl:minQualifiedCardinality>
<owl:onDataRange rdf:resource="&xsd;string"/>
</owl:Restriction>
</rdfs:subClassOf>
For above two axioms protege shows readable string as :
Gender value "M"
Address min 1 xsd:string
The question is how protege generates these readable strings from OWL file ?
Also if I want to create new axiom from these strings how to do that ? (converting axiom to readable string and then convert readable string to axiom back)
The readable format you show is Manchester OWL syntax.
In order to output an ontology in this format, you can use owl api code:
OWLOntology ontology = ...// load or create the ontology
OutputStream out = ... // any output stream will do
ontology.getOWLOntologyManager().saveOntology(ontology, new ManchesterSyntaxDocumentFormat(), out);
out.close();
Parsing a full ontology in Manchester syntax format happens like any other ontology: ontologyManager.loadOntologyFromOntologyDocument() with an input file.
Parsing single axioms is possible but much harder, because the format relies on prefixes set once for a whole ontology; so a lot of setup code is required. I would not recommend doing that as a starter project.
Related
library(ontologyIndex)
library(tm)
library(SnowballC)
setwd("C:/Users/adm_r/OneDrive/Área de Trabalho/Doctorade-Project/OntoNano/OntoNano/Robson_OntoClay.owl")
setwd(Ontology)
ontology <- get_ontology("C:/Users/adm_r/OneDrive/Área de Trabalho/Doctorade-Project/OntoNano/OntoNano/Robson_OntoClay.owl")
#, extract_tags="everything")
I am trying to import the OWL file, in RSTUdio and I am not successful. And I would like to check how to import ..... and view in Rstudio.
And have the words and classes of this Ontology.
Gratitude
I am trying to evaluate a WSD model using well-known WSD data set (SemEval, SensEval). But I am don't understand the format of the gold key text file.
seneval3.gold.key.txt
d000.s000.t000 man%1:18:00::
d000.s000.t001 say%2:32:01::
d000.s001.t000 peer%2:39:00::
d000.s001.t001 companion%1:18:00::
d000.s001.t002 bleary%5:00:00:indistinct:00
d000.s001.t003 eye%1:08:00::
d000.s002.t000 have%2:40:00::
d000.s002.t001 ready%5:00:01:available:00
d000.s002.t002 answer%1:04:00::
d000.s002.t003 much%3:00:00::
d000.s002.t004 surprise%1:12:00::
d000.s002.t005 fit%1:26:00::
d000.s002.t006 coughing%1:26:00::
d000.s003.t000 man%1:18:00::
d000.s003.t001 drunk%3:00:00::
d000.s003.t002 crazy%5:00:00:insane:00
d000.s004.t000 newfound%5:00:00:new:00
I know that in the first line d000.s000.t000 talking about the document #0 sentence #0 token #0 by looking at the data file.
senseval3.data.xml
<sentence id="d000.s000">
<wf lemma="that" pos="DET">That</wf>
<wf lemma="'" pos="VERB">'s</wf>
<wf lemma="what" pos="PRON">what</wf>
<wf lemma="the" pos="DET">the</wf>
<instance id="d000.s000.t000" lemma="man" pos="NOUN">man</instance>
<wf lemma="have" pos="VERB">had</wf>
<instance id="d000.s000.t001" lemma="say" pos="VERB">said</instance>
<wf lemma="." pos=".">.</wf>
</sentence>
But I don't know what is meant after %, for example 1:18:00:: for lemma man.
This answer is composed based on the comment given for this SO post.
The number sequence followed by % is the lex_index. Lex index composed as follows.
ss_type:lex_filenum:lex_id:head_word:head_id
More information is in the WordNet documentation.
Following the definition of symmetric and asymmetric properties in OWL 2 and the explanation in Inheritance of property characteristic by sub-properties I would assume that the declaration of an asymmetric property as sub-property to a symmetric property would result in an inconsistency detected by the reasoner (HermiT 1.3.8.413), but that is not the case in Protégé 5.2.0. Any explanations for this?
HermiT infers from the assertions below correctly the range of :isNeighbourto be :Word and :W1 :isNeighbour :W2, and detects an inconsistency when :W1 :folllows :W2. The same is true for Pellet and Fact++ 1.6.5 in Protégé 5.2.0.
:isNeighbour a owl:SymmetricProperty; rdfs:domain :Word .
:follows a owl:AsymmetricProperty; rdfs:subPropertyOf :isNeighbour .
:W1 a :Word .
:W2 a :Word .
:W2 :follows :W1 .
This code seems to be a sensible formal representation of text (words are (symmetric) neighbours when they follow each other (asymmetric)), but in the definition of OWL it seems to be inconsistent as every assertion using the property :follows should consistently allow the assertions made with the superclass :isNeighbour.
I'm not sure if the Reasoners are just less strict than OWL or I've a misunderstanding of OWL.
Some property characteristics are "top-down inherited" through property hierarchy, whereas some are not:
P rdfs:subPropertyOf Q means ∀x∀y(P(x,y) → Q(x,y)) (1)
Q a owl:SymmetricProperty means ∀x∀y(Q(x,y) → Q(y,x)) (2)
Do (1) and (2) entail ∀x∀y(P(x,y) → P(y,x))? You have already find a countermodel. You could replace "words" with "natural numbers" for solidity.
Actually, symmetricity is "down-top inherited".
P.S. Demystifying OWL for the Enterprise by M. Uschold says that the subproperty of a symmetric property is symmetric, which is not correct.
Hello I'm totally newbie in ontology.
I downloaded dbpedia ontology .owl file and open it using topbraid composer.
Topbraid composer shows dbpedia class( owl:Thing -> Activity, Agent, .. etc). Each class also has its own instances.
However, yago2s only provides many .ttl files( yagoSchema.ttl, yagoFact.ttl .. etc).
Cause I think these ttl files are similar to owl file, I also open it using topbraid composer. I expected to see the structure like dbpedia owl file, but it wasn't similar to dbpedia owl file..
They provide schema ttl file, instances ttl file, ... files respectively, but i wanna see the whole thing at once.
Should I get yago2s owl file? or is there any ways to see yago ttl files like dbpedia owl??
Thanks in advance.
The error message when I tried to open yagoTypes.ttl file is
java.lang.reflect.InvocationTargetException
at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:421)
at org.eclipse.jface.dialogs.ProgressMonitorDialog.run(ProgressMonitorDialog.java:507)
at org.eclipse.ui.internal.progress.ProgressMonitorJobsDialog.run(ProgressMonitorJobsDialog.java:275)
at org.eclipse.ui.internal.progress.ProgressManager$3.run(ProgressManager.java:960)
at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:70)
at org.eclipse.ui.internal.progress.ProgressManager.busyCursorWhile(ProgressManager.java:995)
at org.eclipse.ui.internal.progress.ProgressManager.busyCursorWhile(ProgressManager.java:970)
at org.topbraidcomposer.core.io.TBCIO$3.run(TBCIO.java:501)
at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35)
at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:135)
at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:4145)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3762)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$9.run(PartRenderingEngine.java:1113)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:997)
at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:140)
at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:611)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:567)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:150)
at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:124)
at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:354)
at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:181)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:636)
at org.eclipse.equinox.launcher.Main.basicRun(Main.java:591)
at org.eclipse.equinox.launcher.Main.run(Main.java:1450)
at org.eclipse.equinox.launcher.Main.main(Main.java:1426)
Caused by: java.lang.NullPointerException
at org.topbraid.core.model.Classes.getMetaClasses(Classes.java:548)
at org.topbraid.core.model.Classes.computeMetaClasses(Classes.java:45)
at org.topbraidcomposer.core.session.AbstractSessionWithCache.getCachedMetaClasses(AbstractSessionWithCache.java:67)
at org.topbraid.core.model.Classes.getMetaClasses(Classes.java:166)
at org.topbraidcomposer.editors.ResourceEditorLauncher.checkVisibility(ResourceEditorLauncher.java:270)
at org.topbraidcomposer.editors.ResourceEditorLauncher.access$4(ResourceEditorLauncher.java:269)
at org.topbraidcomposer.editors.ResourceEditorLauncher$5.run(ResourceEditorLauncher.java:577)
at org.topbraidcomposer.core.io.TBCIO$2.run(TBCIO.java:482)
at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:121)
and this same error occurs when I concatenate yagoTypes.ttl and yagoFacts.ttl using cat command, and try to open this concatenated file..
Where to get the data
If you got the data from YAGO2s Downloads, it says right at the beginning of the page:
You can download the entire YAGO2s ontology in one piece. (Extracted
from 2012-12-01 version of Wikipedia.)
Download YAGO2s ontology in
.ttl format! (2.2 Gb compressed, 18.5 Gb uncompressed)
That sounds like what you want. If you just want to see the class hierarchy, though, then you might want the yagoTaxonomy files:
yagoTaxonomy The entire YAGO taxonomy. These are all rdfs:subClassOf facts derived from Wikipedia and from WordNet.
The format of the data
OWL is a ontology language with an abstract structure that can be serialized in a number of different ways including OWL/XML, the OWL Functional Syntax, the Manchester Syntax, and encoded as RDF. Now, RDF is also an abstract format, and can be serialized in a number of ways, including N-Triples, N3, Turtle (ttl), and RDF/XML. Most .owl files that you find are actually RDF/XML files that are serializations of the RDF encoding of an OWL ontology. That's probably what your .owl file is. The .ttl files you're seeing are the Turtle serialization of the RDF encoding of an OWL ontology. Standard RDF processing tools should be able to process it.
I'm using the OWL API, and I have an ontology. I'm trying to import another ontology the way we do in protege, i.e. select the OWL File locally and then import it. Is this possible with the OWL API
I'm using the import declaration,
OWLImportsDeclaration importDeclaraton = ontology.getFactory().getOWLImportsDeclaration(IRI.create("/home/noor/Dropbox/TaggingCaseStudy/Programs/TextBasedMA/files/ontologies/OBMA2/photo1.owl"));
But I'm getting an error, it is not taking the file locally,
Caused by: java.io.FileNotFoundException: http://semanticweb.org/home/noor/Dropbox/TaggingCaseStudy/Programs/TextBasedMA/files/ontologies/OBMA2/photo1.owl
Your IRI is relative, not absolute - it needs to start with file: for a file to be found. Relative IRIs will be resolved against the base IRI at the time of loading, which in your case creates the URL which you can see in the error.
Try making the IRI absolute, or use indirection by using the actual ontology IRI in the import and using an IRIMapper to point at the file.
E.g., if your ontology has an IRI of http://example.com/myontology, use
OWLImportsDeclaration importDeclaraton = ontology.getFactory().getOWLImportsDeclaration(IRI.create("http://example.com/myontology"));
to create the imports declaration, and add an IRIMapper to your OWLOntologyManager for resolving it when loading the ontology:
manager.addIRIMapper(new SimpleIRIMapper(IRI.create("http://example.com/myontology"),
IRI.create("file:///actual/path/to/file.owl"));
Edit: with OWLAPI 4, this looks like:
manager.getIRIMappers().add(new SimpleIRIMapper(IRI.create("http://example.com/myontology"),
IRI.create("file:///actual/path/to/file.owl"));
Javadoc for this can be found on the GitHub page