Administer > Smart Analytics Administration > Smart Analytics APIs > Auto-classification Javascript API

Auto-classification Javascript API

This Javascript API returns an array of arrays that contains the suggested categories.

Syntax
lib.acicategory.getCategoryByContent(file,adapterid,numresult,company)
Arguments
Name Data type Required Description
file Datum object Yes This argument contains the object that holds the input source data. For example, an "incidents" file with title and description.
adapterid Integer Yes This argument contains the id you use to call createAndTrainingOneCategory, or adapter.id in idoladapter.
numresult Integer Yes This argument controls the number of suggested categories to return.
company String No

The company that the categories belong to.

Note If you use an adapterid with the multi-company setting configured, you must specify this parameter in your request.


Return values
An array of arrays that contains the suggested categories. For example:
[["incident","hardware","hardware failure"],["incident","performance","performance degradation"],["incident","failure","job failed"]]
Example
This example assumes that you configure a category group for interactions is configured as the following:
 
id: 201
Source fields: title and description
Category fields: category, subcategory, product_type
 
Then, the Javascript API can be used as in the following example:
var f = new SCFile("incidents");
f.title = "my pc is broken";
f.description=["Starting from yesterday, my pc cannot be started. Both battery and power adapter looks good. The pc itself was very hot before it is broken."]
f.category="incident"; 
print(lib.JSON.json().stringify(lib.acicategory.getCategoryByContent(f,201,3,"es")))
If the input parameter (file) includes value of level 1 and level 2 fields that are configured in the idoladapter, this function will use their values as the parent schema to suggest child category to get better accuracy. In this example, the level 1 field is specified as f.category="incident", which means the returned suggestion will all belong to the "incident" category.