-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTranslationExamples.http
182 lines (152 loc) · 5.33 KB
/
TranslationExamples.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
177
178
179
180
181
182
################################
# Languages Supported & Prices #
################################
# https://learn.microsoft.com/en-us/azure/cognitive-services/translator/language-support
curl "https://api.cognitive.microsofttranslator.com/languages?api-version=3.0&scope=translation"
####
GET https://prices.azure.com/api/retail/prices?api-version=2021-10-01-preview&meterRegion=’primary’
##########################
# Variables Used in Demo #
##########################
@to-lang=es
@badWord=Provide a bad word here
######################################
# Environment Variables Used in Demo #
######################################
# The following vars are better added to settings.json as ENVIRONMENT Variables
# @customModelCat = Enter the CategoryID for the relevant model shown in custom translator GUI
# @translatorRegion = Enter the Azure Translator region here. (e.g. westus2)
# @translatorEndpoint = https://api.cognitive.microsofttranslator.com
# DO NOT check in or commit keys in your repos!!
# vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
# @translatorSubscription = Enter your Azure Translator subscription Key Here
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
# DO NOT check in or commit keys in your repos!!
#######################
# Detect the language #
#######################
POST {{translatorEndpoint}}/detect?api-version=3.0
Content-Type: application/json; charset=utf-8
Ocp-Apim-Subscription-Key: {{translatorSubscription}}
Ocp-Apim-Subscription-Region: {{translatorRegion}}
[
{
"Text": "Esta es solo una declaración simple sobre el 15/10/2020 a las 2:30 pm."
},
{
"Text": "Sag mir, ob das funktioniert, <a href='../test.html'>Dies ist ein Beispiellink</a>"
}
]
##########################
# Detect and Sent Length #
##########################
POST {{translatorEndpoint}}/breaksentence?api-version=3.0
Content-Type: application/json; charset=utf-8
Ocp-Apim-Subscription-Key: {{translatorSubscription}}
Ocp-Apim-Subscription-Region: {{translatorRegion}}
[
{
"Text" : "Hello there! How are you?"
}
]
#####################################
# Dictionary Lookup (Lang Pair Rqd) #
#####################################
POST {{translatorEndpoint}}/dictionary/lookup?api-version=3.0
&from=en
&to={{to-lang}}
Content-Type: application/json; charset=utf-8
Ocp-Apim-Subscription-Key: {{translatorSubscription}}
Ocp-Apim-Subscription-Region: {{translatorRegion}}
[
{
"Text" : "Car"
}
]
######################################
# Dictionary Example (Lang Pair Rqd) #
######################################
# Requires one of the translated definitions above
POST {{translatorEndpoint}}/dictionary/examples?api-version=3.0
&from=en
&to={{to-lang}}
Content-Type: application/json; charset=utf-8
Ocp-Apim-Subscription-Key: {{translatorSubscription}}
Ocp-Apim-Subscription-Region: {{translatorRegion}}
[
{
"Text" : "Car",
"Translation": "coche"
}
]
###############################
# Translate - Known From Lang #
###############################
# Test with a known "from" language (en) to German
POST {{translatorEndpoint}}/translate?api-version=3.0
&to={{to-lang}}
&from=en
Content-Type: application/json; charset=utf-8
Ocp-Apim-Subscription-Key: {{translatorSubscription}}
Ocp-Apim-Subscription-Region: {{translatorRegion}}
[
{
"Text": "This is just a simple statement about 10/15/2020 at 2:30pm."
},
{
"Text": "Tell me if this works, <a href='../test.html'>This is an example link</a>"
}
]
#####################
# Unknown From Lang #
#####################
# Test with an unknown (autodetected) "from" language
POST {{translatorEndpoint}}/translate?api-version=3.0
&to={{to-lang}}
Content-Type: application/json; charset=utf-8
Ocp-Apim-Subscription-Key: {{translatorSubscription}}
Ocp-Apim-Subscription-Region: {{translatorRegion}}
[
{
"Text": "How many times can I do this in from different languages?"
}
]
#############################
# Custom Profanity Handing #
#############################
# Filter out profanity with HTML formatted text
# - NoAction
# - Marked
# - Deleted
#
# https://learn.microsoft.com/en-us/azure/cognitive-services/translator/reference/v3-0-translate#optional-parameters
POST {{translatorEndpoint}}/translate?api-version=3.0
&to={{to-lang}}
&profanityAction=Marked
&textType=html
Content-Type: application/json; charset=utf-8
Ocp-Apim-Subscription-Key: {{translatorSubscription}}
Ocp-Apim-Subscription-Region: {{translatorRegion}}
[
{
"Text": "<div>What a <b>{{badWord}}</b> agency to work with?</div>"
}
]
###############################
# Custom translate to Spanish #
###############################
# https://portal.customtranslator.azure.ai/
# Same key, just new "category" querystring item
# Hard-Coded for en to es as the custom model is fixed
# The trained dictionary used here has both "CTOBA" and "My App Name" as do-not translate.
#POST https://api.cognitive.microsofttranslator.com/translate?api-version=3.0
#&to=es
#&category={{customModelCat}}
#Content-Type: application/json; charset=utf-8
#Ocp-Apim-Subscription-Key: {{translatorSubscription}}
#Ocp-Apim-Subscription-Region: {{translatorRegion}}
#[
# {
# "Text": "This includes some custom translated text that should not be translated: CTBOA & My App Name"
# }
#]