ctakes examples ctakes_cnlpt_py - apache/ctakes GitHub Wiki

Piper Files


Piper Files

Cnlpt Negation

This is an example piper file that will spin up a complete pbj pipeline.

Cnlpt Negation

$\textcolor{gray}{\textsf{\# }}$
$\textcolor{gray}{\textsf{\# This is an example piper file that will spin up a complete pbj pipeline. }}$
$\textcolor{gray}{\textsf{\# }}$
$\textcolor{gray}{\textsf{\# This piper will start the Apache Artemis broker pointed to by the -a parameter on the command line. }}$
$\textcolor{gray}{\textsf{\# It will pause for 5 seconds to allow Artemis to fully launch. }}$
$\textcolor{gray}{\textsf{\# }}$
$\textcolor{gray}{\textsf{\# This piper will then launch another instance of Apache cTAKES. }}$
$\textcolor{gray}{\textsf{\# That instance of cTAKES will run the third and final bit of the entire PBJ pipeline. }}$
$\textcolor{gray}{\textsf{\# }}$
$\textcolor{gray}{\textsf{\# This piper will then launch a python PBJ pipeline that runs the negation model from the external project }}$
$\textcolor{gray}{\textsf{\# Clinical NLP Transformers (cnlp\_transformers), which can be found at }}$
$\textcolor{gray}{\textsf{\# (http)s://github.com/Machine-Learning-for-Medical-Language/cnlp\_transformers }}$
$\textcolor{gray}{\textsf{\# }}$

$\textcolor{gray}{\textsf{\# }}$
$\textcolor{gray}{\textsf{\# To run this pipeline from the command line, use the parameters: }}$
$\textcolor{gray}{\textsf{\# -p CnlptNegation }}$
$\textcolor{gray}{\textsf{\# -v \{python environment Directory\} }}$
$\textcolor{gray}{\textsf{\# -a \{Artemis Broker Directory\} }}$
$\textcolor{gray}{\textsf{\# -i \{Input Document Directory\} }}$
$\textcolor{gray}{\textsf{\# -o \{Output Directory\} }}$
$\textcolor{gray}{\textsf{\# --key \{UMLS Key\} }}$
$\textcolor{gray}{\textsf{\# }}$
$\textcolor{gray}{\textsf{\# A standard command-line option is the specification of whether or not to pip the ctakes-pbj package. }}$
$\textcolor{gray}{\textsf{\# By default ctakes-pbj will be pip ed at the beginning of a run. You can turn this off with: }}$
$\textcolor{gray}{\textsf{\# --pipPbj no }}$
$\textcolor{gray}{\textsf{\# }}$

$\textcolor{gray}{\textsf{// Sets up required parameters, starts your Artemis Broker, pips the PBJ project. }}$
$\textcolor{magenta}{\textbf{load}}$ PbjStarter

$\textcolor{gray}{\textsf{// }}$
$\textcolor{gray}{\textsf{// Start another instance of cTAKES, running the pipeline in StartAllExample\_end.piper }}$
$\textcolor{gray}{\textsf{// \$OutputDirectory will substitute the value of this cTAKES pipeline's value for OutputDirectory. }}$
$\textcolor{gray}{\textsf{// \$ArtemisBroker will substitute the value of this cTAKES pipeline's value for ArtemisBroker. }}$
$\textcolor{gray}{\textsf{// }}$

$\textcolor{green}{\textbf{add}}$ CtakesRunner $\textcolor{purple}{\textbf{Pipeline}}$= $\textcolor{violet}{\textsf{"-p PbjThirdStep -o \$OutputDirectory -a \$ArtemisBroker"}}$


$\textcolor{gray}{\textsf{// }}$
$\textcolor{gray}{\textsf{// Start the python bit of the full pipeline. }}$
$\textcolor{gray}{\textsf{// }}$

$\textcolor{gray}{\textsf{// pip the cnlp\_transformers project and its dependencies. }}$
$\textcolor{gray}{\textsf{//add PythonRunner Command="-m pip install resources/org/apache/ctakes/examples/ctakes\_cnlpt\_py/" Wait=yes }}$
$\textcolor{green}{\textbf{add}}$ PythonPipper $\textcolor{purple}{\textbf{PipPackage}}$= $\textcolor{violet}{\textsf{"resources/org/apache/ctakes/examples/ctakes\_cnlpt\_py/"}}$ $\textcolor{purple}{\textbf{Wait}}$= $\textcolor{violet}{\textsf{yes}}$

$\textcolor{gray}{\textsf{// There is a fixed order to queue specification in python pipelines. }}$
$\textcolor{gray}{\textsf{// The incoming (receiver) queue is named first, the outgoing (sender) queue is named second. }}$
$\textcolor{gray}{\textsf{// TODO: Right now cnlpt isn't using --output\_dir. Need to figure out why. }}$
$\textcolor{green}{\textbf{add}}$ PythonRunner $\textcolor{purple}{\textbf{Command}}$= $\textcolor{violet}{\textsf{"-m ctakes\_cnlpt.negation\_pipeline --receive\_queue JavaToPy --send\_queue PyToJava --output\_dir \$OutputDirectory"}}$


$\textcolor{gray}{\textsf{// }}$
$\textcolor{gray}{\textsf{// The pipeline run by this instance of cTAKES. }}$
$\textcolor{gray}{\textsf{// }}$

$\textcolor{gray}{\textsf{// Load a simple token processing pipeline from another pipeline file }}$
$\textcolor{magenta}{\textbf{load}}$ DefaultTokenizerPipeline
$\textcolor{magenta}{\textbf{load}}$ DictionarySubPipe

$\textcolor{gray}{\textsf{// Send CAS to Artemis at the specified queue. Send stop signal when processing has finished. }}$
$\textcolor{green}{\textbf{add}}$ PbjJmsSender $\textcolor{purple}{\textbf{SendQueue}}$= $\textcolor{violet}{\textsf{JavaToPy}}$ $\textcolor{purple}{\textbf{SendStop}}$= $\textcolor{violet}{\textsf{yes}}$

⚠️ **GitHub.com Fallback** ⚠️