Hi Carolina,

 If you are using a binary installation of ctakes 4.0.0 and editing an examples 
piper in the root resources/ directory then you may have a problem such as you 
describe.
There is an unwanted ctakes-examples-res.jar in the lib/ directory that contain 
copies of all the example pipers, and those pipers are loaded instead of the 
ones in resources/
You can delete the ctakes-examples-res.jar in lib/ and try again.

When you start writing your own piper files you should probably also start 
using the PiperFileRunner class.  Or the Piper File Submitter GUI.
https://cwiki.apache.org/confluence/display/CTAKES/Piper+Files


Here is a template for an annotator.

public class MyAnnotator extends JCasAnnotator_ImplBase {

   public void initialize( UimaContext context ) throws 
ResourceInitializationException {
      super.initialize( context );
      //  My initialization code.
   }
   public void process( JCas jcas ) throws AnalysisEngineProcessException {
      // My process code.
   }
}


The JCas is the main data object passed through the pipeline.
You can find information on JCas on the web, but it can be overwhelming.
 
The two primary get() style methods are
1.  org.apache.uima.fit.util.JCasUtil.select( jcas, [type class] )
http://uima.apache.org/d/uimafit-current/api/org/apache/uima/fit/util/JCasUtil.html
2.  org.apache.ctakes.core.util.OntologyConceptUtil.  *(..)
http://ctakes.apache.org/apidocs/4.0.0/org/apache/ctakes/core/util/OntologyConceptUtil.html

If you are a developer (you are writing your own java class), then I highly 
recommend checking out the ctakes trunk repository and looking at existing 
annotators.
svn co https://svn.apache.org/repos/asf/ctakes/trunk/

Within the code are the various ctakes modules, and almost all of them have a 
package named "ae" containing annotators.


Sean

________________________________________
From: Cervantes, Carolina <ccervant...@luc.edu>
Sent: Wednesday, December 4, 2019 2:13 PM
To: dev@ctakes.apache.org
Subject: Adding Java Class to Piper File [EXTERNAL]

Warning: Email originated outside Boston Children's. Don't click 
links/attachments unless you know sender & content seems safe.


**********************************************************************
Hello,

I have been attempting to add a custom java class into a .piper file which can 
extract CUIs. I have been focused on adding this class to the 
HelloWorldCui.piper file and I am then running the class 
HelloWorldCuiPiperRunner via the terminal. While I have been tinkering with the 
HelloWorldCui.piper file, I have run into two main issues:



  1.  Modifications to the .piper file are not reflected while running the 
HelloWorldCuiPiperRunner via terminal (or IntelliJ). I have tried to add code 
to include the class file, after not having luck with this, I began to comment 
out other parts of the .piper file to observe the effects. I commented out 
integral pieces of the HelloWorldCui.piper file (the lines containing 'load 
DictionarySubPipe.piper' and 'collectCuis'). After running 
HelloWorldPiperRunner with the aforementioned lines commented out, the behavior 
is exactly the same. I have ensured that the changes to the .piper file were 
saved, have cleaned and compiled, and have run this on another machine. Is this 
the correct way to modify and use piper files?

  2.  What is the correct way to add a java file to a pipeline?

Best,
Carolina

Reply via email to