Hi Marshall,

no the aJCas is the source and jcas is an empty JCas which I want to fill with 
this method. Currently I'm currently not working at my thesis because of other 
projects, but I'll try the method Richard suggested the next days. Actually I'm 
reading the JCas from source everytime I need a copy instead of cloning them, 
but there's a good chance that Richards method could be much faster.

Greetings

Bojan

----- Ursprüngliche Mail -----
Von: "Marshall Schor" <[email protected]>
An: [email protected]
Gesendet: Donnerstag, 27. Juni 2013 05:31:25
Betreff: Re: Clone a JCas

Hi,
I wonder if this is just a reversed set of parameters.

You write below ...

CasCopier.copyCas(aJCas.getCas(), jcas.getCas(), true);


But the "source" to be copied should be the 1st parameter, and the 2nd is the
"destination".

So it looks like the first two arguments might be reversed?

-Marshall

On 6/3/2013 5:49 PM, Bojan Janisch wrote:
> Hi everyone,
>
> I'm a german student and currently working at my bachelor 
> thesis. I'm new to this mailing list so I hope my question 
> is suitable for you.
>
> I'm using Genetic Algorithms to create rules which processes / 
> annotates the JCases. After that, the results are evaluated and 
> a F-Score is returned which flows into the fitness function of 
> the genetic algorithm. So I'm only using the JCases for 
> evaluation and don't need to write them back. 
>
> I already tried the CasCopier.copyCas() method:
>
> public static JCas copyJCas(JCas aJCas) {
>   JCas jcas = null;
>   jcas = JCasFactory.createJCas(UIMATestUtils.readTypeSystem());
>   CasCopier.copyCas(aJCas.getCas(), jcas.getCas(), true);
>   return jcas;
> }
>
> but I'm getting these two exceptions with the following 
> stacktraces:
>
> Exception in thread "ECJ Evaluation Thread 0" 
> java.lang.ArrayIndexOutOfBoundsException: 1015
>       at org.apache.uima.jcas.impl.JCasHashMap.put(JCasHashMap.java:139)
>       at 
> org.apache.uima.jcas.impl.JCasImpl.putJfsFromCaddr(JCasImpl.java:1035)
>       at 
> org.apache.uima.jcas.impl.JCasImpl$JCasFsGenerator.createFS(JCasImpl.java:847)
>       at org.apache.uima.cas.impl.CASImpl.ll_getFSForRef(CASImpl.java:3117)
>       at org.apache.uima.cas.impl.CASImpl.createFS(CASImpl.java:1773)
>       at 
> org.apache.uima.cas.impl.FeatureStructureImpl.getFeatureValue(FeatureStructureImpl.java:234)
>       at org.apache.uima.util.CasCopier.copyFeatures(CasCopier.java:312)
>       at org.apache.uima.util.CasCopier.copyFs(CasCopier.java:190)
>       at org.apache.uima.util.CasCopier.copyCasView(CasCopier.java:149)
>       at org.apache.uima.util.CasCopier.copyCas(CasCopier.java:108)
>       at rulevolution.utils.JCasUtils.copyJCas(JCasUtils.java:80)
>       at rulevolution.utils.JCasUtils.copyCasPool(JCasUtils.java:94)
>       at rulevolution.RulEvolution.evaluate(RulEvolution.java:105)
>       at ec.simple.SimpleEvaluator.evalPopChunk(SimpleEvaluator.java:259)
>       at 
> ec.simple.SimpleEvaluator$SimpleEvaluatorThreadCG.run(SimpleEvaluator.java:341)
>       at ec.util.ThreadPool$PoolThread.run(ThreadPool.java:57)
>
> Exception in thread "ECJ Evaluation Thread 2" 
> java.lang.IndexOutOfBoundsException: Index: 0, Size: 1
>       at java.util.ArrayList.rangeCheck(Unknown Source)
>       at java.util.ArrayList.get(Unknown Source)
>       at 
> org.apache.uima.cas.impl.FSIndexRepositoryImpl$LeafPointerIterator.initPointerIterator(FSIndexRepositoryImpl.java:628)
>       at 
> org.apache.uima.cas.impl.FSIndexRepositoryImpl$LeafPointerIterator.<init>(FSIndexRepositoryImpl.java:636)
>       at 
> org.apache.uima.cas.impl.FSIndexRepositoryImpl$LeafPointerIterator.<init>(FSIndexRepositoryImpl.java:612)
>       at 
> org.apache.uima.cas.impl.FSIndexRepositoryImpl.createPointerIterator(FSIndexRepositoryImpl.java:158)
>       at 
> org.apache.uima.cas.impl.FSIndexRepositoryImpl$IndexImpl.iterator(FSIndexRepositoryImpl.java:792)
>       at org.apache.uima.util.CasCopier.copyCasView(CasCopier.java:145)
>       at org.apache.uima.util.CasCopier.copyCas(CasCopier.java:108)
>       at rulevolution.utils.JCasUtils.copyJCas(JCasUtils.java:80)
>       at rulevolution.utils.JCasUtils.copyCasPool(JCasUtils.java:94)
>       at rulevolution.RulEvolution.evaluate(RulEvolution.java:105)
>       at ec.simple.SimpleEvaluator.evalPopChunk(SimpleEvaluator.java:259)
>       at 
> ec.simple.SimpleEvaluator$SimpleEvaluatorThreadCG.run(SimpleEvaluator.java:341)
>       at ec.util.ThreadPool$PoolThread.run(ThreadPool.java:57)
>
> My goal would be generating a JCas pool at beginning of the algorithm. Then 
> cloning the entire 
> jcas pool for each rule evaluation. After the rule is evaluated the cloned 
> cas pool needs to be
> deleted.
>
> Does someone know why I'm getting these exceptions and are there some ways to 
> work with JCas objects outside of UIMA Concext? 
>
> Greetings 
>
> Bojan
>
>

Reply via email to