Hi John,

Just out of curiosity, if you have one method that works then why do you want 
to use a different method to do the same thing?

I personally use the PIpelineBuilder as you have in your second example when I 
need to work with code - though that is extremely rare as piper files can 
handle everything that I normally want to do.

If you want an example of how to build a pipeline using only code (no piper 
file) then check the ctakes-examples module, class ProcessDirBuilderRunner.  It 
recreates the default clinical pipeline without dictionary lookup.  Adding in 
the lookup is fairly simple:

builder
  ...
  .set( UmlsUserApprover.KEY_PARAM, "my-umls-key" )
  .add( DefaultJCasTermAnnotator.class )
  ...

or the single line
  .add( DefaultJCasTermAnnotator.class, Collections.emptyList(),  
UmlsUserApprover.KEY_PARAM, "my-umls-key" )

The code above is just off the top of my head, so I apologize for any typos or 
slight misdirection.  Hopefully it is enough to point a way for you.

Sean

________________________________________
From: John Doe <lucanus...@gmail.com>
Sent: Thursday, April 22, 2021 1:09 PM
To: dev@ctakes.apache.org
Subject: Running cTAKES Default Clinical Pipeline from Code [EXTERNAL]

* External Email - Caution *


Hello,

I'm having trouble running the default clinical pipeline from code. It
keeps giving me the error message that I have an invalid UMLS License.
However, I know my license is valid and I have managed to get the default
pipeline to run using the PiperFileReader with the same credentials.

This is the code that doesn't work that I would like to get working:

System.setProperty(UmlsUserApprover.KEY_PARAM, "my-umls-key");
JCas jCas = JCasFactory.createJCas();
jCas.setDocumentText("My text");
AnalysisEngineDescription aed =
ClinicalPipelineFactory.getDefaultPipeline();
SimplePipeline.runPipeline(jCas, aed);

This is the code that I managed to get to work. This just demonstrates to
me that it isn't really a credential issue.
PiperFileReader piperReader = new PiperFileReader();
PipelineBuilder builder = piperReader.getBuilder();
builder.set( UmlsUserApprover.KEY_PARAM  , "the-same-umls-key");
piperReader.loadPipelineFile("path/to/default.piper");
builder.run("test text");

default.piper just loads the default pipeline:
load
./resources/org/apache/ctakes/clinical/pipeline/DefaultFastPipeline.piper

Does anyone know what the issue might be here?

Reply via email to