You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Use this quickstart to send sentiment analysis requests using the REST API. In the following example, you will use cURL to identify the sentiment(s) expressed in a text sample, and perform aspect-based sentiment analysis.
15
+
Use this quickstart to send sentiment analysis requests using the REST API. In the following example, you'll use cURL to identify the sentiment(s) expressed in a text sample, and perform aspect-based sentiment analysis.
16
16
17
17
## Prerequisites
18
18
19
-
* The current version of [cURL](https://curl.haxx.se/).
20
-
* Once you have your Azure subscription, <ahref="https://portal.azure.com/#create/Microsoft.CognitiveServicesTextAnalytics"title="Create a Language resource"target="_blank">create a Language resource </a> in the Azure portal to get your key and endpoint.
19
+
* Azure subscription - [Create one for free](https://azure.microsoft.com/free/cognitive-services)
20
+
21
+
> [!div class="nextstepaction"]
22
+
> <ahref="https://microsoft.qualtrics.com/jfe/form/SV_0Cl5zkG3CnDjq6O?PLanguage=REST API&Pillar=Language&Product=Sentiment-analysis&Page=quickstart&Section=Prerequisites"target="_target">I ran into an issue</a>
23
+
24
+
## Setting up
25
+
26
+
[!INCLUDE [Create an Azure resource](../../../includes/create-resource.md)]
## Create a JSON file with the example request body
31
+
32
+
In a code editor, create a new file named `request_body.json` and copy the following JSON example. This example request will be sent to the API in the next step.
33
+
34
+
```json
35
+
{
36
+
"kind": "SentimentAnalysis",
37
+
"parameters": {
38
+
"modelVersion": "latest",
39
+
"opinionMining": "True"
40
+
},
41
+
"analysisInput":{
42
+
"documents":[
43
+
{
44
+
"id":"1",
45
+
"language":"en",
46
+
"text": "The food and service were unacceptable. The concierge was nice, however."
47
+
}
48
+
]
49
+
}
50
+
}
51
+
```
52
+
53
+
Save `request_body.json` somewhere on your computer. For example, your desktop.
54
+
55
+
## Send a sentiment analysis and opinion mining API request
21
56
22
57
> [!NOTE]
23
-
> *The following BASH examples use the `\` line continuation character. If your console or terminal uses a different line continuation character, use that character.
58
+
> The below examples include a request for the opinion mining feature of sentiment analysis, which provides granular information about assessments (adjectives) related to targets (nouns) in the text.
24
59
60
+
Use the following commands to send the API request using the program you're using. Copy the command into your terminal, and run it.
25
61
26
62
|parameter |Description |
27
63
|---------|---------|
28
64
|`-X POST <endpoint>`| Specifies your endpoint for accessing the API. |
29
65
|`-H Content-Type: application/json`| The content type for sending JSON data. |
30
66
|`-H "Ocp-Apim-Subscription-Key:<key>`| Specifies the key for accessing the API. |
31
-
|`-d <documents>`| The JSON containing the documents you want to send. |
67
+
|`-d <documents>`| The JSON file containing the documents you want to send. |
32
68
33
-
The following cURL commands are executed from a BASH shell. Edit these commands with your own resource name, resource key, and JSON values.
69
+
# [Windows](#tab/windows)
34
70
35
-
> [!div class="nextstepaction"]
36
-
> <ahref="https://microsoft.qualtrics.com/jfe/form/SV_0Cl5zkG3CnDjq6O?PLanguage=REST API&Pillar=Language&Product=Sentiment-analysis&Page=quickstart&Section=Prerequisites"target="_target">I ran into an issue</a>
71
+
Replace `C:\Users\<myaccount>\Desktop\test_sentiment_payload.json` with the location of the example JSON request file you created in the previous step.
37
72
38
-
##Setting up
73
+
### Command prompt
39
74
40
-
[!INCLUDE [Create an Azure resource](../../../includes/create-resource.md)]
75
+
```terminal
76
+
curl -X POST "%LANGUAGE_ENDPOINT%/language/:analyze-text?api-version=2022-05-01" ^
> The below examples include a request for the Opinion Mining feature of Sentiment Analysis using the `opinionMining=true` parameter, which provides granular information about assessments (adjectives) related to targets (nouns) in the text.
91
+
#### [Linux](#tab/linux)
48
92
49
-
```bash
50
-
curl -i -X POST <your-language-resource-endpoint>/language/:analyze-text?api-version=2022-05-01 \
93
+
Use the following commands to send the API request using the program you're using. Replace `/home/mydir/test_sentiment_payload.json` with the location of the example JSON request file you created in the previous step.
94
+
95
+
```terminal
96
+
curl -X POST $LANGUAGE_ENDPOINT/language/:analyze-text?api-version=2022-05-01 \
"text": "The food and service were unacceptable. The concierge was nice, however."
67
-
}
68
-
]
69
-
}
70
-
}
71
-
'
98
+
-H "Ocp-Apim-Subscription-Key: $LANGUAGE_KEY" \
99
+
-d "@/home/mydir/test_sentiment_payload.json"
100
+
```
101
+
102
+
#### [macOS](#tab/macos)
103
+
104
+
Use the following commands to send the API request using the program you're using. Replace `/home/mydir/test_sentiment_payload.json` with the location of the example JSON request file you created in the previous step.
105
+
106
+
```terminal
107
+
curl -X POST $LANGUAGE_ENDPOINT/language/:analyze-text?api-version=2022-05-01 \
Copy file name to clipboardExpand all lines: articles/healthcare-apis/iot/how-to-use-calculated-functions-mappings.md
+18-21Lines changed: 18 additions & 21 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,20 +5,17 @@ author: msjasteppe
5
5
ms.service: healthcare-apis
6
6
ms.subservice: fhir
7
7
ms.topic: how-to
8
-
ms.date: 02/16/2022
8
+
ms.date: 10/25/2022
9
9
ms.author: jasteppe
10
10
---
11
11
12
12
# How to use CalculatedContentTemplate mappings
13
13
14
-
> [!TIP]
15
-
> Check out the [IoMT Connector Data Mapper](https://github.com/microsoft/iomt-fhir/tree/master/tools/data-mapper) tool for editing, testing, and troubleshooting MedTech service Device and FHIR destination mappings. Export mappings for uploading to MedTech service in the Azure portal or use with the [open-source version](https://github.com/microsoft/iomt-fhir) of MedTech service.
16
-
17
-
This article describes how to use CalculatedContentTemplate mappings with MedTech service Device mappings templates.
14
+
This article describes how to use CalculatedContentTemplate mappings with MedTech service device mapping template.
18
15
19
16
## CalculatedContentTemplate
20
17
21
-
MedTech service provides an expression-based content template to both match the wanted template and extract values. **Expressions** may be used by either JSONPath or JmesPath. Each expression within the template may choose its own expression language.
18
+
MedTech service provides an expression-based content template to both match the wanted template and extract values. **Expressions** may be used by either JSONPath or JMESPath. Each expression within the template may choose its own expression language.
22
19
23
20
> [!NOTE]
24
21
> If an expression language isn't defined, the default expression language configured for the template will be used. The default is JSONPath but can be overwritten if needed.
@@ -45,8 +42,9 @@ In the example below, *typeMatchExpression* is defined as:
45
42
...
46
43
}
47
44
```
45
+
48
46
> [!TIP]
49
-
> The default expression language to use for a Device mapping template is JsonPath. If you want to use JsonPath, the expression alone may be supplied.
47
+
> The default expression language to use for a MedTech service device mapping template is JsonPath. If you want to use JsonPath, the expression alone may be supplied.
50
48
51
49
```json
52
50
"templateType": "CalculatedContent",
@@ -57,7 +55,7 @@ In the example below, *typeMatchExpression* is defined as:
57
55
}
58
56
```
59
57
60
-
The default expression language to use for a template can be explicitly set using the `defaultExpressionLanguage` parameter:
58
+
The default expression language to use for a MedTech service device template can be explicitly set using the `defaultExpressionLanguage` parameter:
61
59
62
60
```json
63
61
"templateType": "CalculatedContent",
@@ -69,7 +67,7 @@ The default expression language to use for a template can be explicitly set usin
69
67
}
70
68
```
71
69
72
-
The CalculatedContentTemplate allows matching on and extracting values from an Azure Event Hub message using **Expressions** as defined below:
70
+
The CalculatedContentTemplate allows matching on and extracting values from an Azure Event Hubs message using **Expressions** as defined below:
73
71
74
72
|Property|Description|Example|
75
73
|--------|-----------|-------|
@@ -82,7 +80,7 @@ The CalculatedContentTemplate allows matching on and extracting values from an A
82
80
|CorrelationIdExpression|*Optional*: The expression to extract the correlation identifier. This output can be used to group values into a single observation in the FHIR destination mappings.|`$.matchedToken.correlationId`|
83
81
|Values[].ValueName|The name to associate with the value extracted by the next expression. Used to bind the wanted value/component in the FHIR destination mapping template.|`hr`|
84
82
|Values[].ValueExpression|The expression to extract the wanted value.|`$.matchedToken.heartRate`|
85
-
|Values[].Required|Will require the value to be present in the payload. If not found, a measurement won't be generated and an InvalidOperationException will be created.|`true`|
83
+
|Values[].Required|Will require the value to be present in the payload. If not found, a measurement won't be generated, and an InvalidOperationException will be created.|`true`|
86
84
87
85
### Expression Languages
88
86
@@ -91,16 +89,16 @@ When specifying the language to use for the expression, the below values are val
91
89
| Expression Language | Value |
92
90
|---------------------|--------------|
93
91
| JSONPath |**JsonPath**|
94
-
|JmesPath|**JmesPath**|
92
+
|JMESPath|**JmesPath**|
95
93
96
94
>[!TIP]
97
-
>For more information on JSONPath, see [JSONPath](https://goessner.net/articles/JsonPath/). The [CalculatedContentTemplate](#calculatedcontenttemplate) uses the [JSON .NET implementation](https://www.newtonsoft.com/json/help/html/QueryJsonSelectTokenJsonPath.htm) for resolving JSONPath expressions.
95
+
>For more information on JSONPath, see [JSONPath](https://goessner.net/articles/JsonPath/). The [CalculatedContentTemplate](#calculatedcontenttemplate) uses the [JSON .NET implementation](https://www.newtonsoft.com/json/help/html/QueryJsonSelectTokenJsonPath.htm) for resolving JSONPath expressions.
98
96
>
99
-
>For more information on JmesPath, see [JmesPath](https://jmespath.org/specification.html). The [CalculatedContentTemplate](#calculatedcontenttemplate) uses the [JmesPath .NET implementation](https://github.com/jdevillard/JmesPath.Net) for resolving JmesPath expressions.
97
+
>For more information on JMESPath, see [JMESPath](https://jmespath.org/specification.html). The [CalculatedContentTemplate](#calculatedcontenttemplate) uses the [JMESPath .NET implementation](https://github.com/jdevillard/JmesPath.Net) for resolving JMESPath expressions.
100
98
101
-
### Custom Functions
99
+
### Custom functions
102
100
103
-
A set of MedTech service Custom Functions is also available. These Custom Functions are outside of the functions provided as part of the JmesPath specification. For more information on Custom Functions, see [MedTech service Custom Functions](./how-to-use-custom-functions.md).
101
+
A set of MedTech service custom functions is also available. The MedTech service custom functions are outside of the functions provided as part of the JMESPath specification. For more information on the MedTech service custom functions, see [How to use MedTech service custom functions](how-to-use-custom-functions.md).
104
102
105
103
### Matched Token
106
104
@@ -221,7 +219,6 @@ And
221
219
"systolic": "122",
222
220
"diastolic": "82",
223
221
"date": "2021-07-13T17:28:01.061122Z"
224
-
}
225
222
}
226
223
}
227
224
```
@@ -509,7 +506,7 @@ In the below example, height data arrives in either inches or meters. We want al
509
506
{
510
507
"required": "true",
511
508
"valueExpression": {
512
-
"value": "multiply(to_number(matchedToken.height), `0.0254`)", // Convert inches to meters. Notice we utilize JmesPath as that gives us access to transformation functions
509
+
"value": "multiply(to_number(matchedToken.height), `0.0254`)", // Convert inches to meters. Notice we utilize JMESPath as that gives us access to transformation functions
513
510
"language": "JmesPath"
514
511
},
515
512
"valueName": "height"
@@ -541,13 +538,13 @@ In the below example, height data arrives in either inches or meters. We want al
541
538
```
542
539
543
540
> [!TIP]
544
-
> See MedTech service [troubleshooting guide](./iot-troubleshoot-guide.md) for assistance fixing common errors and issues.
541
+
> See the MedTech service article [Troubleshoot MedTech service device and FHIR destination mappings](iot-troubleshoot-mappings.md) for assistance fixing common errors and issues related to MedTech service mappings.
545
542
546
543
## Next steps
547
544
548
545
In this article, you learned how to use Device mappings. To learn how to use FHIR destination mappings, see
549
546
550
-
>[!div class="nextstepaction"]
551
-
>[How to use FHIR destination mappings](how-to-use-fhir-mappings.md)
547
+
>[!div class="nextstepaction"]
548
+
>[How to use FHIR destination mappings](how-to-use-fhir-mappings.md)
552
549
553
-
(FHIR®) is a registered trademark of [HL7](https://hl7.org/fhir/)and is used with the permission of HL7.
550
+
(FHIR®) is a registered trademark of Health Level Seven International, registered in the U.S. Trademark Office and is used with their permission.
0 commit comments