v1

latestOpenAPI 3.0.02026-08-061473373.5 KB
Analyze

Analyze text (GET)

Analyzes raw text, HTML, or a public webpage.

If a language for the input text is not specified with the language parameter, the service automatically detects the language.

get/v1/analyze

Query parameters

textstring

URL-encoded text to analyze. One of the text, html, or url parameters is required.

htmlstring

URL-encoded HTML to analyze. One of the text, html, or url parameters is required.

urlstring

Public webpage to analyze. One of the text, html, or url parameters is required. url is not supported in IBM Cloud Dedicated instances.

featuresstring[] required

Comma separated list of analysis features

return_analyzed_textboolean

Set this to true to show the analyzed text in the response

cleanboolean

Set this to false to disable text cleaning when analyzing webpages. For more information about webpage cleaning, see Analyzing webpages.

xpathstring

An XPath query to perform on html or url input. Results of the query will be appended to the cleaned webpage text before it is analyzed. To analyze only the results of the XPath query, set the clean parameter to false.

fallback_to_rawboolean

Whether to use raw HTML content if text cleaning fails

languagestring

ISO 639-1 code that specifies the language of your text. This overrides automatic language detection. Language support differs depending on the features you include in your analysis. For more information, see Language support.

categories.explanationboolean

Set this to true to return explanations for each categorization. This feature is available only for English language text.

categories.limitinteger

Maximum number of categories to return.

categories.modelstring

(Beta) Enter a custom model ID to override the standard categories model. This feature is available only for English language text.

classifications.modelstring

Model ID of the classifications model to be used

concepts.limitinteger

Maximum number of concepts to return.

emotion.documentboolean

Set this to false to hide document-level emotion results

emotion.targetsstring[]

Target strings, separated by commas. Emotion results will be returned for each target string found in the document

entities.limitinteger

Maximum number of entities to return.

entities.mentionsboolean

Set this to true to return locations of entity mentions

entities.modelstring

Enter a custom model ID to override the standard entity detection model

entities.emotionboolean

Set this to true to return emotion information for detected entities

entities.sentimentboolean

Set this to true to return sentiment information for detected entities

keywords.limitinteger

Maximum number of keywords to return.

keywords.emotionboolean

Set this to true to return emotion information for detected keywords

keywords.sentimentboolean

Set this to true to return sentiment information for detected keywords

relations.modelstring

Enter a custom model ID to override the default en-news relations model

semantic_roles.limitinteger

Maximum number of semantic_roles results to return

semantic_roles.entitiesboolean

Set this to true to return entity information for subjects and objects

semantic_roles.keywordsboolean

Set this to true to return keyword information for subjects and objects

sentiment.documentboolean

Set this to false to disable document level sentiment analysis

sentiment.targetsstring[]

Sentiment information will return for each target string that is found in the text

syntax.tokensboolean

Set this to true to return information about the tokens in the input text.

syntax.tokens.lemmaboolean

Set this to true to return the lemma for each token.

syntax.tokens.part_of_speechboolean

Set this to true to return the part of speech for each token.

syntax.sentencesboolean

Set this to true to return information about the sentences in the input text.

limit_text_charactersinteger

Sets the maximum number of characters that are processed by the service.

Response

Analysis results

languagestring

Language used to analyze the text

analyzed_textstring

Text that was used in the analysis

retrieved_urlstring

URL of the webpage that was analyzed

advanced_rulesobject

The advanced rules feature is deprecated. Existing models are supported until 24 June 2021, but after 10 June 2021, you will not be able to deploy advanced rules models to Natural Language Understanding. After 24 June 2021, advanced rules models will not run in Natural Language Understanding.

Response from advanced rules analysis

Example response

{
  "advanced_rules": {
    "Country": [
      {
        "Country": {
          "text": "USA",
          "location": {
            "end": 23,
            "begin": 20
          }
        },
        "Continent": null
      }
    ]
  },
  "concepts": [
    {
      "text": "Social network service",
      "relevance": 0.92186,
      "dbpedia_resource": "http://dbpedia.org/resource/Social_network_service"
    },
    {
      "text": "Thomas J. Watson",
      "relevance": 0.871908,
      "dbpedia_resource": "http://dbpedia.org/resource/Thomas_J._Watson"
    },
    {
      "text": "Lotus Software",
      "relevance": 0.839578,
      "dbpedia_resource": "http://dbpedia.org/resource/Lotus_Software"
    }
  ],
  "entities": [
    {
      "text": "Social network service",
      "relevance": 0.92186,
      "dbpedia_resource": "http://dbpedia.org/resource/Social_network_service"
    },
    {
      "text": "Thomas J. Watson",
      "relevance": 0.871908,
      "dbpedia_resource": "http://dbpedia.org/resource/Thomas_J._Watson"
    },
    {
      "text": "Lotus Software",
      "relevance": 0.839578,
      "dbpedia_resource": "http://dbpedia.org/resource/Lotus_Software"
    }
  ],
  "keywords": [
    {
      "text": "curated online courses",
      "sentiment": {
        "score": 0.792454
      },
      "relevance": 0.864624,
      "emotion": {
        "sadness": 0.188625,
        "joy": 0.522781,
        "fear": 0.12012,
        "disgust": 0.103212,
        "anger": 0.106669
      },
      "count": 1
    },
    {
      "text": "free virtual server",
      "sentiment": {
        "score": 0.664726
      },
      "relevance": 0.864593,
      "emotion": {
        "sadness": 0.265225,
        "joy": 0.532354,
        "fear": 0.07773,
        "disgust": 0.090112,
        "anger": 0.102242
      },
      "count": 1
    }
  ],
  "categories": [
    {
      "score": 0.594296,
      "label": "/technology and computing/computing/computer software and applications"
    },
    {
      "score": 0.448495,
      "label": "/science"
    },
    {
      "score": 0.426429,
      "label": "/business and finance/industries"
    }
  ],
  "classifications": [
    {
      "class_name": "temperature",
      "confidence": 0.562519
    },
    {
      "class_name": "conditions",
      "confidence": 0.433996
    }
  ],
  "emotion": {
    "targets": [
      {
        "text": "apples",
        "emotion": {
          "sadness": 0.028574,
          "joy": 0.859042,
          "fear": 0.02752,
          "disgust": 0.017519,
          "anger": 0.012855
        }
      },
      {
        "text": "oranges",
        "emotion": {
          "sadness": 0.514253,
          "joy": 0.078317,
          "fear": 0.074223,
          "disgust": 0.058103,
          "anger": 0.126859
        }
      }
    ],
    "document": {
      "emotion": {
        "sadness": 0.32665,
        "joy": 0.563273,
        "fear": 0.033387,
        "disgust": 0.022637,
        "anger": 0.041796
      }
    }
  },
  "metadata": {
    "title": "IBM - United States",
    "publication_date": "2015-10-01T00:00:00",
    "image": "",
    "feeds": [],
    "authors": []
  },
  "relations": [
    {
      "type": "awardedTo",
      "sentence": "Leonardo DiCaprio won Best Actor in a Leading Role for his performance.",
      "score": 0.680715,
      "arguments": [
        {
          "text": "Best Actor",
          "location": [
            22,
            32
          ],
          "entities": [
            {
              "type": "EntertainmentAward",
              "text": "Best Actor"
            }
          ]
        },
        {
          "text": "Leonardo DiCaprio",
          "location": [
            0,
            17
          ],
          "entities": [
            {
              "type": "Person",
              "text": "Leonardo DiCaprio"
            }
          ]
        }
      ]
    }
  ],
  "semantic_roles": [
    {
      "subject": {
        "text": "IBM"
      },
      "sentence": "IBM has one of the largest workforces in the world",
      "object": {
        "text": "one of the largest workforces in the world"
      },
      "action": {
        "verb": {
          "text": "have",
          "tense": "present"
        },
        "text": "has",
        "normalized": "have"
      }
    }
  ],
  "sentiment": {
    "targets": [
      {
        "text": "stocks",
        "score": 0.279964,
        "label": "positive"
      }
    ],
    "document": {
      "score": 0.127034,
      "label": "positive"
    }
  },
  "summarization": {
    "text": "Today, IBM and Workday, a leading provider of enterprise applications for human resources and finance, announced a joint solution designed to help companies begin the process of safely re-opening their workplaces. Here are five key takeaways from the announcement. The two companies, which have had a partnership since 2011, announced a new solution to help businesses and communities determine when and how to safely open up their workplaces during the ongoing COVID-19 pandemic."
  }
}
All 14 operations