使用 JSONata 解析模型输出
OpenPages® 使用 JSONata 表达式语言来解析模型输出中的 JSON。
不同的模型可以有不同的输出结构。 JSONata 查询并变换模型的输出,以便无论模型结构如何,输出都可以由 OpenPages使用。
OpenPages 使用 JSONata 的开放式源代码 Java™ 版本 JSONata4Java ,该版本未实现所有 JSONata 函数。 有关更多信息,请参阅 IBM JSONata4Java Github 存储库中的自述文件。
关于本任务
此过程使用示例来演示如何解析模型输出。
示例中使用的模型将生成以下输出:
{
"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
}
]
}
}
]
}
在此示例中,以下信息显示在输出中:
- 模型组件包括 "人员" , "内容" , "时间" , "位置" 和 "原因"。
- 每个组件的模型洞察显示为与每个组件关联的文本。
- 将显示每个组件的置信度分数。
过程
下一步操作
您可以按希望输出在 OpenPages中显示的顺序来定义输出。 配置输出时,指定从模型中抽取特定组件的 JSONata 字符串。 您还可以为置信度分数指定 JSONata 字符串。

有关定义模型输出的更多信息,请参阅 配置模型输出。
将模型添加到 控件的 " 任务视图 " 中的 描述 字段后,上图中显示的示例配置将在 OpenPages中生成以下结果。



