Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

This REST Handler contains:

  • Endpoints that return Saga configuration and build information
  • Endpoints to process text and return the interpretation graph

Table of Contents
maxLevel2

Saga_rest_endpoint
EndpointprocessText
  • Will return a Saga interpretation graph in the format specified
  • By default, it returns the graph in HTML format which is used by the UI
  • It also can return JSON or plain text

Parameters

  • Parameter
    summaryThis is the text to process
    nameq
    requiredtrue
  • Parameter
    summaryList of tags to use to process the text
    nametags
    typestring array
    requiredtrue
  • Parameter
    summaryTag to use to process the text
    nametag
  • Parameter
    summaryPipeline or pipeline stage to use to process the text
    nameprocessor
  • Parameter
    summarySpecifies the regex to use to split text into TEXT_BLOCKs
    default[\r |\n ]+
    namesplitRegex
  • Parameter
    summarySpecifies the format of the results. It could be one of these values: "ux", "text" or "json"
    defaultux
    nametype
    • ux - Returns an output useful for Saga to show the graph on a web display.
    • text - Returns a "line" with the highest confidence route and a text representation of the graph.
    • json - Returns all the semantic tags on the graph.
    If true, it will combine all the SEMANTIC_TAGs, which has same matching text and same confidence value
    defaultfalse
    namecombine
    typeboolean

    • The combination includes the metadata, of every SEMANTIC_TAG
  • Parameter
    summaryIf true, it will also add the components from the highest route confidence tokens. ()
    Parameter
    summaryUsed to pretty format the JSON result
    defaultfalse
    nameprettyaddComponents
    typeboolean
Request Examples
  • Parameter
Code Block
languagepowershell
themeFadeToGrey
curl -X ${method} \
  http://localhost:${port}/${url} \
  -H 'Content-Type: application/json' \
  -d '
{
    "q": "I like traveling with Air Paris",
	"tags": ["airline"],
	"splitRegex": "[\r|\n]+",
	"type": "text",
	"pretty": true
}'

Response

  • summaryApplicable when addComponents is true. Indicates which components to add to the response
    namecompFields
    typestring array

    • If missing all the components will be added
  • Parameter
    summaryIf true, it will add the metadata of the entities found in every SEMANTIC_TAG
    defaultfalse
    namemetadata
    typeboolean
  • Parameter
    summarySpecifies the format of the results. It could be one of these values: "ux", "text" or "json"
    defaultux
    nametype
    • ux - Returns an output useful for Saga to show the graph on a web display.
    • text - Returns a "line" with the highest confidence route and a text representation of the graph.
    • json - Returns all the semantic tags on the graph.
  • Parameter
    summaryUsed to pretty format the JSON result
    defaultfalse
    namepretty
    typeboolean
Note

The parameters tags, tag and processor are mutually exclusive, only one is required, and the priority order is:

  1. tags
  2. tag
  3. processor


Request Examples

Code Block
languagepowershell
themeFadeToGrey
curl -X ${method} \
  http://localhost:${port}/${url} \
  -H 'Content-Type: application/json' \
  -d '
{
    "q": "I like traveling with Air Paris",
	"tags": ["airline"],
    "combine": true,
    "addComponents": true,
    "compFields": "paris",
	"splitRegex": "[\r|\n]+",
	"type": "text",
	"pretty": true
}'

Response

Saga_json
{
  "_success": true,
  "data": {
    "line": [
      {
Saga_json
{
    "_success": true,
    "data": {
        "line": [
            {
                "character": "0:1",
                "components": [
                    "I like traveling with Air Paris"
                ],
                "stage": "WhitespaceTokenizer",
                "confidence": 0.5,
                "flags": [
                    "TOKEN",
                    "ALL_UPPER_CASE",
                    "ORIGINAL"
                ],
                "_item": "I",
                "matching": "I"
            },
            {
                "character": "2:6",
                "components": [
                    "I like traveling with Air Paris"
                ],
                "stage": "WhitespaceTokenizer",
                "confidence": 0.5,
                "flags": [
                    "TOKEN",
                    "ALL_LOWER_CASE",
                    "ORIGINAL"
                ],
                "_itemstage": "likeWhitespaceTokenizer",
        "confidence": 0.5,
        "matchingmatch": "likeI",
            },"flags": [
            {"ORIGINAL",
                "character": "7:16"ALL_UPPER_CASE",
                "componentsTOKEN": [
        ],
        "text": "I",
   "I like traveling with Air Paris""startPos": 0,
        "endPos": 1
       ]},
      {
          "stage": "WhitespaceTokenizer",
        ,
        "confidence": 0.5,
        "match": "like",
        "flags": [
          "ORIGINAL",
          "TOKEN",
                    "ALL_LOWER_CASE",
        ],
            "ORIGINAL""text": "like",
                ],
  "startPos": 2,
        "endPos": 6
     "_item": "traveling" },
       {
         "matchingstage": "travelingWhitespaceTokenizer",
            }"confidence": 0.5,
        "match": "traveling",
   {
     "flags": [
          "character": "17:21"ORIGINAL",
          "TOKEN",
      "components": [    "ALL_LOWER_CASE"
        ],
        "text": "traveling",
   "I like traveling with Air Paris""startPos": 7,
        "endPos": 16
       ]},
        {
        "stage": "WhitespaceTokenizer",
                "confidence": 0.4,
        "match": "with",
        "flags": [
          "ORIGINAL",
          "TOKENSTOP_WORD",
          "TOKEN",
          "ALL_LOWER_CASE",
        ],
            "SKIP"text": "with",
                    "ORIGINALstartPos": 17,
        "endPos": 21
       ]},
       {
         "_itemcomponents": "with",
[
          {
            "matchingstage": "withCaseAnalysis",
            }"confidence": 0.45,
            {
     "match": "Paris",
            "characterflags": "22:31",[
                "stage": "DictionaryTagger"ORIGINAL",
                "display": "Air ParisLOWERED",
                "patternsTOKEN": [,
                 "ALL_LOWER_CASE"
   "Air Orly",
        ],
            "text"Air: Paris"paris",
                ]"startPos": 26,
                "confidenceendPos": 0.6975,31
          }
       "flags": [ ],
            "stage": "DictionaryTagger",
        "SEMANTIC_TAG"confidence": 0.6975,
        "display": "Air Paris",
        "match": "Air Paris"ENTITY",
        "flags": [
       ],
   "SEMANTIC_TAG",
             "id": "34365531","ENTITY"
        ],
        "_itemtext": "{airline}",
                "matchingid": "Air Paris34365531",
        "startPos": 22,
        "tagsendPos": [31,
          "tags": [
          "airline"
                ]
            }
        ],
        "graph": " V-----------[I like traveling with Air Paris]-----------V \n ^-[I]-V-[like]-V-[traveling]-V-[with]-V-[Air]-V-[Paris]-^ \n ^-[i]-^                               ^-[air]-^-[paris]-^ \n                                       ^---[{airline}]---^ \n"
    }
}
Saga_rest_endpoint
Endpointsolution
MethodGET
  • Returns the information of the solution currently being used.
  • A solution is basically the set of Elasticsearch indices in use

Request Examples

Code Block
languagepowershell
themeFadeToGrey
curl -X ${method} \
  http://localhost:${port}/${url} \
  -H 'Content-Type: application/json' \
  -d '
{
}'

Response

Saga_json
	"_success": true,
    "elasticSearch": {
    	"indexName": "air"
    },
    "display": "Saga - EN"
Saga_rest_endpoint
Endpointinfo
MethodGET
  • Returns build-specific and configuration information about Saga
  • Build information contains title, vendor, version, build revision and date
  • Configuration information contains the solution (Elastic index) and providers configured at the moment

Request Examples

Code Block
curl -X ${method} \
  http://localhost:${port}/${url} \
  -H 'Content-Type: application/json' \
  -d '
{
}'


Response

Saga_json
    "msg": "Saga API online",
    "_success": true,
    "buildInfo": {
        "Implementation-Title": "Saga Server",
        "Implementation-Build": "9dde0a32f17264f7b9004fc8d141e5b1cd0838b0",
        "Implementation-Version": "1.0.0-SNAPSHOT",
        "Implementation-Timestamp": "1550261725668",
        "Implementation-Vendor-Id": "com.accenture.saga",
        "Built-By": "ronny.ortega.ugalde",
        "Build-Jdk": "11.0.2",
        "Implementation-Branch": "develop"
    },
    "solutions": [
        {
            "elasticSearch": {
                "indexName": "air"
            },
            "display": "Saga - EN"
        }
    ],
    "providers": [
        {
            "baseDir": "./config",
            "name": "filesystem-provider",
            "type": "FileSystem"
        },
        {
            "hostname": "localhost",
            "scheme": "http",
            "port": 9200,
            "name": "saga-provider",
            "exclude": [
                "updatedAt",
                "createdAt"
            ],
            "type": "Elastic",
            "timestamp": "updatedAt"
        }
    ]