Configuring a data transform for a JSON output mapping
Support a machine learning service connection to external topic models by converting the JSON response from the prediction endpoint to a format that Pega Platform accepts.
The output mapping is based on the structure of the Data-NLP-Outcome class.
- In the header of Dev Studio, click .
- In the Label field, enter a short description for your data transform.
- In the Additional configuration options section, select Clipboard.
- In the Context section, specify the context for your data
transform:
- In the Apply to field, enter Data-NLP-ExternalMapping.
- In the Add to ruleset field, select the name of a ruleset to contain the record, and then select the version number from the list.
- Click Create and open.
- On the Definition tab, map the properties in the
Data-NLP-Outcome class to the paths in the JSON
response.
Use the following actions, target properties, and source properties for the mapping:
Choices Actions Specify an array in the JSON response Use the Append and Map to action to map the .pxResults target property to a path in the JSON response as the source. Enter the path in a format that follows the JSON Pointer specification but without a slash (/) prefix. Note: If you leave the Source field empty, the mapping will point to the following JSON path: /
Specify a path in the JSON response Use the Set action to map the .pySource_jsonPath target property to a path in the JSON response as the source. Enter the path in a format that follows the JSON Pointer specification but without a slash (/) prefix. Examples:
classification/score displayName Specify a property in the Data-NLP-Outcome class Use the Set action to map the .pyDestination_property target property to a property in the Property in the Data-NLP-Outcome class as the source. Examples:
.pyTopics .pyName .pyConfidenceScore Enter the path in a format that follows the JSON Pointer specification but without a slash (/) prefix. For more information, see JSON Pointer specification and Configuring a data transform.For example: The following code represents a sample JSON response from a prediction endpoint:
{ "payload": [ { "annotationSpecId": "2348805326557413376", "classification": { "score": 0.9609469 }, "displayName": "greeting" }, { "annotationSpecId": "42962317343719424", "classification": { "score": 0.026214128 }, "displayName": "thanks" } ] }
To convert the properties from the JSON response to a format that Pega Platform accepts, a data transform is used, as in the following figure:
Data transform for a sample JSON response The sample JSON response contains the classification/score and displayName properties in a JSON array property payload.
The data transform maps the classification/score and displayName properties to the Pega Platform .pyConfidenceScore and .pyName properties, and the JSON array payload property to .pyTopics.
The property .pxResults indicates each node in the JSON array that includes child properties that need to be processed.
- Click Save.
Previous topic Configuring a machine learning service connection for topic models using REST API Next topic Creating a text categorization model to run topic models through an API