categorization property
result.match_info.rules.categorization
is an array containing the results of categorization.
Each array item has the following properties:
Property | Description |
---|---|
name |
Domain ID |
label |
Domain label |
score |
Domain score |
compound |
Domain's compound score, depending on child to father scoring mechanism |
frequency |
Domain score computed as a percentage of the sum of the scores of all the domains |
winner |
Boolean value that is true, if the domain is considered a winner, false otherwise |
rules |
Categorization rules that have been triggered |
rules
is an array. Its items have the following properties:
Property | Description |
---|---|
id |
Rule ID is a rule identification number created during the project building. It is a compiled rule index of an array where the rules are placed. It changes after every building. |
label |
Rule label, if any |
score |
Fraction of the domain's score that is due to this rule's activation |
scope |
Information about scope where the rule is activated |
scope
is an array. Its items have the following properties:
Property | Description |
---|---|
begin |
Scope initial position in the text |
end |
Scope final position in the text |
score |
Fraction of the domain's score that is due to the rule's activation in this scope |
operands |
Operands that triggered the rule in this scope |
operands
is an array. Its items have the following properties:
Property | Description |
---|---|
begin |
Initial text position matched by the operand |
end |
Final text position matched by the operand |
operand |
Operand ID is an operand identification number created during the project building. |
For example, consider the following text:
How Jack Daniel's Tennessee Whiskey is made
By Lutho Pasiya Time of article published Feb 24, 2020
If you are a whiskey lover, you will know that it is a spirit produced from fermented grain and aged in the wood.
And a spirit is an alcoholic beverage in which the alcohol content has been increased by distillation.
We had a chat with Jack Daniels Master Distiller, Chris Fletcher who shared with us the process of making one of the top-selling whiskey in the world which is Jack Daniel's.
and these categorization rules:
SCOPE SENTENCE
{
DOMAIN(08) // Labeled as FOOD in the taxonomy
{
ANCESTOR(102138622,100011707,103499072)//@SYN: #102138622# [food] //@SYN: #100011707# [restaurant] //@SYN: #103499072# [chef de cuisine]
}
}
SCOPE SENTENCE
{
DOMAIN(06) // Labeled as SPIRITS in the taxonomy
{
ANCESTOR(100000154)//@SYN: #100000154# [alcoholic beverage]
}
}
the categorization
property has the following JSON serialization:
`categorization": [
{
"name": "06",
"label": "SPIRITS",
"score": 90,
"compound": 90,
"rank": 0,
"frequency": 90.0,
"winner": true,
"rules": [
{
"id": 13,
"label": "",
"score": 90,
"scope": [
{
"begin": 0,
"end": 42,
"score": 20,
"operands": [
{
"operand": 13,
"begin": 4,
"end": 16
}
]
},
{
"begin": 0,
"end": 42,
"score": 20,
"operands": [
{
"operand": 13,
"begin": 28,
"end": 34
}
]
},
{
"begin": 99,
"end": 211,
"score": 10,
"operands": [
{
"operand": 13,
"begin": 112,
"end": 118
}
]
},
{
"begin": 213,
"end": 314,
"score": 10,
"operands": [
{
"operand": 13,
"begin": 219,
"end": 224
}
]
},
{
"begin": 213,
"end": 314,
"score": 10,
"operands": [
{
"operand": 13,
"begin": 232,
"end": 249
}
]
},
{
"begin": 213,
"end": 314,
"score": 10,
"operands": [
{
"operand": 13,
"begin": 264,
"end": 270
}
]
},
{
"begin": 316,
"end": 488,
"score": 10,
"operands": [
{
"operand": 13,
"begin": 445,
"end": 451
}
]
}
]
}
]
},
{
"name": "08",
"label": "FOOD",
"score": 10,
"compound": 10,
"frequency": 10.0,
"winner": true,
"rules": [
{
"id": 9,
"label": "",
"score": 10,
"scope": [
{
"begin": 99,
"end": 211,
"score": 10,
"operands": [
{
"operand": 9,
"begin": 185,
"end": 189
}
]
}
]
}
]
}
]
In that context, the following code:
function onFinalize(result) {
var count = result.match_info.rules.categorization.length;
var category;
for (i=0; i < count; i++)
{
category = result.match_info.rules.categorization[i];
if(category.label == "SPIRITS")
{
category.label = "NEW SPIRITS";
}
}
return result;
}
changes the label of category 06 from SPIRITS to NEW SPIRITS. The figures below show categorization results as they appear in Studio without and with the manipulation.
This other example code:
function onFinalize(result) {
var count = result.match_info.rules.categorization.length;
var category;
for (i=0; i < count; i++)
{
category = result.match_info.rules.categorization[i];
if(category.label == "FOOD")
{
category.score += 15;
}
}
return result;
}
adds some point to the score of the category labeled FOOD.
The figures below show categorization results as they appear in Studio without and with the manipulation.