Text Statistics

Returns statistical information about the specified text.

The Text Statistics API analyzes text that you provide, and returns information about the content, such as the number of sentences and terms.

Quick Start

The API requires some text as input, which you can provide in one of the input parameters. The text parameter accepts a block of text:

/1/api/[async|sync]/gettextstatistics/v1?text=Shall I compare thee to a summer's day

You can also provide a file, a Haven OnDemand object store reference, or a URL.

For any input format, the API extracts the text and returns statistical information about the contents, such as the number of terms, and the percentage of different types of character (alphabetic, numeric, punctuation, and so on).

Synchronous
https://api.havenondemand.com/1/api/sync/gettextstatistics/v1
Asynchronous
https://api.havenondemand.com/1/api/async/gettextstatistics/v1
Authentication

This API requires an authentication token to be supplied in the following parameter:

Parameter Description
apikey The API key to use to authenticate the API request.
Parameters

This API accepts the following parameters:

Required
Name Type Description
file
binary A file that contains the text to process. Multipart POST only.
reference
string A Haven OnDemand reference obtained from either the Expand Container or Store Object API. The corresponding document is passed to the API.
text
string The text content to process.
url
string A publicly accessible HTTP URL from which the document can be retrieved.

This API returns a JSON response that is described by the model below. This single model is presented both as an easy to read abstract definition and as the formal JSON schema.

Asynchronous Use

Additional requests are required to get the result if this API is invoked asynchronously.

You can use /1/job/status/<job-id> to get the status of the job, including results if the job is finished.

You can also use /1/job/result/<job-id>, which waits until the job has finished and then returns the result.

Model
This is an abstract definition of the response that describes each of the properties that might be returned.
Text Statistics Response {
sentences ( integer ) The number of sentences in the specified text.
paragraphs ( integer ) The number of paragraphs in the specified text.
terms ( Terms ) The term counts for the specified text.
stop_words ( Stop_words ) The stop word counts for the specified text.
characters ( Characters ) The character counts for the specified text.
}
Text Statistics Response:Terms {
total ( integer ) The total number of terms in the specified text.
distinct ( integer ) The number of distinct terms in the specified text.
}
Text Statistics Response:Stop_words {
total ( integer ) The total number of stop words in the specified text.
distinct ( integer ) The number of distinct stop words in the specified text
}
Text Statistics Response:Characters {
total ( integer ) The total number of characters in the specified text.
percent_alphabetic ( number ) The percentage of alphabetic characters in the specified text.
percent_uppercase ( number ) The percentage of uppercase characters in the specified text.
percent_numeric ( number ) The percentage of numeric characters in the specified text.
percent_whitespace ( number ) The percentage of whitespace characters in the specified text.
percent_punctuation ( number ) The percentage of punctuation characters in the specified text.
percent_control ( number ) The percentage of control characters in the specified text.
}
Model Schema
This is a JSON schema that describes the syntax of the response. See json-schema.org for a complete reference.
{
    "properties": {
        "sentences": {
            "type": "integer"
        },
        "paragraphs": {
            "type": "integer"
        },
        "terms": {
            "properties": {
                "total": {
                    "type": "integer"
                },
                "distinct": {
                    "type": "integer"
                }
            },
            "required": [
                "total",
                "distinct"
            ],
            "type": "object"
        },
        "stop_words": {
            "properties": {
                "total": {
                    "type": "integer"
                },
                "distinct": {
                    "type": "integer"
                }
            },
            "required": [
                "total",
                "distinct"
            ],
            "type": "object"
        },
        "characters": {
            "properties": {
                "total": {
                    "type": "integer"
                },
                "percent_alphabetic": {
                    "type": "number"
                },
                "percent_uppercase": {
                    "type": "number"
                },
                "percent_numeric": {
                    "type": "number"
                },
                "percent_whitespace": {
                    "type": "number"
                },
                "percent_punctuation": {
                    "type": "number"
                },
                "percent_control": {
                    "type": "number"
                }
            },
            "required": [
                "total",
                "percent_alphabetic",
                "percent_uppercase",
                "percent_numeric",
                "percent_whitespace",
                "percent_punctuation",
                "percent_control"
            ],
            "type": "object"
        }
    },
    "required": [
        "sentences",
        "paragraphs",
        "terms",
        "stop_words",
        "characters"
    ],
    "type": "object"
}
https://api.havenondemand.com/1/api/sync/gettextstatistics/v1
/api/api-example/1/api/sync/gettextstatistics/v1
Examples
See this API for yourself - select one of our examples below.
Text
There are approximately 1,600 giant pandas (simplified Chinese: 大熊猫) left living in the wild.
Word doc
Parameters
Required
Select file Change Remove


Async – Response An error occurred making the API request
Response Code:
Response Body

	
Making API Request…
Checking result of job

To try this API with your own data and use it in your own applications, you need an API Key. You can create an API Key from your account page - API Keys.

Output Refresh An error occurred making the API request View Input
Rendered RawHtml Response
Result Display
Response Code:
Response Body:

			
Make this call with curl


If you would like to provide us with more information then please use the box below:

We will use your submission to help improve our product.