Parsing model outputs with JSONata
OpenPages® uses the JSONata expression language to parse the JSON from the model outputs.
Different models can have different output structures. JSONata queries and transforms the output of the model so that the output can be used by OpenPages, regardless of the model structure.
OpenPages uses the open source Java™ version of JSONata, JSONata4Java that does not implement all of the JSONata functions. For more information, see the readme in the IBM JSONata4Java Github repository.
About this task
The procedure uses an example to demonstrate how to parse model outputs.
The model that is used in the example generates the following output:
{
"predictions": [
{
"results": {
"Controls": [
{
"text": "No recommendations available",
"score": 0,
"name": "Not Found"
}
],
"Class": [
{
"score": 0.8766618371009827,
"label": "Technical"
}
],
"Priority": [
{
"score": 0.9162724614143372,
"label": "P1"
}
],
"LDA": [
{
"score": 0.4810614287853241,
"label": "Authorization"
},
{
"score": 0.31226786971092224,
"label": "Configuration"
},
{
"score": 0.13503773510456085,
"label": "System"
},
{
"score": 0.017938677221536636,
"label": "Policy"
},
{
"score": 0.017931180074810982,
"label": "Information"
},
{
"score": 0.017895007506012917,
"label": "Control"
},
{
"score": 0.01786813512444496,
"label": "Security"
}
],
"Quali": [
{
"semantic_roles": [
{
"sentence": "Product Management will verify test cases via Post Launch Monitoring.",
"subject": {
"text": [
"Product Management"
]
},
"action": {
"text": [
"will verify"
]
},
"object": {
"text": [
"Post Launch Monitoring",
"test cases"
]
},
"when": {
"text": false
}
},
{
"sentence": "Product PQ testing and analysis is also determined and performed on a quarterly basis.",
"subject": {
"text": [
"Product PQ testing and analysis"
]
},
"action": {
"text": false
},
"object": {
"text": [
"a quarterly basis"
]
},
"when": {
"text": [
"quarterly"
]
}
}
],
"rating": "No Review Needed",
"feedback": null,
"rules": {
"Abbreviation": true,
"Title and Description Relevance": false,
"Jargon": false,
"Spelling Errors - Minor": false,
"Spelling Errors - Moderate": false,
"URLs": false,
"Word Count - Low # of Words": false,
"Word Count - Too many Words": false,
"Word Count - Medium # of Words": false,
"Insufficient information explaining who, what, why, how": false,
"Conditional Words": false
},
"errors": [],
"cond": []
}
],
"semantic_roles": [
{
"sentence": "Product Management will verify test cases via Post Launch Monitoring.",
"subject": {
"text": [
"Product Management"
]
},
"action": {
"text": [
"will verify"
]
},
"object": {
"text": [
"Post Launch Monitoring",
"test cases"
]
},
"when": {
"text": false
}
},
{
"sentence": "Product PQ testing and analysis is also determined and performed on a quarterly basis.",
"subject": {
"text": [
"Product PQ testing and analysis"
]
},
"action": {
"text": false
},
"object": {
"text": [
"a quarterly basis"
]
},
"when": {
"text": [
"quarterly"
]
}
}
],
"questions": [
{
"sentence": "Product Management will verify test cases via Post Launch Monitoring. Product PQ testing and analysis is also determined and performed on a quarterly basis.",
"full_question": "Who performs the control?",
"question": "Who",
"text": "product management"
},
{
"sentence": "Product Management will verify test cases via Post Launch Monitoring. Product PQ testing and analysis is also determined and performed on a quarterly basis.",
"full_question": "What is performed?",
"question": "What",
"text": "product pq testing and analysis"
},
{
"sentence": "Product Management will verify test cases via Post Launch Monitoring. Product PQ testing and analysis is also determined and performed on a quarterly basis.",
"full_question": "When or how frequently is the control performed?",
"question": "When",
"text": "quarterly"
},
{
"sentence": "Product Management will verify test cases via Post Launch Monitoring. Product PQ testing and analysis is also determined and performed on a quarterly basis.",
"full_question": "Where is the control performed?",
"question": "Where",
"text": "product pq testing and analysis is also determined and performed on a quarterly"
},
{
"sentence": "Product Management will verify test cases via Post Launch Monitoring. Product PQ testing and analysis is also determined and performed on a quarterly basis.",
"full_question": "Why is this performed?",
"question": "Why",
"text": "product pq testing and analysis is also determined and performed on a quarterly basis ."
}
],
"cutoff": 0.06,
"scores": [
{
"score": 0.47622546553611755
},
{
"score": 0.4898279309272766
},
{
"score": 0.3327782452106476
},
{
"score": 0.25064486265182495
},
{
"score": 0.3405856490135193
}
]
}
}
]
}
In the example, the following information is displayed in the output:
- The model components are Who, What, When, Where, and Why.
- The model insights for each component are displayed as the text associated with each component.
- The confidence scores for each component are displayed.
Procedure
What to do next
You define the outputs in the order in which you want them displayed in OpenPages. When you configure the outputs, you specify the JSONata string that extracts the specific components from the model. You also specify a JSONata string for the Confidence score.
For more information about defining model outputs, see Configuring model outputs.
After the model is added to the Description field in the Task View for Controls, the example configuration that is shown in the preceding figure generates the following result in OpenPages.