Jena ConversionException while viewing owl:NamedIndividual as an OntClass - jena

I am getting the following Jena Named Individual Exception:
Cannot convert node http://www.w3.org/2002/07/owl#NamedIndividual
to OntClass: it does not have rdf:type owl:Class or equivalent
I am unable to find some relevant answer to my problem. Is is due to OWL 2 incompatibility with OWL 1. What are the mitigation strategies available to me?

Yes, Jena doesn't support OWL2 at the moment. However, you can just call setStrictMode(false) on your OntModel, and it will allow you to view that resource as a class by switching off strict checking.

Related

When I use the protege to perform SWRL reasoning, I am reminded that prefix name not registered

I am using protege to build an ontology and use the SWRL rules provided with the software for reasoning. When creating a new SWRL rule, I was reminded "protege prefix not registered for prefix name". Many thanks here, can someone tell me how to register the prefix name?
This happened to me too when I used the SWRLTab and the SQWRLTab.
I like to edit my turtle files with an IDE instead of using protege. I prefer this as I end up with a much cleaner and shorter file.
I still use Protege for a better visualization of my Ontology, to use reasoners, etc.
I personally use the Turtle format but this solution should work with all the other formats too, just make sure to adapt it to yours in the right way.
The problem for me was that I stored the Ontology IRI using only the #base declaration.
#base <MY_ONTOLOGY_IRI> .
I did some exploration and find out that Protege also saves a prefix as follow:
#prefix _: <MY_ONTOLOGY_IRI> .
This causes the SWRLTab and the SQWRLTab to expect to find the _: prefix. I think this can happen only if the Ontology is written by hand like in my case. Doesn't matter your situation, just make sure that the #prefix _: and the #base declaration have the same value and You should be fine.
⚠️ An additional note:
After adding the #prefix from my IDE, Protege asked to reload the Ontology with a pop-up. Reloading it was not enough for me. I had to restart Protege completely to make it work.

how can I customize a scope generator in xtext to cross reference variables from a file

Please refer to the Expressions Grammar and code generator present in below link
Is there some way to test my grammar which refer to EAttributes?
What I want to do is create a file (.ecore) and save it locally, specifically for the purpose of storing variables and i want my code to cross references the variables of EAttribute type from that ".ecore" file. This is in context with the below rule of grammar.
Atomic returns Expression:
...
{VariableRef} variable=[ecore::EAttribute|QualifiedName];
I am unable to find much help on how to customize a global scope provider as per this requirement. Would really appreciate if someone could guide me in the right direction.

Resolving variables in my DSL from an external source

I'm new to working with Xtext and Xtend and I have stumbled upon a problem which I hope someone can help me solve.
What I'm trying to achieve is to resolve variables from an external source rather than declaring them explicitly in the DSL.
I got the following example to demonstrate:
Here is the grammar:
grammar org.xtext.example.mydsl.MyDsl with org.eclipse.xtext.xbase.Xbase
generate myDsl "http://www.xtext.org/example/mydsl/MyDsl"
Model:
configUrl=ConfigUrl
devices+=Device*
test=Test
;
ConfigUrl:
"ConfigURL=" url=STRING
;
Device:
'Device' name=ID
'has channels: ' (channels+=Channel (',' channels+=Channel)*)?
;
Channel:
name=ID
;
Test:
'DoSomething' channel=[Channel|QualifiedName]
;
and here is an example usage:
ConfigURL="http://localhost:8080/devices"
Device Light has channels: state
DoSomething Light.state
Instead of explicitly declaring the devices in the DSL I would like to resolve them from and external source (the ConfigURL variable). As far as I can tell, what I'm looking for is related to the scoping functionality of Xtend. I have looked at the documentation but haven't found much that can help me further. In addition, it seems that some things has changed and the examples that I've come across are outdated.
Thanks,
Since your elements are not parsed by xtext you will need to create them, e.g. in the scope provider. For this, first create an ecore model that describes your Device and Channel classes. You will also need a reference in your DSL to these elements, e.g.
DeviceDesc:
'Device' deviceRef=[Device|ID]
'has channels: ' (channels+=[Channel] (',' channels+=[Channel])*)?;
Then you need an own scope provider which implements:
public IScope scope_DeviceDesc_deviceRef(final DeviceDesc context, EReference reference)
In this method you need to resolve the URL. You can get it via the context element:
String url = ((Model)context.eContainer()).getConfigUrl();
Use the URL to retrieve your external data and create Device elements from it. Then use Scopes.scopeFor(myDeviceList) to create a scope and return it in your scope provider.
You might want to consider caching the device elements instead of always recreating them when the scope provider is asked.

function 'Func/Arity' already imported from 'Module'

I defined both area/1 and perim/1 in modules sqaure and circle.
I want to import and use them in another module. Here is my import statements:
-import(square, [area/1, perim/1]).
-import(circle, [area/1, perim/1]).
I got these error messages.
~/test.erl:4: function area/1 already imported from square
~/test.erl:4: function perim/1 already imported from square
I know erlang does not support namespace. But since we can qualify a function call by specifying the module (i.e. square:area vs circle:area), I fail to see how the lack of namespace is the source of the error here.
So, what exactly caused the above error and how can I fix it?
In Erlang, "importing" a function from another module means being able to call it as if it were a local function, without the module prefix. So with this directive:
-import(square, [area/1, perim/1]).
you could write area(42) and it would mean the same as square:area(42).
However, if you include area and perim functions from two modules, it would be ambiguous which one you'd actually call when writing area(42).
As you correctly note, you can always qualify the function call with the name of the module, i.e. square:area(42) and circle:area(42) - so I would suggest doing so consistently and removing both import directives. This is also recommended by rule 6.6 of the Erlang Programming Rules - "Don't use import".

How to use Fuseki for storing data persistently with ontology schema

Hi I'm new to ontology storing :)
Actually I'm looking for a triplestore with Java interoperability (Jena). So I choose Apache Fuseki.
In the documentation I found the ja:MemoryModel for loading ontologies. But does this mean the data is lost when I shut down the server?
Another idea is to use some kind of ontology schema. This means I want to use 1 ontology as schema and a second one for storing the entities. In the example configuration.ttl I found something like that:
ja:baseModel
[ a ja:MemoryModel ;
ja:content [ja:externalContent <file:Data/test_abox.ttl>] ;
ja:content [ja:externalContent <file:Data/test_tbox.ttl>] ;
] ;
But I couldn’t found a real explanation for the baseModel and in the documentation there is also the OntModel mentioned. Which one to use for schema and which one for entities. For me as newcomer it’s a little bit confusing?
Could someone be so kind as to give me a hint for that?
Thanks!
You can run the server with a persistent database. Start the server with --loc=DB and it will use it's copy of Jena TDB as the datastore.
Or you can use the assembler and configure in a TDB-backed datastore and a model from that.

Resources