You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jena.apache.org by Mario Kofler <ma...@gmail.com> on 2011/08/26 08:56:54 UTC

mapping/matching between ontologies with Jena

Dear List,

I have a general question about matching information between two
ontologies. Imagine I have two ontologies, while each of the
ontologies contains a specific concept. This concept, let's name it
Pizza, represents the same conceptual entity in the real world,
however the two ontologies give different views on this concept.

Hence, for example, in ontology A the concept has a relation

'Pizza hasBase PizzaBase'

and in the second ontology B the concept has a relation

'Pizza inventedBy Nation".

Now, what I need is a somehow "global view" of the Pizza, which
contains all the information about a specific pizza that is  available
in both ontologies, hence for a specific individual "PizzaNeapolitana"
i want

"PizzaNeapolitana hasBase CrispyBase"
"PizzaNeapolitana inventedBy Neapolitans".

My question now is, how can i make sure in Jena, that
"PizzaNeapolitana" which is available two times (once in ontology A
and once in B) is treated as one individual in Jena, hence these
individuals in the two
ontologies denote one and the same individual in real world.

Direct import of one ontology into the other is not possible, due to
reasoning constraints. There are too many classes and individuals in
either of these two ontologies as a direct import would make sense
(reasoning would take an extreme long time).

What I want to do is somehow "mask" that there are two individuals in
the both ontologies, and access the specific Pizza as one individual
as the two individuals are just two views of the same entity in real
world.

Maybe someone has a hint about a software design pattern or can give
me a clue how i can make this most straightforward and correctly in
Jena.

Thank you for your help,

Greetings,

Mario

Re: mapping/matching between ontologies with Jena

Posted by Mario Kofler <ma...@gmail.com>.
Hello,

> Note also that you should not be reasoning directly over a TDB model.
> The inference engines available in Jena are all memory based so there's
> no scaling advantage, and a large performance hit, to reasoning directly
> over TDB/SDB. Instead load your data into a memory model and reason over
> that.

OK, thanks i will try to re-model my program in a way that it reasons on
the memory model only. Let's see if this will result in a performance increase.

> Sure. There's no requirement that a given ontology only mention URIs
> which correspond to its default namespace. A single OWL or RDF graph can
> contain data crossing many namespaces quite freely.
>
> I'm confused about whether you are being given ontologies which talk
> about different individuals which you want to merge or whether you are
> in fact generating these partitioned ontologies yourself just for
> management/performance reasons.

you could say I am given ontologies which talk about different classes
that i want
to merge. The member individuals of these classes are however created
by me, and in future
by my implementation, and could be created with the namespace of either of the
two ontologies, or in one ontology which is the result of the union of
the two ontologies.

> My interpretation was that you had two ontologies which talk about the
> same concept but using different URIs and you wanted to map those
> concepts together so you could query the resulting union. I would do
> that by constructing the union (not intersection) as a separate third
> model. There is then a choice of how to represent the mapped concepts in
> the merged model. Among the options are:
>  (a) Pick one the source URIs as definitive, use that in the merged
> model, map statements about the other alias URI as you do the merge.
>  (b) Create a new URI for the merged concept and map statements about
> both the source URIs to the new merged concept.
>  (c) Keep both source URIs in the merged model and use owl:sameAs
> assertions to represent the mapping.

Thank you again, I will try the options that you suggested. However,
at the moment with the equipment that i have
available and the size/complexity of my ontologies a direct import
(owl:import) with necessary assertions
(e.g.owl:equivalentClass, owl:sameAs) always resulted in an
unacceptable reasoning performance.

Best Regards,

Mario

Re: mapping/matching between ontologies with Jena

Posted by Dave Reynolds <da...@gmail.com>.
Hi,

On Mon, 2011-08-29 at 14:20 +0200, Mario Kofler wrote:

> >> NOTE: For the real implementation in my case it is necessary to keep
> >> the two ontologies seperate due to performance reasons.
> >
> > Are you sure about that?
> >
> > If there is a performance problem it will be in the reasoning not the
> > storage and if you are joining the information back together again for
> > reasoning then nothing will have been saved by separating the storage.
> 
> Please try to explain, I think I do not get the message. Of course I
> believe the
> performance problem lies in the reasoning on the ontologies. That is the reason
> why i keep them in two seperate TDB stores, so that i can start
> reasoning just on
> one part at a time.

Reasoning over two halves of an ontology separately will not give the
same results as reasoning over the union. If at some point you want to
end up with inference results as over the union (which is what I
understood) then there's no performance advantage from the separation.

Note also that you should not be reasoning directly over a TDB model.
The inference engines available in Jena are all memory based so there's
no scaling advantage, and a large performance hit, to reasoning directly
over TDB/SDB. Instead load your data into a memory model and reason over
that.

> >> Therefore, I need to programmatically assure the fact that the
> >> NeapolitanPizza from TDB store A is the same as NeapolitanPizza from
> >> TDB store B, meaning it just states some extra information about the
> >> same individual.
> >>
> >> Does anyone have a suggestion about how to solve this programmatically
> >> in Java code?
> >
> > First, please define what you mean by the two NeopolitanPizzas being the
> > "same individual".
> >
> > If the URIs are the same then they are the same individual, QED.
> >
> > If the URIs are different then what are your criteria for identity?
> 
> The URIs are different, as stated above, however my criteria of identity is the
> unqualified name of the individual (without namespace). I could unify
> the URI just
> by storing the individual with the same namespace into both
> ontologies. However then
> I would end up with one of the two ontologies containing individuals
> with different
> namespaces:
> 
> for ex.
> OntologyA: URI of Individual A: NSA+IndividualA
> OntologyA: URI of Individual B: NSB+IndividualB
> 
> IndividualA is an Individual that has the native namespace of OntologyA and
> IndividualB is an Individual that has the Namespace of OntologyB
> because this Individual
> also exists in OntologyB but with different relations and information.

Sure. There's no requirement that a given ontology only mention URIs
which correspond to its default namespace. A single OWL or RDF graph can
contain data crossing many namespaces quite freely.

I'm confused about whether you are being given ontologies which talk
about different individuals which you want to merge or whether you are
in fact generating these partitioned ontologies yourself just for
management/performance reasons.

> > I don't understand what you trying to achieve but it would seem easier
> > to create a  merged model into which you load the selected and mapped
> > triples from each source.
> 
> Do I get this right, that this merged model then would contain only
> individuals and concepts
> that occur in both ontological representations and need to be mapped?

I wasn't thinking that but since I don't understand what problem you are
trying to solve it is hard to be clearer.

My interpretation was that you had two ontologies which talk about the
same concept but using different URIs and you wanted to map those
concepts together so you could query the resulting union. I would do
that by constructing the union (not intersection) as a separate third
model. There is then a choice of how to represent the mapped concepts in
the merged model. Among the options are:
  (a) Pick one the source URIs as definitive, use that in the merged
model, map statements about the other alias URI as you do the merge.
  (b) Create a new URI for the merged concept and map statements about
both the source URIs to the new merged concept.
  (c) Keep both source URIs in the merged model and use owl:sameAs
assertions to represent the mapping.

Dave



Re: mapping/matching between ontologies with Jena

Posted by Mario Kofler <ma...@gmail.com>.
Hello,

> Are the namespaces the same?

Namespaces are different for the two ontologies.

>> NOTE: For the real implementation in my case it is necessary to keep
>> the two ontologies seperate due to performance reasons.
>
> Are you sure about that?
>
> If there is a performance problem it will be in the reasoning not the
> storage and if you are joining the information back together again for
> reasoning then nothing will have been saved by separating the storage.

Please try to explain, I think I do not get the message. Of course I
believe the
performance problem lies in the reasoning on the ontologies. That is the reason
why i keep them in two seperate TDB stores, so that i can start
reasoning just on
one part at a time.

>> In the implementation I have two separate TDB stores for the two
>> ontologies (A+B).
>
> If you mean literally two stores then you may find two graphs within the
> same store has less overhead.

Thank you for the tip, i will try this. At the moment I have two TDB instances
with two seperate directories where the graphs can be found.

>
>> Therefore, I need to programmatically assure the fact that the
>> NeapolitanPizza from TDB store A is the same as NeapolitanPizza from
>> TDB store B, meaning it just states some extra information about the
>> same individual.
>>
>> Does anyone have a suggestion about how to solve this programmatically
>> in Java code?
>
> First, please define what you mean by the two NeopolitanPizzas being the
> "same individual".
>
> If the URIs are the same then they are the same individual, QED.
>
> If the URIs are different then what are your criteria for identity?

The URIs are different, as stated above, however my criteria of identity is the
unqualified name of the individual (without namespace). I could unify
the URI just
by storing the individual with the same namespace into both
ontologies. However then
I would end up with one of the two ontologies containing individuals
with different
namespaces:

for ex.
OntologyA: URI of Individual A: NSA+IndividualA
OntologyA: URI of Individual B: NSB+IndividualB

IndividualA is an Individual that has the native namespace of OntologyA and
IndividualB is an Individual that has the Namespace of OntologyB
because this Individual
also exists in OntologyB but with different relations and information.

> I don't understand what you trying to achieve but it would seem easier
> to create a  merged model into which you load the selected and mapped
> triples from each source.

Do I get this right, that this merged model then would contain only
individuals and concepts
that occur in both ontological representations and need to be mapped?

Thanks for your help,

Best Regards,

Mario

Re: mapping/matching between ontologies with Jena

Posted by Dave Reynolds <da...@gmail.com>.
On Mon, 2011-08-29 at 10:38 +0200, Mario Kofler wrote:

> no, that is not really what i meant. let us assume that i talk about
> two individuals (maybe the pizza example was not stated exactly
> right):
> 
> :NeapolitanPizza rdf:type :Pizza (Ontology A)
> :NeapolitanPizza rdf:type :Pizza (Ontology B)
> 
> while the first assertion is in ontology A and the second assertion is
> in ontology B. In both ontologies i have different facts modeled about
> the Neapolitan Pizza.

Are the namespaces the same?

> For example it can be seen as in ontology A is stored which type of
> meat goes on the pizza,  and in ontology B all types of vegetables
> that are typical for this pizza are stored. However, just both
> representations together will give all the information that is
> available about the individual "NeapolitanPizza".
> 
> 
> NOTE: For the real implementation in my case it is necessary to keep
> the two ontologies seperate due to performance reasons. 

Are you sure about that?

If there is a performance problem it will be in the reasoning not the
storage and if you are joining the information back together again for
reasoning then nothing will have been saved by separating the storage. 

> In the implementation I have two separate TDB stores for the two
> ontologies (A+B).

If you mean literally two stores then you may find two graphs within the
same store has less overhead.

> Therefore, I need to programmatically assure the fact that the
> NeapolitanPizza from TDB store A is the same as NeapolitanPizza from
> TDB store B, meaning it just states some extra information about the
> same individual.
> 
> Does anyone have a suggestion about how to solve this programmatically
> in Java code?

First, please define what you mean by the two NeopolitanPizzas being the
"same individual".

If the URIs are the same then they are the same individual, QED.

If the URIs are different then what are your criteria for identity?

> I was thinking about creating a controller which accesses both
> individuals and kind of masks the underlying two ontologies, so that
> it looks as one single individual would be accessed. Then the
> individuals in either ontology TDB representation are updated whenever
> some fact changes.

If those are two different representations from different ontological
perspectives then you can't simply propagate changes back.

> However, maybe there exists a more straightforward solution which is
> more appropriate.

I don't understand what you trying to achieve but it would seem easier
to create a  merged model into which you load the selected and mapped
triples from each source.

Dave



Re: mapping/matching between ontologies with Jena

Posted by Mario Kofler <ma...@gmail.com>.
Hello,

first of all, thanks for the vivid response.

> Actually, I think you need to be careful about what you want here. On the
> one hand, you are talking about individuals (a Pizza is a thing that has a
> base), and on the other hand you are talking about classes - NeopolitanPizza
> is a type of (i.e. is a member of the class of) Pizzas.

no, that is not really what i meant. let us assume that i talk about
two individuals (maybe the pizza example was not stated exactly
right):

:NeapolitanPizza rdf:type :Pizza (Ontology A)
:NeapolitanPizza rdf:type :Pizza (Ontology B)

while the first assertion is in ontology A and the second assertion is
in ontology B. In both ontologies i have different facts modeled about
the Neapolitan Pizza.

For example it can be seen as in ontology A is stored which type of
meat goes on the pizza,  and in ontology B all types of vegetables
that are typical for this pizza are stored. However, just both
representations together will give all the information that is
available about the individual "NeapolitanPizza".


NOTE: For the real implementation in my case it is necessary to keep
the two ontologies seperate due to performance reasons. Therefore, the
suggested method in the sample code does unfortunately not work.


In the implementation I have two separate TDB stores for the two
ontologies (A+B).

Therefore, I need to programmatically assure the fact that the
NeapolitanPizza from TDB store A is the same as NeapolitanPizza from
TDB store B, meaning it just states some extra information about the
same individual.

Does anyone have a suggestion about how to solve this programmatically
in Java code?

I was thinking about creating a controller which accesses both
individuals and kind of masks the underlying two ontologies, so that
it looks as one single individual would be accessed. Then the
individuals in either ontology TDB representation are updated whenever
some fact changes.

However, maybe there exists a more straightforward solution which is
more appropriate.


Thank you for your will to help out,

Best Regards,

Mario

Re: mapping/matching between ontologies with Jena

Posted by Ian Dickinson <ia...@epimorphics.com>.
Hi Mario,
On 26/08/11 07:56, Mario Kofler wrote:
> I have a general question about matching information between two
> ontologies. Imagine I have two ontologies, while each of the
> ontologies contains a specific concept. This concept, let's name it
> Pizza, represents the same conceptual entity in the real world,
> however the two ontologies give different views on this concept.
>
> Hence, for example, in ontology A the concept has a relation
>
> 'Pizza hasBase PizzaBase'
>
> and in the second ontology B the concept has a relation
>
> 'Pizza inventedBy Nation".
>
> Now, what I need is a somehow "global view" of the Pizza, which
> contains all the information about a specific pizza that is  available
> in both ontologies, hence for a specific individual "PizzaNeapolitana"
> i want
>
> "PizzaNeapolitana hasBase CrispyBase"
> "PizzaNeapolitana inventedBy Neapolitans".
>
> My question now is, how can i make sure in Jena, that
> "PizzaNeapolitana" which is available two times (once in ontology A
> and once in B) is treated as one individual in Jena, hence these
> individuals in the two
> ontologies denote one and the same individual in real world.
Actually, I think you need to be careful about what you want here. On 
the one hand, you are talking about individuals (a Pizza is a thing that 
has a base), and on the other hand you are talking about classes - 
NeopolitanPizza is a type of (i.e. is a member of the class of) Pizzas.

Separate from how you manage that in Jena, if you write it naively 
you'll have something like:

:NeopolitanPizza rdf:type :Pizza.
:Pizza :hasBase :thin.

Which states that :Pizza is an abstract concept (the set of all possible 
pizzas) but that abstract concept has a thin bread base!

There are various ways to handle this. See:

http://www.w3.org/TR/swbp-classes-as-values/

Any of these approaches can be used in Jena, depending which approach 
suits your needs.

> Direct import of one ontology into the other is not possible, due to
> reasoning constraints. There are too many classes and individuals in
> either of these two ontologies as a direct import would make sense
> (reasoning would take an extreme long time).
>
> What I want to do is somehow "mask" that there are two individuals in
> the both ontologies, and access the specific Pizza as one individual
> as the two individuals are just two views of the same entity in real
> world.
It sounds like you want a union of the two models, which will "just 
work" if the shared concepts use the same URI. There are various ways to 
do this in Jena. I've attached some sample code with one way of 
approaching the problem, which hopefully will give you some clues. If 
not, please post a more specific question.

Ian


-- 
____________________________________________________________
Ian Dickinson                   Epimorphics Ltd, Bristol, UK
mailto:ian@epimorphics.com        http://www.epimorphics.com
cell: +44-7786-850536              landline: +44-1275-399069
------------------------------------------------------------
Epimorphics Ltd.  is a limited company registered in England
(no. 7016688). Registered address: Court Lodge, 105 High St,
               Portishead, Bristol BS20 6PT, UK


RE: mapping/matching between ontologies with Jena

Posted by David Jordan <Da...@sas.com>.
I am relatively new to semantic web and Jena, but won't owl:sameAs work for you? If not, I'd like to hear the experts explain why...

>From the OWL spec:
	The ability to express equivalences using owl:sameAs can be used
	to state that seemingly different individuals are actually the same.

-----Original Message-----
From: Mario Kofler [mailto:mario.kofler@gmail.com] 
Sent: Friday, August 26, 2011 2:57 AM
To: jena-users@incubator.apache.org
Subject: mapping/matching between ontologies with Jena

Dear List,

I have a general question about matching information between two ontologies. Imagine I have two ontologies, while each of the ontologies contains a specific concept. This concept, let's name it Pizza, represents the same conceptual entity in the real world, however the two ontologies give different views on this concept.

Hence, for example, in ontology A the concept has a relation

'Pizza hasBase PizzaBase'

and in the second ontology B the concept has a relation

'Pizza inventedBy Nation".

Now, what I need is a somehow "global view" of the Pizza, which contains all the information about a specific pizza that is  available in both ontologies, hence for a specific individual "PizzaNeapolitana"
i want

"PizzaNeapolitana hasBase CrispyBase"
"PizzaNeapolitana inventedBy Neapolitans".

My question now is, how can i make sure in Jena, that "PizzaNeapolitana" which is available two times (once in ontology A and once in B) is treated as one individual in Jena, hence these individuals in the two ontologies denote one and the same individual in real world.

Direct import of one ontology into the other is not possible, due to reasoning constraints. There are too many classes and individuals in either of these two ontologies as a direct import would make sense (reasoning would take an extreme long time).

What I want to do is somehow "mask" that there are two individuals in the both ontologies, and access the specific Pizza as one individual as the two individuals are just two views of the same entity in real world.

Maybe someone has a hint about a software design pattern or can give me a clue how i can make this most straightforward and correctly in Jena.

Thank you for your help,

Greetings,

Mario