My work around is to create a pipeline wrapper class that has a run(JCas) method and that seems to work fine. But I would still like to know what is causing the issue. It is effectively doing this under the hood, which is fine.
piperReader.loadPipelineFile("path/to/default.piper"); piperFileReader.getBuilder().set(UmlsUserApprover.KEY_PARAM, "<key>"); piperFileReader.getBuilder().build(); SimplePipeline.runPipeline(jCas, piperFileReader.getBuilder().getAnalysisEngineDesc()); On Thu, Apr 22, 2021 at 2:24 PM John Doe <lucanus...@gmail.com> wrote: > Hi Sean, > > I tried this piper builder approach below and it also didn't work. > > PipelineBuilder pipelineBuilder = new PipelineBuilder(); > pipelineBuilder.set(UmlsUserApprover.KEY_PARAM, "<my-key>"); > AnalysisEngineDescription aed = > ClinicalPipelineFactory.getDefaultPipeline(); > pipelineBuilder.addDescription(aed); > pipelineBuilder.run("text"); > > Mainly, I just want to understand what the issue is. But the reason it > came up is because I want to set up ctakes to work in real time. So I want > clients to be able to send in notes and have them get processed using the > default clinical pipeline on one of several nodes running ctakes. The > reason I don't want to use builder.run("text") is because it recreates the > jCas every time, which I don't think will scale well. I would rather each > node create the jCas once and call jCas.reset() after each note is done > getting processed rather than have it get instantiated again. I think > creating the jCas is expensive but correct me if I'm wrong. > > On Thu, Apr 22, 2021 at 1:58 PM Finan, Sean < > sean.fi...@childrens.harvard.edu> wrote: > >> 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? >> >