You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jena.apache.org by Deyan Chen <ch...@neusoft.com> on 2014/09/17 11:01:31 UTC

How to associate a triple with a weight value?

Hi all,

I want to associate a triple with a weight value, for example:

s1 p1 v1 with 20,
s1 p1 v2 with 11,
s1 p2 v3 with 30,
......
s2 p1 v1 with 15,
s2 p2 v3 with 20,
......

The way I have tested is to make a anonymous ReifiedStatement object 
from the triple/statement.
The example code is as following:

// list the statements in the graph
StmtIterator stmtIter = model.listStatements(res, prop, (RDFNode) null);

Property certaintyFactor = model.createProperty(fuzzyOntNameSpace, 
"certainty_factor");

// print out the predicate, subject and object of each statement
Statement stmt = null;

while (stmtIter.hasNext()) {
     // get next statement
     stmt = stmtIter.nextStatement();
     System.out.println(stmt.toString());

     if (stmt.isReified()) {
         stmt.removeReification();
     } else {
         ReifiedStatement reifStmt = stmt.createReifiedStatement();
         reifStmt.addLiteral(certaintyFactor, Math.random());
         System.out.println(reifStmt.toString());
     }
}

The output is as following:

[http://www.example.com/ontologies/2013/6/medicine.owl#m.029k_, 
http://www.example.com/ontologies/2013/6/medicine.owl#disease.symptoms, 
http://www.example.com/ontologies/2013/6/medicine.owl#m.014wq_]
(273851cd:146eb73208f:-7fea rdf:type rdf:Statement)
(273851cd:146eb73208f:-7fea rdf:subject medicine:m.029k_)
(273851cd:146eb73208f:-7fea rdf:predicate medicine:disease.symptoms)
(273851cd:146eb73208f:-7fea rdf:object medicine:m.014wq_)
(273851cd:146eb73208f:-7fea fuzzy:certainty_factor 
'0.6892811680228655'^^http://www.w3.org/2001/XMLSchema#double)
Exception in thread "main" java.util.ConcurrentModificationException: 
Iterator: started at 5, now 10
     at 
com.hp.hpl.jena.tdb.sys.DatasetControlMRSW.policyError(DatasetControlMRSW.java:157)
     at 
com.hp.hpl.jena.tdb.sys.DatasetControlMRSW.access$000(DatasetControlMRSW.java:32)
     at 
com.hp.hpl.jena.tdb.sys.DatasetControlMRSW$IteratorCheckNotConcurrent.checkCourrentModification(DatasetControlMRSW.java:110)
     at 
com.hp.hpl.jena.tdb.sys.DatasetControlMRSW$IteratorCheckNotConcurrent.hasNext(DatasetControlMRSW.java:118)
     at org.apache.jena.atlas.iterator.Iter$4.hasNext(Iter.java:295)
     at org.apache.jena.atlas.iterator.Iter$4.hasNext(Iter.java:295)
     at org.apache.jena.atlas.iterator.Iter.hasNext(Iter.java:853)
     at 
com.hp.hpl.jena.tdb.store.GraphTDBBase$ProjectQuadsToTriples.hasNext(GraphTDBBase.java:170)
     at 
com.hp.hpl.jena.util.iterator.WrappedIterator.hasNext(WrappedIterator.java:90)
     at 
com.hp.hpl.jena.util.iterator.Map1Iterator.hasNext(Map1Iterator.java:48)
     at 
com.hp.hpl.jena.util.iterator.WrappedIterator.hasNext(WrappedIterator.java:90)
     at 
com.neusoft.phs.diagnosis.FindDiseasesBySymptoms.setWeightForSymptomsOfDisease(FindDiseasesBySymptoms.java:117)
     at 
com.neusoft.phs.diagnosis.FindDiseasesBySymptoms.main(FindDiseasesBySymptoms.java:60)
Java Result: 1

Only the first time of this cycle is successful. And whether the model 
is located in memory or TDB, the test result is same.

But when the model is created by Model.union() method, for example:

Dataset dataset = TDBFactory.assembleDataset(assemblerFile);
Model defaultModel = dataset.getDefaultModel();
Model unionNamedModel = dataset.getNamedModel("urn:x-arq:UnionGraph");
Model model = defaultModel.union(unionNamedModel);

the above cycle can execute successfully. I don't know why.

Have I done something wrong? Could anyone help on this or give me any 
suggestions?

Thank you very much.

Deyan Chen
---------------------------------------------------------------------------------------------------
Confidentiality Notice: The information contained in this e-mail and any accompanying attachment(s) 
is intended only for the use of the intended recipient and may be confidential and/or privileged of 
Neusoft Corporation, its subsidiaries and/or its affiliates. If any reader of this communication is 
not the intended recipient, unauthorized use, forwarding, printing,  storing, disclosure or copying 
is strictly prohibited, and may be unlawful.If you have received this communication in error,please 
immediately notify the sender by return e-mail, and delete the original message and all copies from 
your system. Thank you. 
---------------------------------------------------------------------------------------------------

Re: How to associate a triple with a weight value?

Posted by Deyan Chen <ch...@neusoft.com>.
Hi Dave,

Your explains and suggestions are very helpful to me.
Thank you very much.

Deyan Chen

在 2014年09月18日 16:44, Dave Reynolds 写道:
> On 18/09/14 09:26, Deyan Chen wrote:
>>
>>
>> 在 2014年09月18日 15:32, Dave Reynolds 写道:
>>> On 18/09/14 01:31, Deyan Chen wrote:
>>>> Hi Dave,
>>>>
>>>> Thank you for your reply.
>>>>
>>>> I know the means of the error, but I want to know why the second
>>>> case(model created by Model.union()) doesn't report the error.
>>>
>>> Presumably because in that case you are using TDB instead of an
>>> in-memory data structure.
>>
>> The model in my first test cast was created from TDB store and an
>> in-memory data structure individually, it reported the same error.
>
> Since you didn't show us that code it is hard to say but it looks like 
> you are running over an in-memory copy.
>
> In the second case your updates are going straight to TDB.
>
> As it happens you are also using different models for the read and 
> writes. The updates are going into the default graph of TDB and the 
> reads are coming from a union of the named graphs in the TDB. However, 
> for TDB models are really just projections out of a quad store so 
> that's not particularly relevant.
>
> If you are going to do this sort of thing with TDB then use transactions.
>
>>>> And about the way to associate a triple with a weight value, have 
>>>> you a
>>>> better one or any other suggestions?
>>>
>>> Apart from reification at the RDF level the alternative is to consider
>>> explicit n-ary relations. The implementation of n-ary relations boils
>>> down to something much the same as reification - create resources,
>>> typically b-nodes, to represent each instance of the relation with
>>> separate properties to link that instance to the relation components
>>> (such as subject, object, weight).
>>>
>>> It depends on whether you really are trying to annotate every RDF
>>> statement or whether you want to build on top of RDF some way of
>>> representing certain weighted property values.
>>
>> I want to represent weighted property values on some RDF triples, such
>> as, disease and symptom relations.
>
> Personally I would represent those with n-ary relations rather than 
> RDF-level reification but either could be made to work.
>
>> --------------------------------------------------------------------------------------------------- 
>>
>>
>> Confidentiality Notice: The information contained in this e-mail and any
>> accompanying attachment(s) is intended only for the use of the intended
>> recipient and may be confidential and/or privileged of Neusoft
>> Corporation, its subsidiaries and/or its affiliates. If any reader of
>> this communication is not the intended recipient, unauthorized use,
>> forwarding, printing,  storing, disclosure or copying is strictly
>> prohibited, and may be unlawful.If you have received this communication
>> in error,please immediately notify the sender by return e-mail, and
>> delete the original message and all copies from your system. Thank you.
>> --------------------------------------------------------------------------------------------------- 
>>
>
> This is a public forum :)
>
> Dave
>
>
>
>

---------------------------------------------------------------------------------------------------
Confidentiality Notice: The information contained in this e-mail and any accompanying attachment(s) 
is intended only for the use of the intended recipient and may be confidential and/or privileged of 
Neusoft Corporation, its subsidiaries and/or its affiliates. If any reader of this communication is 
not the intended recipient, unauthorized use, forwarding, printing,  storing, disclosure or copying 
is strictly prohibited, and may be unlawful.If you have received this communication in error,please 
immediately notify the sender by return e-mail, and delete the original message and all copies from 
your system. Thank you. 
---------------------------------------------------------------------------------------------------

Re: How to associate a triple with a weight value?

Posted by Dave Reynolds <da...@gmail.com>.
On 18/09/14 09:26, Deyan Chen wrote:
>
>
> 在 2014年09月18日 15:32, Dave Reynolds 写道:
>> On 18/09/14 01:31, Deyan Chen wrote:
>>> Hi Dave,
>>>
>>> Thank you for your reply.
>>>
>>> I know the means of the error, but I want to know why the second
>>> case(model created by Model.union()) doesn't report the error.
>>
>> Presumably because in that case you are using TDB instead of an
>> in-memory data structure.
>
> The model in my first test cast was created from TDB store and an
> in-memory data structure individually, it reported the same error.

Since you didn't show us that code it is hard to say but it looks like 
you are running over an in-memory copy.

In the second case your updates are going straight to TDB.

As it happens you are also using different models for the read and 
writes. The updates are going into the default graph of TDB and the 
reads are coming from a union of the named graphs in the TDB. However, 
for TDB models are really just projections out of a quad store so that's 
not particularly relevant.

If you are going to do this sort of thing with TDB then use transactions.

>>> And about the way to associate a triple with a weight value, have you a
>>> better one or any other suggestions?
>>
>> Apart from reification at the RDF level the alternative is to consider
>> explicit n-ary relations. The implementation of n-ary relations boils
>> down to something much the same as reification - create resources,
>> typically b-nodes, to represent each instance of the relation with
>> separate properties to link that instance to the relation components
>> (such as subject, object, weight).
>>
>> It depends on whether you really are trying to annotate every RDF
>> statement or whether you want to build on top of RDF some way of
>> representing certain weighted property values.
>
> I want to represent weighted property values on some RDF triples, such
> as, disease and symptom relations.

Personally I would represent those with n-ary relations rather than 
RDF-level reification but either could be made to work.

> ---------------------------------------------------------------------------------------------------
>
> Confidentiality Notice: The information contained in this e-mail and any
> accompanying attachment(s) is intended only for the use of the intended
> recipient and may be confidential and/or privileged of Neusoft
> Corporation, its subsidiaries and/or its affiliates. If any reader of
> this communication is not the intended recipient, unauthorized use,
> forwarding, printing,  storing, disclosure or copying is strictly
> prohibited, and may be unlawful.If you have received this communication
> in error,please immediately notify the sender by return e-mail, and
> delete the original message and all copies from your system. Thank you.
> ---------------------------------------------------------------------------------------------------

This is a public forum :)

Dave




Re: How to associate a triple with a weight value?

Posted by Deyan Chen <ch...@neusoft.com>.

在 2014年09月18日 15:32, Dave Reynolds 写道:
> On 18/09/14 01:31, Deyan Chen wrote:
>> Hi Dave,
>>
>> Thank you for your reply.
>>
>> I know the means of the error, but I want to know why the second
>> case(model created by Model.union()) doesn't report the error.
>
> Presumably because in that case you are using TDB instead of an 
> in-memory data structure.

The model in my first test cast was created from TDB store and an 
in-memory data structure individually, it reported the same error.

>
>> And about the way to associate a triple with a weight value, have you a
>> better one or any other suggestions?
>
> Apart from reification at the RDF level the alternative is to consider 
> explicit n-ary relations. The implementation of n-ary relations boils 
> down to something much the same as reification - create resources, 
> typically b-nodes, to represent each instance of the relation with 
> separate properties to link that instance to the relation components 
> (such as subject, object, weight).
>
> It depends on whether you really are trying to annotate every RDF 
> statement or whether you want to build on top of RDF some way of 
> representing certain weighted property values.

I want to represent weighted property values on some RDF triples, such 
as, disease and symptom relations.

Thank you very much.

Deyan Chen

>
> Dave
>
>> Thank you very much.
>>
>> Deyan Chen
>>
>> 在 2014年09月17日 17:13, Dave Reynolds 写道:
>>>
>>> On 17/09/14 10:01, Deyan Chen wrote:
>>>> Hi all,
>>>>
>>>> I want to associate a triple with a weight value, for example:
>>>>
>>>> s1 p1 v1 with 20,
>>>> s1 p1 v2 with 11,
>>>> s1 p2 v3 with 30,
>>>> ......
>>>> s2 p1 v1 with 15,
>>>> s2 p2 v3 with 20,
>>>> ......
>>>>
>>>> The way I have tested is to make a anonymous ReifiedStatement object
>>>> from the triple/statement.
>>>> The example code is as following:
>>>>
>>>> // list the statements in the graph
>>>> StmtIterator stmtIter = model.listStatements(res, prop, (RDFNode) 
>>>> null);
>>>>
>>>> Property certaintyFactor = model.createProperty(fuzzyOntNameSpace,
>>>> "certainty_factor");
>>>>
>>>> // print out the predicate, subject and object of each statement
>>>> Statement stmt = null;
>>>>
>>>> while (stmtIter.hasNext()) {
>>>>      // get next statement
>>>>      stmt = stmtIter.nextStatement();
>>>>      System.out.println(stmt.toString());
>>>>
>>>>      if (stmt.isReified()) {
>>>>          stmt.removeReification();
>>>>      } else {
>>>>          ReifiedStatement reifStmt = stmt.createReifiedStatement();
>>>>          reifStmt.addLiteral(certaintyFactor, Math.random());
>>>
>>> N.B. This modifies the model you are iterating over.
>>>
>>>> System.out.println(reifStmt.toString());
>>>>      }
>>>> }
>>>>
>>>> The output is as following:
>>>>
>>>> [http://www.example.com/ontologies/2013/6/medicine.owl#m.029k_,
>>>> http://www.example.com/ontologies/2013/6/medicine.owl#disease.symptoms, 
>>>>
>>>> http://www.example.com/ontologies/2013/6/medicine.owl#m.014wq_]
>>>> (273851cd:146eb73208f:-7fea rdf:type rdf:Statement)
>>>> (273851cd:146eb73208f:-7fea rdf:subject medicine:m.029k_)
>>>> (273851cd:146eb73208f:-7fea rdf:predicate medicine:disease.symptoms)
>>>> (273851cd:146eb73208f:-7fea rdf:object medicine:m.014wq_)
>>>> (273851cd:146eb73208f:-7fea fuzzy:certainty_factor
>>>> '0.6892811680228655'^^http://www.w3.org/2001/XMLSchema#double)
>>>> Exception in thread "main" java.util.ConcurrentModificationException:
>>>
>>> As the error says, you are modifying a data structure while still
>>> iterating over it.
>>>
>>> Depending on the reification style the reification statements
>>> themselves may be visible but in any case the step noted above
>>> definitely adds statements to the model you are scanning.
>>>
>>> The thing to do is the build up a separate list of modification
>>> actions during the iteration and then afterwards perform all those
>>> modifications.
>>>
>>> Dave
>>>
>>>
>>
>> --------------------------------------------------------------------------------------------------- 
>>
>>
>> Confidentiality Notice: The information contained in this e-mail and any
>> accompanying attachment(s) is intended only for the use of the intended
>> recipient and may be confidential and/or privileged of Neusoft
>> Corporation, its subsidiaries and/or its affiliates. If any reader of
>> this communication is not the intended recipient, unauthorized use,
>> forwarding, printing,  storing, disclosure or copying is strictly
>> prohibited, and may be unlawful.If you have received this communication
>> in error,please immediately notify the sender by return e-mail, and
>> delete the original message and all copies from your system. Thank you.
>> --------------------------------------------------------------------------------------------------- 
>>
>>
>
> .
>

---------------------------------------------------------------------------------------------------
Confidentiality Notice: The information contained in this e-mail and any accompanying attachment(s) 
is intended only for the use of the intended recipient and may be confidential and/or privileged of 
Neusoft Corporation, its subsidiaries and/or its affiliates. If any reader of this communication is 
not the intended recipient, unauthorized use, forwarding, printing,  storing, disclosure or copying 
is strictly prohibited, and may be unlawful.If you have received this communication in error,please 
immediately notify the sender by return e-mail, and delete the original message and all copies from 
your system. Thank you. 
---------------------------------------------------------------------------------------------------

Re: How to associate a triple with a weight value?

Posted by Dave Reynolds <da...@gmail.com>.
On 18/09/14 01:31, Deyan Chen wrote:
> Hi Dave,
>
> Thank you for your reply.
>
> I know the means of the error, but I want to know why the second
> case(model created by Model.union()) doesn't report the error.

Presumably because in that case you are using TDB instead of an 
in-memory data structure.

> And about the way to associate a triple with a weight value, have you a
> better one or any other suggestions?

Apart from reification at the RDF level the alternative is to consider 
explicit n-ary relations. The implementation of n-ary relations boils 
down to something much the same as reification - create resources, 
typically b-nodes, to represent each instance of the relation with 
separate properties to link that instance to the relation components 
(such as subject, object, weight).

It depends on whether you really are trying to annotate every RDF 
statement or whether you want to build on top of RDF some way of 
representing certain weighted property values.

Dave

> Thank you very much.
>
> Deyan Chen
>
> 在 2014年09月17日 17:13, Dave Reynolds 写道:
>>
>> On 17/09/14 10:01, Deyan Chen wrote:
>>> Hi all,
>>>
>>> I want to associate a triple with a weight value, for example:
>>>
>>> s1 p1 v1 with 20,
>>> s1 p1 v2 with 11,
>>> s1 p2 v3 with 30,
>>> ......
>>> s2 p1 v1 with 15,
>>> s2 p2 v3 with 20,
>>> ......
>>>
>>> The way I have tested is to make a anonymous ReifiedStatement object
>>> from the triple/statement.
>>> The example code is as following:
>>>
>>> // list the statements in the graph
>>> StmtIterator stmtIter = model.listStatements(res, prop, (RDFNode) null);
>>>
>>> Property certaintyFactor = model.createProperty(fuzzyOntNameSpace,
>>> "certainty_factor");
>>>
>>> // print out the predicate, subject and object of each statement
>>> Statement stmt = null;
>>>
>>> while (stmtIter.hasNext()) {
>>>      // get next statement
>>>      stmt = stmtIter.nextStatement();
>>>      System.out.println(stmt.toString());
>>>
>>>      if (stmt.isReified()) {
>>>          stmt.removeReification();
>>>      } else {
>>>          ReifiedStatement reifStmt = stmt.createReifiedStatement();
>>>          reifStmt.addLiteral(certaintyFactor, Math.random());
>>
>> N.B. This modifies the model you are iterating over.
>>
>>> System.out.println(reifStmt.toString());
>>>      }
>>> }
>>>
>>> The output is as following:
>>>
>>> [http://www.example.com/ontologies/2013/6/medicine.owl#m.029k_,
>>> http://www.example.com/ontologies/2013/6/medicine.owl#disease.symptoms,
>>> http://www.example.com/ontologies/2013/6/medicine.owl#m.014wq_]
>>> (273851cd:146eb73208f:-7fea rdf:type rdf:Statement)
>>> (273851cd:146eb73208f:-7fea rdf:subject medicine:m.029k_)
>>> (273851cd:146eb73208f:-7fea rdf:predicate medicine:disease.symptoms)
>>> (273851cd:146eb73208f:-7fea rdf:object medicine:m.014wq_)
>>> (273851cd:146eb73208f:-7fea fuzzy:certainty_factor
>>> '0.6892811680228655'^^http://www.w3.org/2001/XMLSchema#double)
>>> Exception in thread "main" java.util.ConcurrentModificationException:
>>
>> As the error says, you are modifying a data structure while still
>> iterating over it.
>>
>> Depending on the reification style the reification statements
>> themselves may be visible but in any case the step noted above
>> definitely adds statements to the model you are scanning.
>>
>> The thing to do is the build up a separate list of modification
>> actions during the iteration and then afterwards perform all those
>> modifications.
>>
>> Dave
>>
>>
>
> ---------------------------------------------------------------------------------------------------
>
> Confidentiality Notice: The information contained in this e-mail and any
> accompanying attachment(s) is intended only for the use of the intended
> recipient and may be confidential and/or privileged of Neusoft
> Corporation, its subsidiaries and/or its affiliates. If any reader of
> this communication is not the intended recipient, unauthorized use,
> forwarding, printing,  storing, disclosure or copying is strictly
> prohibited, and may be unlawful.If you have received this communication
> in error,please immediately notify the sender by return e-mail, and
> delete the original message and all copies from your system. Thank you.
> ---------------------------------------------------------------------------------------------------
>


Re: How to associate a triple with a weight value?

Posted by Deyan Chen <ch...@neusoft.com>.
Hi Dave,

Thank you for your reply.

I know the means of the error, but I want to know why the second 
case(model created by Model.union()) doesn't report the error.

And about the way to associate a triple with a weight value, have you a 
better one or any other suggestions?

Thank you very much.

Deyan Chen

在 2014年09月17日 17:13, Dave Reynolds 写道:
>
> On 17/09/14 10:01, Deyan Chen wrote:
>> Hi all,
>>
>> I want to associate a triple with a weight value, for example:
>>
>> s1 p1 v1 with 20,
>> s1 p1 v2 with 11,
>> s1 p2 v3 with 30,
>> ......
>> s2 p1 v1 with 15,
>> s2 p2 v3 with 20,
>> ......
>>
>> The way I have tested is to make a anonymous ReifiedStatement object
>> from the triple/statement.
>> The example code is as following:
>>
>> // list the statements in the graph
>> StmtIterator stmtIter = model.listStatements(res, prop, (RDFNode) null);
>>
>> Property certaintyFactor = model.createProperty(fuzzyOntNameSpace,
>> "certainty_factor");
>>
>> // print out the predicate, subject and object of each statement
>> Statement stmt = null;
>>
>> while (stmtIter.hasNext()) {
>>      // get next statement
>>      stmt = stmtIter.nextStatement();
>>      System.out.println(stmt.toString());
>>
>>      if (stmt.isReified()) {
>>          stmt.removeReification();
>>      } else {
>>          ReifiedStatement reifStmt = stmt.createReifiedStatement();
>>          reifStmt.addLiteral(certaintyFactor, Math.random());
>
> N.B. This modifies the model you are iterating over.
>
>> System.out.println(reifStmt.toString());
>>      }
>> }
>>
>> The output is as following:
>>
>> [http://www.example.com/ontologies/2013/6/medicine.owl#m.029k_,
>> http://www.example.com/ontologies/2013/6/medicine.owl#disease.symptoms,
>> http://www.example.com/ontologies/2013/6/medicine.owl#m.014wq_]
>> (273851cd:146eb73208f:-7fea rdf:type rdf:Statement)
>> (273851cd:146eb73208f:-7fea rdf:subject medicine:m.029k_)
>> (273851cd:146eb73208f:-7fea rdf:predicate medicine:disease.symptoms)
>> (273851cd:146eb73208f:-7fea rdf:object medicine:m.014wq_)
>> (273851cd:146eb73208f:-7fea fuzzy:certainty_factor
>> '0.6892811680228655'^^http://www.w3.org/2001/XMLSchema#double)
>> Exception in thread "main" java.util.ConcurrentModificationException:
>
> As the error says, you are modifying a data structure while still 
> iterating over it.
>
> Depending on the reification style the reification statements 
> themselves may be visible but in any case the step noted above 
> definitely adds statements to the model you are scanning.
>
> The thing to do is the build up a separate list of modification 
> actions during the iteration and then afterwards perform all those 
> modifications.
>
> Dave
>
>

---------------------------------------------------------------------------------------------------
Confidentiality Notice: The information contained in this e-mail and any accompanying attachment(s) 
is intended only for the use of the intended recipient and may be confidential and/or privileged of 
Neusoft Corporation, its subsidiaries and/or its affiliates. If any reader of this communication is 
not the intended recipient, unauthorized use, forwarding, printing,  storing, disclosure or copying 
is strictly prohibited, and may be unlawful.If you have received this communication in error,please 
immediately notify the sender by return e-mail, and delete the original message and all copies from 
your system. Thank you. 
---------------------------------------------------------------------------------------------------

Re: How to associate a triple with a weight value?

Posted by Dave Reynolds <da...@gmail.com>.
On 17/09/14 10:01, Deyan Chen wrote:
> Hi all,
>
> I want to associate a triple with a weight value, for example:
>
> s1 p1 v1 with 20,
> s1 p1 v2 with 11,
> s1 p2 v3 with 30,
> ......
> s2 p1 v1 with 15,
> s2 p2 v3 with 20,
> ......
>
> The way I have tested is to make a anonymous ReifiedStatement object
> from the triple/statement.
> The example code is as following:
>
> // list the statements in the graph
> StmtIterator stmtIter = model.listStatements(res, prop, (RDFNode) null);
>
> Property certaintyFactor = model.createProperty(fuzzyOntNameSpace,
> "certainty_factor");
>
> // print out the predicate, subject and object of each statement
> Statement stmt = null;
>
> while (stmtIter.hasNext()) {
>      // get next statement
>      stmt = stmtIter.nextStatement();
>      System.out.println(stmt.toString());
>
>      if (stmt.isReified()) {
>          stmt.removeReification();
>      } else {
>          ReifiedStatement reifStmt = stmt.createReifiedStatement();
>          reifStmt.addLiteral(certaintyFactor, Math.random());

N.B. This modifies the model you are iterating over.

>          System.out.println(reifStmt.toString());
>      }
> }
>
> The output is as following:
>
> [http://www.example.com/ontologies/2013/6/medicine.owl#m.029k_,
> http://www.example.com/ontologies/2013/6/medicine.owl#disease.symptoms,
> http://www.example.com/ontologies/2013/6/medicine.owl#m.014wq_]
> (273851cd:146eb73208f:-7fea rdf:type rdf:Statement)
> (273851cd:146eb73208f:-7fea rdf:subject medicine:m.029k_)
> (273851cd:146eb73208f:-7fea rdf:predicate medicine:disease.symptoms)
> (273851cd:146eb73208f:-7fea rdf:object medicine:m.014wq_)
> (273851cd:146eb73208f:-7fea fuzzy:certainty_factor
> '0.6892811680228655'^^http://www.w3.org/2001/XMLSchema#double)
> Exception in thread "main" java.util.ConcurrentModificationException:

As the error says, you are modifying a data structure while still 
iterating over it.

Depending on the reification style the reification statements themselves 
may be visible but in any case the step noted above definitely adds 
statements to the model you are scanning.

The thing to do is the build up a separate list of modification actions 
during the iteration and then afterwards perform all those modifications.

Dave