Icon

02.Workflow Services - Sentiment Predictor - Lexicon Based - Exercise

<p>This workflow calls workflow segments that preprocess and tag airline reviews, uses shared components that help come up with sentiment scores, and then calls a last workflow segment that joins the generated data with the original reviews. This workflow can be used to deploy a lexicon-based sentiment analysis predictor.</p>

Part 3 - Workflow Invocation and Integrated Deployment

Exercise 02 Integrated Deployment - Sentiment Predictor - Lexicon Based

Learning objective: In this exercise you'll learn how to use workflow services functionalities to re-use segments of workflows and components.


Workflow description: This workflow calls workflow segments that preprocess and tag airline reviews, uses shared components that help come up with sentiment scores, and then calls a last workflow segment that joins the generated data with the original reviews. This workflow can be used to deploy a lexicon-based sentiment analysis predictor.


You'll find the instructions to the exercises in the yellow annotations.

Step 1. Call workflow segment for data preprocessing.

  1. Using the Call Workflow Service node, set the workflow relative path to captured segment as '../Workflow Segments/01.Captured Segment 1 Data Preparation'. Adjust node ports and click 'OK'.

  2. Connect the output of the Column Renamer node to the Call Workflow Service node to preprocess the tweets with renamed columns.

  3. Execute the node and connect its output to the following instance of the Call Workflow Service node, already present in the exercise.



Here we read tweets that were previously collected with the Twitter API, and a few columns get renamed so that we can better reuse shared components and workflow segments derived from the building workflow.

Here we execute another captured segment of the building workflow -- this time, to tag words based on their sentiment. Non-tagged words get filtered out in the end.

Here, the sentiment score is calculated by (number of postive words - number of negative words) divided by (number of postive words + number of negative words). If the score is negative it is classified as negative, if the score is positive it is classified as positive, and if it is equal to 0 it is classified as neutral.

Step 3. Join original data with sentiment predictions.

  1. Using the Call Workflow Service node, set the workflow relative path to captured segment '../Workflow Segments/01.Captured Segment 3 Join Results'. Adjust node ports and click 'OK'.

  2. Connect the output of the Calculate Scores component to the first data table input port of the Call Workflow Service node.

  3. Connect the output of the CSV Reader node, right at the beginning of this workflow, to the second data table input port of the Call Workflow Service node.

  4. Execute the node to join the original data with the created predictions, when they exist. The quality of these predictions can then be evaluated by deploying this workflow as a web application or as a web service.



Step 2. Apply shared component to count the number of positive and negative words per document.

  1. Drag shared component Numbers of Positive and Negative Words per Document from folder 'Components' to here.

  2. Connect the output of the previous instance of the Call Workflow Service to the shared component. The idea is to feed the component with the tagged tweets.

  3. Execute the shared component and connect its output to shared component Calculate Scores, already present in the exercise.



Column Renamer
Calculate Scores
Read tweets extractedwith the Twitter API
CSV Reader
Call Workflow Service

Nodes

Extensions

Links