-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLanguage.http
176 lines (155 loc) · 6.64 KB
/
Language.http
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
##############################
# Azure AI Language Services #
##############################
# Formerly Text Analytics #
##############################
# https://learn.microsoft.com/en-us/azure/ai-services/language-service/
##########################
# Variables Used in Demo #
##########################
######################################
# Environment Variables Used in Demo #
######################################
# The following vars are better added to settings.json as ENVIRONMENT Variables
# @textAnalyticsRegion = Enter the Azure Translator region here. (e.g. westus2)
# @textAnalyticsEndpoint = https://api.cognitive.microsofttranslator.com
# DO NOT check in or commit keys in your repos!!
# vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
# @textAnalyticsSubscription = Enter your Azure subscription Key Here
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
# DO NOT check in or commit keys in your repos!!
######################
# Language Detection #
######################
# https://learn.microsoft.com/en-us/azure/ai-services/language-service/language-detection/overview
# A simple language detection of three snippets as exampled in:
# https://westus.dev.cognitive.microsoft.com/docs/services/TextAnalytics-v3-1/operations/Languages/console
# @name langDetectionRequest
POST {{textAnalyticsEndpoint}}/text/analytics/v3.1/languages
Ocp-Apim-Subscription-Key: {{textAnalyticsSubscription}}
Ocp-Apim-Subscription-Region: {{textAnalyticsRegion}}
Content-Type: application/json
{
"documents":
[
{
"countryHint": "US",
"id": "1",
"text": "Hello world"
},
{
"id": "2",
"text": "Bonjour tout le monde"
},
{
"id": "3",
"text": "La carretera estaba atascada. Había mucho tráfico el día de ayer."
}
]
}
#############################
# PII Detection & Redaction #
#############################
POST {{textAnalyticsEndpoint}}/language/:analyze-text?api-version=2023-04-01
Ocp-Apim-Subscription-Key: {{textAnalyticsSubscription}}
Ocp-Apim-Subscription-Region: {{textAnalyticsRegion}}
Content-Type: application/json
{
"kind": "PiiEntityRecognition",
"parameters": {
"modelVersion": "latest"
},
"analysisInput": {
"documents": [
{
"id": "1",
"language": "en",
"text": "My SSN is 859-98-0987"
},
{
"id": "2",
"language": "en",
"text": "Your ABA number - 111000025 - is the first 9 digits in the lower left hand corner of your personal check."
},
{
"id": "3",
"language": "en",
"text": "Is 998.214.865-68 your Brazilian CPF number?"
}
]
}
}
######################
# Sentiment Analysis #
######################
# https://learn.microsoft.com/en-us/azure/ai-services/language-service/sentiment-opinion-mining/overview
####
# Sentiment Analysis
# https://westus.dev.cognitive.microsoft.com/docs/services/TextAnalytics-v3-1/operations/Sentiment
# @name sentAnalysisRequest
POST {{textAnalyticsEndpoint}}/text/analytics/v3.1/keyPhrases?stringIndexType=TextElement_v8
Ocp-Apim-Subscription-Key: {{textAnalyticsSubscription}}
Ocp-Apim-Subscription-Region: {{textAnalyticsRegion}}
Content-Type: application/json
{
"documents": [
{
"id": "1",
"language": "en",
"text": "Great atmosphere. Close to plenty of restaurants, hotels, and transit! Staff are friendly and helpful."
},
{
"id": "2",
"language": "de",
"text": "Sehr schlechte Arbeiter und das Essen war nicht gut."
},
{
"id": "3",
"language": "es",
"text": "La carretera estaba atascada. Había mucho tráfico el día de ayer."
}
]
}
##############################
# Conversation Summarization #
##############################
# https://learn.microsoft.com/en-us/azure/ai-services/language-service/summarization/quickstart?tabs=document-summarization%2Cwindows&pivots=rest-api
# This is an Asynchronous command, so there is a 2 step process for this.
# 1. send a document to a conversation endpoint.
# 2. get the asynchronous results from a different request.
########################################
# --------------------------------------
# Summarization Request
# --------------------------------------
# @name convSumReq
POST {{textAnalyticsEndpoint}}/language/analyze-text/jobs?api-version=2023-04-01
Ocp-Apim-Subscription-Key: {{textAnalyticsSubscription}}
Content-Type: application/json
{
"analysisInput": {
"documents": [
{
"id": "1",
"language": "en",
"text": "At Microsoft, we have been on a quest to advance AI beyond existing techniques, by taking a more holistic, human-centric approach to learning and understanding. As Chief Technology Officer of Azure AI services, I have been working with a team of amazing scientists and engineers to turn this quest into a reality. In my role, I enjoy a unique perspective in viewing the relationship among three attributes of human cognition: monolingual text (X), audio or visual sensory signals, (Y) and multilingual (Z). At the intersection of all three, there’s magic—what we call XYZ-code as illustrated in Figure 1—a joint representation to create more powerful AI that can speak, hear, see, and understand humans better. We believe XYZ-code will enable us to fulfill our long-term vision: cross-domain transfer learning, spanning modalities and languages. The goal is to have pre-trained models that can jointly learn representations to support a broad range of downstream AI tasks, much in the way humans do today. Over the past five years, we have achieved human performance on benchmarks in conversational speech recognition, machine translation, conversational question answering, machine reading comprehension, and image captioning. These five breakthroughs provided us with strong signals toward our more ambitious aspiration to produce a leap in AI capabilities, achieving multi-sensory and multilingual learning that is closer in line with how humans learn and understand. I believe the joint XYZ-code is a foundational component of this aspiration, if grounded with external knowledge sources in the downstream AI tasks."
}
]
},
"tasks": [
{
"kind": "ExtractiveSummarization",
"taskName": "Document Extractive Summarization Task 1",
"parameters": {
"sentenceCount": 6
}
}
]
}
########################################
# --------------------------------------
# Summarization Status and/or Results
# --------------------------------------
GET {{convSumReq.response.headers.operation-location}}
Ocp-Apim-Subscription-Key: {{textAnalyticsSubscription}}
Content-Type: application/json
#####