You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ctakes.apache.org by Reed Villanueva <vi...@gmail.com> on 2018/04/09 03:27:15 UTC

Re: resources location problem? Initialization of annotator class "org.apache.ctakes.assertion.medfacts.cleartk.PolarityCleartkAnalysisEngine" failed in default clinical pipeline

Problem solved.

Upon further inspection, it appears that the resource

/org/apache/ctakes/assertion/models/polarity/sharpi2b2mipacqnegex/model.jar

just was simply not in the resources folder I was using (which only
appeared to have the .../ctakes/dictionary and .../ctakes/lvg
components), which
is probably why it seemed like my project was going through all of the same
execution steps as the original reference
/trunk/ctakes-example/.../HelloWorldAggregatePipeline.java
program and yet still returning null when trying to find that particular
resource.

I had downloaded the 4.0 resources file from the ctakes sourceforge
location (https://sourceforge.net/projects/ctakesresources/files/) to use
for my project, which when compared to the 4.0 and 4.0.1 binary
distributions' existing resources/ folder, actually has ***less*** files
(only had org/apache/ctakes/dictionary and org/apache/ctakes/lvg).

In the future, I think the best thing to do to be sure project is using all
necessary resources would be to build the /trunk source, extract the
ctakes-distribution/target/ binaries, then from those extraction
distribution binaries, copy the resources/ folder to the top level (as
implicitly expected by certain ctakes resource locator classes) of the
project. Running my project variation of the original
HelloWorldAggregatePipeline program after this change seems to have fixed
the problem.

** Note the side-effect of this "fix" is that the 4.0.1 distribution from
the trunk/ctakes-distribution build does not seem to come with the file
org/apache/ctakes/dictionary/lookup/fast/sno_rx_16ab.xml nor the associated
folder org/apache/ctakes/dictionary/lookup/fast/sno_rx_16ab. To address
this, I just added it myself after downloading it from the ctakes
sourceforge (https://sourceforge.net/projects/ctakesresources/files/).

On Sat, Apr 7, 2018 at 5:06 PM, Reed Villanueva <vi...@gmail.com>
wrote:

> Trying to run a copy of the trunk/ctakes-examples/.../
> HelloWorldAggregatePipeline.java in an intellij project using the line
>
> builder.add( ClinicalPipelineFactory.getDefaultPipeline() );
>
>
> (rather than code: ClinicalPipelineFactory.getTokenProcessingPipeline())
> but getting the error
>
> ​.......
>>
> 06 Apr 2018 09:42:56  INFO JdbcConceptFactory - Connected to concept table
>> SNOMEDCT_US with class LONG
>
> Loading configuration.
>
> Loading feature templates.
>
> Loading lexica.
>
> Loading model:
>
> ............................................................
>> ............................
>
> 06 Apr 2018 09:43:08  INFO ClearNLPDependencyParserAE - Initializing
>> ClearNLP dependency parser, using lemmatizer: true
>
> org.apache.uima.resource.ResourceInitializationException: Initialization
>> of annotator class "org.apache.ctakes.assertion.medfacts.cleartk.PolarityCleartkAnalysisEngine"
>> failed.  (Descriptor: <unknown>)
>>
> at org.apache.uima.analysis_engine.impl.PrimitiveAnalysisEngine_impl.
>> initializeAnalysisComponent(PrimitiveAnalysisEngine_impl.java:274)
>
> at org.apache.uima.analysis_engine.impl.PrimitiveAnalysisEngine_impl.
>> initialize(PrimitiveAnalysisEngine_impl.java:172)
>
> at org.apache.uima.impl.AnalysisEngineFactory_impl.produceResource(
>> AnalysisEngineFactory_impl.java:94)
>
> at org.apache.uima.impl.CompositeResourceFactory_impl.produceResource(
>> CompositeResourceFactory_impl.java:62)
>
> at org.apache.uima.UIMAFramework.produceResource(UIMAFramework.java:279)
>
> at org.apache.uima.UIMAFramework.produceAnalysisEngine(
>> UIMAFramework.java:407)
>
> at org.apache.uima.analysis_engine.asb.impl.ASB_impl.
>> setup(ASB_impl.java:256)
>
> at org.apache.uima.analysis_engine.impl.AggregateAnalysisEngine_impl.
>> initASB(AggregateAnalysisEngine_impl.java:435)
>
> at org.apache.uima.analysis_engine.impl.AggregateAnalysisEngine_impl.
>> initializeAggregateAnalysisEngine(AggregateAnalysisEngine_impl.java:379)
>
> at org.apache.uima.analysis_engine.impl.AggregateAnalysisEngine_impl.
>> initialize(AggregateAnalysisEngine_impl.java:192)
>
> at org.apache.uima.impl.AnalysisEngineFactory_impl.produceResource(
>> AnalysisEngineFactory_impl.java:94)
>
> at org.apache.uima.impl.CompositeResourceFactory_impl.produceResource(
>> CompositeResourceFactory_impl.java:62)
>
> at org.apache.uima.UIMAFramework.produceResource(UIMAFramework.java:279)
>
> at org.apache.uima.UIMAFramework.produceAnalysisEngine(
>> UIMAFramework.java:407)
>
> at org.apache.uima.analysis_engine.asb.impl.ASB_impl.
>> setup(ASB_impl.java:256)
>
> at org.apache.uima.analysis_engine.impl.AggregateAnalysisEngine_impl.
>> initASB(AggregateAnalysisEngine_impl.java:435)
>
> at org.apache.uima.analysis_engine.impl.AggregateAnalysisEngine_impl.
>> initializeAggregateAnalysisEngine(AggregateAnalysisEngine_impl.java:379)
>
> at org.apache.uima.analysis_engine.impl.AggregateAnalysisEngine_impl.
>> initialize(AggregateAnalysisEngine_impl.java:192)
>
> at org.apache.uima.impl.AnalysisEngineFactory_impl.produceResource(
>> AnalysisEngineFactory_impl.java:94)
>
> at org.apache.uima.impl.CompositeResourceFactory_impl.produceResource(
>> CompositeResourceFactory_impl.java:62)
>
> at org.apache.uima.UIMAFramework.produceResource(UIMAFramework.java:279)
>
> at org.apache.uima.UIMAFramework.produceAnalysisEngine(
>> UIMAFramework.java:407)
>
> at org.apache.uima.analysis_engine.asb.impl.ASB_impl.
>> setup(ASB_impl.java:256)
>
> at org.apache.uima.analysis_engine.impl.AggregateAnalysisEngine_impl.
>> initASB(AggregateAnalysisEngine_impl.java:435)
>
> at org.apache.uima.analysis_engine.impl.AggregateAnalysisEngine_impl.
>> initializeAggregateAnalysisEngine(AggregateAnalysisEngine_impl.java:379)
>
> at org.apache.uima.analysis_engine.impl.AggregateAnalysisEngine_impl.
>> initialize(AggregateAnalysisEngine_impl.java:192)
>
> at org.apache.uima.impl.AnalysisEngineFactory_impl.produceResource(
>> AnalysisEngineFactory_impl.java:94)
>
> at org.apache.uima.impl.CompositeResourceFactory_impl.produceResource(
>> CompositeResourceFactory_impl.java:62)
>
> at org.apache.uima.UIMAFramework.produceResource(UIMAFramework.java:279)
>
> at org.apache.uima.UIMAFramework.produceResource(UIMAFramework.java:331)
>
> at org.apache.uima.UIMAFramework.produceAnalysisEngine(
>> UIMAFramework.java:448)
>
> at org.apache.uima.fit.factory.AnalysisEngineFactory.createEngine(
>> AnalysisEngineFactory.java:205)
>
> at org.apache.uima.fit.pipeline.SimplePipeline.runPipeline(
>> SimplePipeline.java:259)
>
> at org.apache.uima.fit.pipeline.SimplePipeline.runPipeline(
>> SimplePipeline.java:292)
>
> at doodles.HelloWorldAggregatePipeline.runPipelineBuild(
>> HelloWorldAggregatePipeline.java:89)
>
> at doodles.HelloWorldAggregatePipeline.main(HelloWorldAggregatePipeline.
>> java:44)
>
> Caused by: org.apache.uima.resource.ResourceInitializationException
>
> at org.cleartk.ml.CleartkAnnotator.initialize(CleartkAnnotator.java:137)
>
> at org.apache.ctakes.assertion.medfacts.cleartk.
>> AssertionCleartkAnalysisEngine.initialize(AssertionCleartkAnalysisEngine
>> .java:201)
>
> at org.apache.ctakes.assertion.medfacts.cleartk.
>> PolarityCleartkAnalysisEngine.initialize(PolarityCleartkAnalysisEngine.
>> java:59)
>
> at org.apache.uima.analysis_engine.impl.PrimitiveAnalysisEngine_impl.
>> initializeAnalysisComponent(PrimitiveAnalysisEngine_impl.java:267)
>
> ... 35 more
>
> Caused by: java.io.FileNotFoundException: /org/apache/ctakes/assertion/
>> models/polarity/sharpi2b2mipacqnegex/model.jar (No such file or
>> directory)
>
> at java.io.FileInputStream.open0(Native Method)
>
> at java.io.FileInputStream.open(FileInputStream.java:195)
>
> at java.io.FileInputStream.<init>(FileInputStream.java:138)
>
> at java.io.FileInputStream.<init>(FileInputStream.java:93)
>
> at org.cleartk.ml.jar.GenericJarClassifierFactory.createClassifier(
>> GenericJarClassifierFactory.java:69)
>
> at org.cleartk.ml.jar.JarClassifierFactory.createClassifier(
>> JarClassifierFactory.java:35)
>
> at org.cleartk.ml.CleartkAnnotator.initialize(CleartkAnnotator.java:135)
>
> ... 38 more
>
>
> ​Investigating into the error, I see what seems to be the problem that in
>
> ctakes-libs/cleartk-ml-2.0.0.jar!/org/cleartk/ml/jar/
>> GenericJarClassifierFactory.class​, line 42 (ctakes-libs being the
>> folder in my project that holds the ctakes jar files)
>
>
> when setting a conditional breakpoint here of
>
> this.classifierJarPath.equals("/org/apache/ctakes/assertion/
>> models/polarity/sharpi2b2mipacqnegex/model.jar")
>
>
> the variable "stream" is getting set to null. This differs from what I see
> in the intellij debugger when running the *original*
>
> trunk/ctakes-examples/src/main/java/org/apache/ctakes/examples/pipeline/
>> HelloWorldAggregatePipeline.java
>
>
> file, where "stream" does *not* get set to null in that section of the
> code. Looking further into the problem, I see that further into the
> execution stack, at execution frame
>
> getResourceAsStream:2223, Class
>> ​.java​
>> (java.lang)
>
>
> ​for the line of code​
>
> return cl.getResourceAsStream(name);
>
>
> the original trunk example has the value
>
> URLClassLoader.getResourceAsStream(String)=BufferedInputStream
>
> with field in.path = /home/me/projects/ctakes/trunk/ctakes-assertion-res/
>> target/classes/org/apache/ctakes/assertion/models/
>> polarity/sharpi2b2mipacqnegex/model.jar
>
>
> whereas in my project, I see in the debugger that same line returns
>
> URLClassLoader.getResourceAsStream(String)=null
>
>
> What does this imply? Why can our project program not find this resource
> jar?
> If anyone else has any knowledge about what is happening here, I would
> appreciate some advice.
>
>
> Just in case this has something to do with undocumented expectations about
> where resources folders need to be, my intellij project structure from the
> project.iml file looks like
>
> <component name="NewModuleRootManager" inherit-compiler-output="true">
>   <exclude-output />
>   <content url="file://$MODULE_DIR$">
>     <sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
>     <sourceFolder url="file://$MODULE_DIR$/stuff/mystuff/src" isTestSource="false" />
>     <sourceFolder url="file://$MODULE_DIR$/resources" type="java-resource" />
>     <sourceFolder url="file://$MODULE_DIR$/stuff/mystuff/desc" type="java-resource" />  (I actually don't know why it says this, as I deleted this folder some time ago)
>     <sourceFolder url="file://$MODULE_DIR$/resources" type="java-resource" />
>     <sourceFolder url="file://$MODULE_DIR$/desc" type="java-resource" />
>   </content>
>   <orderEntry type="jdk" jdkName="1.8" jdkType="JavaSDK" />
>   <orderEntry type="sourceFolder" forTests="false" />
>   <orderEntry type="library" name="ctakes-libs" level="project" />
> </component>
>
>
>
>