Developing and running applications that use the Text Toolkit

Specialized toolkits - release 4.3.1.0-prod20190605 > com.ibm.streams.text 2.3.2 > Developing and running applications that use the Text Toolkit

To create applications that use the Text Toolkit, you must configure either Streams Studio or the SPL compiler to be aware of the location of the toolkit.

Before you begin

Install IBM Streams. Configure the product environment variables by entering the following command:

source product-installation-root-directory/4.2.0.0/bin/streamsprofile.sh

About this task

After the location of the toolkit is communicated to the compiler, the SPL artifacts that are specified in the toolkit can be used by an application. The application can include a use directive to bring the necessary namespaces into scope. Alternatively, you can fully qualify the operators that are provided by toolkit with their namespaces as prefixes.

Procedure

  1. Configure the SPL compiler to find the toolkit root directory. Use one of the following methods:
    • Set the STREAMS_SPLPATH environment variable to the root directory of a toolkit or multiple toolkits (with : as a separator). For example:
      
      export STREAMS_SPLPATH=$STREAMS_INSTALL/toolkits/com.ibm.streams.text
      
    • Specify the -t or --spl-path command parameter when you run the sc command. For example:
      
      sc -t $STREAMS_INSTALL/toolkits/com.ibm.streams.text -M MyMain
      
      where MyMain is the name of the SPL main composite. Note: These command parameters override the STREAMS_SPLPATH environment variable.
    • Add the toolkit location in IBM Streams Studio.
  2. Develop your application. To avoid the need to fully qualify the operators, add a use directive in your application.
    • For example, you can add the following clause in your SPL source file:
      
      use com.ibm.streams.text::*;
      
      You can also specify a use clause for individual operators by replacing the asterisk (*) with the operator name. For example:
      
      use com.ibm.streams.text::TextExtract;
      
  3. Set the appropriate environment variables:
    • If your application loads Text Analytics Module (TAM) files from HDFS and uses Apache Hadoop, set HADOOP_HOME before you compile the application. It must also be set in your run time environment. For stand-alone streams processing applications, the environment variable must be set before you run the application. For distributed streams processing applications, the environment variable must be set in your .bashrc file before you start the instance.
    • If your application loads TAM files from HDFS or GPFS and uses IBM BigInsights, run the following command before you compile the streams processing application:
      
      source BIGINSIGHTS_HOME/conf/biginsights-env.sh
      
      Add the source command to your .bashrc file before you start the instance.
  4. Build your application. You can use the sc command or Streams Studio.
  5. Start the IBM Streams instance.
  6. Run the application. You can submit the application as a job by using the streamtool submitjob command or by using Streams Studio.