Sentiment Analysis
#
DescriptionCreate an API to allows extracting the sentiment of a given string. The API provides a trainable model which enables different weights for specific keywords
#
UIAccess the DataTrucker URL via a browser
#
Make an API- Go to Utils API in the Sidebar > Sentiment API’s
- Fill the form to create the API
- Resource Name: an arbitrary name to identify the resource
- Method: The type of REST Call
- Validation Regex of Input values is the input sanitization before executing the command. Arguments will be sent to API as an Array and will be space-separated. Every input argument needs to pass the regex as defined during the creation of the API. Documentation for Validation
- Options: used to train models for sentiment analysis
#
Query the resource you createdURL: /api/v1/jobs/<resource name>TYPE: <method defined>HEADER: Authorization: "Bearer <JWT Token>"BODY (JSON): { "statement": "paintings are good."}
Response: 200 OK
#
As a CRD in Openshift / KubernetesFor credentials use the the API below to the management end point
---apiVersion: datatrucker.datatrucker.io/v1kind: DatatruckerFlowmetadata: name: datatruckerflow-samplespec: Resources: requests: memory: "256Mi" cpu: "250m" limits: memory: "256Mi" cpu: "500m" JobDefinitions: - resourcename: sentiment2 name: sentiment2 type: Util-Sentiment tenant: Admin restmethod: POST options: extras: cats: 5 amazing: 2 tasteless: -10 Wanted: 10 validations: type: object properties: statement: type: string pattern: "^[ A-za-z0-9.]*$" maxLength: 20 Keys: configmap: placeholder Scripts: configmap: placeholder Type: Job DatatruckerConfig: datatruckerconfig-sample Replicas: 1 API: name: api Image: repository: docker.io imageName: datatruckerio/datatrucker-api tagName: latest
#
API#
Create the API via RESTURL: /api/v1/resourcesTYPE: POSTHEADER: Authorization: "Bearer <JWT Token>"BODY (JSON): { "resourcename": "sentiment2", "type": "Util-Sentiment", "restmethod": "POST", "options": { "extras": { "cats": 5, "amazing": 2, "tasteless": -10, "Wanted": 10 } }, "validations": { "type": "object", "properties": { "statement": { "type": "string", "pattern": "^[ A-za-z0-9.]*$", "maxLength":20 } } }}
Response: 201 OK