On 08/01/2012 09:11, 锐光刘 wrote:
Dear DAVE,
I am still graceful for your help again.With your help, I learn a
lot.Thanks sincerely!
As you told me ,the blank nodes in RDFS  are restrictions classes,

I didn't say that. I said *OWL* uses blank nodes for representing expressions, *including* restrictions. Your examples include both a Restriction and a complement Class.

so they
always located at the root,

No. They are almost never roots themselves. If you mean that only your root classes have restrictions then, if true, that would be a property of your ontology and not of ontologies in general.

since some other classes with the same restrictions
just belong to the subclass?

Again, if you only have restrictions on root classes that is something specific to your ontologies (and not particularly common).

That is to say the blank node are same as the
global parameters in JAVA.Is this the truth?

No. They are nothing at all like global parameters, not even a little bit :)

Using object oriented languages as an analogy with OWL will almost always mislead you. However, if you want an analogy then they are more like anonymous inner classes.

The concepts you have declared in your OWL are represented in RDF as resources which have names. The internal expressions like Restrictions or unions of complementOfs are just the same, they are resources, it is just that they don't have global names. But otherwise they are identical.

However, the problems of mine are still pending.As you told me, I have
tried the ways to create blank node,it does work !

Actually I think all three of the methods I suggest do work :)

But I still confuse with the name of blank node? Every time, the name of
one certain blank node are same in the places it appeals,while the serious
number is changing each time of running.It seems the number is created
randomly for every blank node,right?

The whole point of blanks nodes is that they don't have *any* name.

Internally in Jena you have to have some way of keeping track of them so they are given the anonymous IDs you are seeing. However, you should never need to look at those. The only thing you need to know about two blank nodes is "are they the same node" and you do that using equals().

So it's proved fault to create a blank
node with certain given name such as ( -c125e31:134bc22d954:-7ffc ),because
it doesn't work.

Don't try to give a specific ID to a blank node, you should almost never need to. You can, and it does work because we have to do that internally in jena, but don't do it. None of the three methods I suggested required you to do that.

So far, my project is still held on.As you already know,I want to create a
new model(m2) merely containing part of information from another
model(m1).So I add the concerned statements to m2,while the obstacle is
apparent.If the statement contain a blank node, such as (
[-c125e31:134bc22d954:-7ff9,
http://www.w3.org/2002/07/owl#allValuesFrom,
http://www.semanticweb.org/ontologies/2011/2/Ontology1300069908451.owl#OWLClass_00000011048271017738]
).It is meaningless,since the name of blank node have no meaning.

When you do the copy (and as I said off list, I don't understand why you are doing this copy in the first place!) you have to create the same shape of graph. So if a blank node in the m1 has 2 incoming links and 5 outgoing links then the new blank node you create in m2 has to have equivalent links. This is *no different* from the case of normal resources.

I gave you three ways of achieving this. Two ways to use the same blank bnodes in the new model and one way to create new blank nodes but keep the structure isomorphic.

In view of this situation, I have my solution but don't know whether it is
correct or have some leaks without taking into accounts.

1.create a OntModel named m2 and add all namespace from raw model m1 to
keep the same name prefix.
2.Since most blank nodes are the root class for restriction, so put the
statements of one blank node into a list and then create a new blank node
with the same predicate and object.At last, add them to the model m2, for
example:

There are three statement about the blank node called (
-c125e31:134bc22d954:-7ff9) here

[-c125e31:134bc22d954:-7ff9, http://www.w3.org/2002/07/owl#allValuesFrom,
http://www.semanticweb.org/ontologies/2011/2/Ontology1300069908451.owl#OWLClass_00000011048271017738
]
[-c125e31:134bc22d954:-7ff9, http://www.w3.org/2002/07/owl#onProperty,
http://www.semanticweb.org/ontologies/2011/2/Ontology1300069908451.owl#OWLObjectProperty_00000007999444084524
]
[-c125e31:134bc22d954:-7ff9, http://www.w3.org/1999/02/22-rdf-syntax-ns#type,
http://www.w3.org/2002/07/owl#Restriction]


Resource s1 = CreatedModel.createResource(new AnonId()); Property p1 =
CreatedModel.createProperty("http://www.w3.org/2002/07/owl#someValuesFrom";);
RDFNode o1 = CreatedModel.createResource("
http://www.semanticweb.org/ontologies/2011/2/Ontology1300069908451.owl#OWLClass_00000007917927734386";);
Property pp1 = CreatedModel.createProperty("
http://www.w3.org/2002/07/owl#onProperty";); RDFNode  oo1 =
CreatedModel.createResource("
http://www.semanticweb.org/ontologies/2011/2/Ontology1300069908451.owl#OWLObjectProperty_00000009464787570107";);
Property ppp1 = CreatedModel.createProperty("
http://www.w3.org/1999/02/22-rdf-syntax-ns#type";); RDFNode  ooo1 =
CreatedModel.createResource("http://www.w3.org/2002/07/owl#Restriction";);
m2.add(s1, p1, o1); m2.add(s1, pp1, oo1); m2.add(s1, ppp1, ooo1);

That that looks vaguely like my recommendation #3, for each blank node bn1 in model1 you have created a new blank node bn2 in model2 and transferred all of the properties of bn1 to bn2.

A few minor comments:
- you said "Since most blank nodes are the root class for restriction" that is rarely true and not relevant here - to create a new blank node use model.createResource() as I said in my earlier recommendations, there is no need to call "new AnonId()" yourself (though it does no harm)
  - you don't need to do things like
     createProperty("http://www.w3.org/2002/07/owl#onProperty";)
    use
     OWL.onProperty

For all the blank nodes ,dealt with them as the same way.After this
process, all the blank node are add into the OntModel m2,no matter whether
they are used.
At the end of step 2,the m2 contains namespace and the blank nodes with
properties with them.And the statements list from m1 can deleted the ones
which contain the blank nodes as subject,since they these statements are
already contained in m2.

3.Add the other needed statements to the m2,if encounter some statements
mentioning blank nodes as objects,(since the ones with blank nodes as
subjects are already contained in step 2).Relplace the blank node with the
corresponding created one(such as s1 above in step 2),and then add the
statememts to the model m2.for example

[
http://www.semanticweb.org/ontologies/2011/2/Ontology1300069908451.owl#OWLClass_00000010519829538601,
http://www.w3.org/2002/07/owl#equivalentClass, -c125e31:134bc22d954:-7ffa]
The object ( -c125e31:134bc22d954:-7ffa) is a blank node, so replace it
then add it to m2.
Of course,the statements belong to one resource such as class and
individual should be added together.

So this is the method 3 that I suggested, except that I suggested using a HashMap and you seem to say you are using a List to track the mapping from old blank node to new blank node.

Well,Could you tell me the faults of this solution or whether it is
feasible in theory?

In theory it is fine :) In practice it depends on how you have implemented Step2. You shouldn't need to be doing a separate pass at the beginning for handling blank nodes. You should be able to handle then during your step 3. As you meet a node in your traversal you will have either already created a new blank node for it (in which case you reuse that) or you haven't (in which case create a new one then and add it to your mapping table).

Since this way should store the infomation during
process,needing to redesign a database and store the statements with label
to them.So I have done the procee at the second step,and it seems all
right.The third step haven't done for the reason of new database.If I
describe ambiguously, I am pleasure to explain in details.

Well I don't understand it but I don't need to :)

The one thing I would say is that if this custom database you are creating is supposed to be enough to store the OWL structure then it will need to have a way to represent the blank nodes as well as URI nodes.

So could you tell me could my solution will be work?

It's an approach than can be made to work.

Dave


Reply via email to