Choose where you’d like to start

Keyword Extraction

Description

The zoho.ai.extractKeywords task extracts tags/ keywords from the given text.

Note: 
  • The prediction results may not be accurate, which is also the case with any AI prediction. However, we are working on improving this.
  • The prediction results are dynamic. The same script may produce different outcomes at different times based on how much the machine has learned.

Syntax

<response> = zoho.ai.extractKeywords(<content>, [<number_of_element>], [<model_type>], [<keyword_length>]);

where:

ParamsData typeDescription

<response>

KEY-VALUE

Specifies the keywords extracted from the given text.

<content>

TEXT

Specifies the text from which keywords need to be extracted.

Note: The maximum allowed character length is 5000.

<number_of_elements>

(optional)

NUMBER

Specifies the number of top keywords that need to be returned.

<model_type>

(optional)

TEXT

Specifies one of the supported model types. An appropriate model type can be provided to improve the reading accuracy.

Applicable Values:

​i) ONLY_VALID_KEYWORDS
ii) RANKED_KEYWORDS
iii) RANKED_KEYWORDS_WITH_CATEGORY (default)
iv) RANKED_KEYWORDS_WITH_INDEX
​v) RANKED_KEYWORDS_WITH_FREQ

<keyword_length>

(optional)

NUMBER

Specifies the maximum number of tokens in a single keyword. For example, the number of tokens in the keyword - Operating Systems is 2.

 

Example 1

The following script extracts keywords from the specified text.

query = "An operating system (OS) is system software that manages computer hardware, software resources, and provides common services for computer programs.Time-sharing operating systems schedule tasks for efficient use of the system and may also include accounting software for cost allocation of processor time, mass storage, printing, and other resources.For hardware functions such as input and output and memory allocation, the operating system acts as an intermediary between programs and the computer hardware,[1][2] although the application code is usually executed directly by the hardware and frequently makes system calls to an OS function or is interrupted by it. Operating systems are found on many devices that contain a computer – from cellular phones and video game consoles to web servers and supercomputers."; 

response = zoho.ai.extractKeywords(query);

where:

response
The KEY-VALUE response that represents the text extracted keywords from the text.
query
The TEXT  from which the keywords need to be extracted.

Example 2

The following script extracts the top 3 keywords with a length maximum of 2 words from the given text.

query = "An operating system (OS) is system software that manages computer hardware, software resources, and provides common services for computer programs.Time-sharing operating systems schedule tasks for efficient use of the system and may also include accounting software for cost allocation of processor time, mass storage, printing, and other resources.For hardware functions such as input and output and memory allocation, the operating system acts as an intermediary between programs and the computer hardware,[1][2] although the application code is usually executed directly by the hardware and frequently makes system calls to an OS function or is interrupted by it. Operating systems are found on many devices that contain a computer – from cellular phones and video game consoles to web servers and supercomputers.";

response = zoho.ai.extractKeywords(query,3,"RANKED_KEYWORDS_WITH_CATEGORY",2);

where:

3
The NUMBER of top keywords needs to be extracted.
RANKED_KEYWORDS_WITH_CATEGORY
The TEXT  that represents the model type.
2
The maximum NUMBER of words that the extracted keywords can contain.

Response Format

Success Response

  • The success response will be returned in the following format:

    {
    "data": {
    "items": [
    {
    "keywords": [
    {
    "score": 2,
    "keyword": "operating system"
    },
    {
    "score": 1,
    "keyword": "video game consoles"
    },
    {
    "score": 1,
    "keyword": "computer hardware"
    },
    {
    "score": 1,
    "keyword": "computer hardware,[1]"
    },
    {
    "score": 1,
    "keyword": "system calls"
    },
    {
    "score": 1,
    "keyword": "web servers"
    },
    {
    "score": 1,
    "keyword": "function"
    },
    {
    "score": 1,
    "keyword": "hardware"
    },
    {
    "score": 1,
    "keyword": "system software"
    },
    {
    "score": 1,
    "keyword": "memory allocation"
    }
    ],
    "categories": [
    {
    "categoryTag": "mobile & computer",
    "distribution": 0.28
    },
    {
    "categoryTag": "tech companies",
    "distribution": 0.11
    },
    {
    "categoryTag": "multimedia",
    "distribution": 0.1
    },
    {
    "categoryTag": "engineering & technology",
    "distribution": 0.09
    }
    ]
    }
    ]
    },
    "message": "OK",
    "status": 200
    }

Failure Response

  • The failure response returned for an empty input will be returned in the following format:

     {
     "message": "EMPTY_VALUE_NOT_ALLOWED",
     "status": 400
     }
  • The failure response returned for an input value with character length greater than the allowed limitwill be returned in the following format:

     {
     "message": "queryValue length is max than maximum length",
     "status": 400
     }
 

Related Links

Get Started Now

Execute