| | 1 | | // <auto-generated> |
| | 2 | | // Code generated by Microsoft (R) AutoRest Code Generator. |
| | 3 | | // Changes may cause incorrect behavior and will be lost if the code is |
| | 4 | | // regenerated. |
| | 5 | | // </auto-generated> |
| | 6 | |
|
| | 7 | | namespace Microsoft.Azure.CognitiveServices.Language.SpellCheck |
| | 8 | | { |
| | 9 | | using Models; |
| | 10 | | using System.Threading; |
| | 11 | | using System.Threading.Tasks; |
| | 12 | |
|
| | 13 | | /// <summary> |
| | 14 | | /// Extension methods for SpellCheckClient. |
| | 15 | | /// </summary> |
| | 16 | | public static partial class SpellCheckClientExtensions |
| | 17 | | { |
| | 18 | | /// <summary> |
| | 19 | | /// The Bing Spell Check API lets you perform contextual grammar and spell |
| | 20 | | /// checking. Bing has developed a web-based spell-checker that leverages |
| | 21 | | /// machine learning and statistical machine translation to dynamically train a |
| | 22 | | /// constantly evolving and highly contextual algorithm. The spell-checker is |
| | 23 | | /// based on a massive corpus of web searches and documents. |
| | 24 | | /// </summary> |
| | 25 | | /// <param name='operations'> |
| | 26 | | /// The operations group for this extension method. |
| | 27 | | /// </param> |
| | 28 | | /// <param name='text'> |
| | 29 | | /// The text string to check for spelling and grammar errors. The combined |
| | 30 | | /// length of the text string, preContextText string, and postContextText |
| | 31 | | /// string may not exceed 10,000 characters. You may specify this parameter in |
| | 32 | | /// the query string of a GET request or in the body of a POST request. Because |
| | 33 | | /// of the query string length limit, you'll typically use a POST request |
| | 34 | | /// unless you're checking only short strings. |
| | 35 | | /// </param> |
| | 36 | | /// <param name='acceptLanguage'> |
| | 37 | | /// A comma-delimited list of one or more languages to use for user interface |
| | 38 | | /// strings. The list is in decreasing order of preference. For additional |
| | 39 | | /// information, including expected format, see |
| | 40 | | /// [RFC2616](http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html). This |
| | 41 | | /// header and the setLang query parameter are mutually exclusive; do not |
| | 42 | | /// specify both. If you set this header, you must also specify the cc query |
| | 43 | | /// parameter. Bing will use the first supported language it finds from the |
| | 44 | | /// list, and combine that language with the cc parameter value to determine |
| | 45 | | /// the market to return results for. If the list does not include a supported |
| | 46 | | /// language, Bing will find the closest language and market that supports the |
| | 47 | | /// request, and may use an aggregated or default market for the results |
| | 48 | | /// instead of a specified one. You should use this header and the cc query |
| | 49 | | /// parameter only if you specify multiple languages; otherwise, you should use |
| | 50 | | /// the mkt and setLang query parameters. A user interface string is a string |
| | 51 | | /// that's used as a label in a user interface. There are very few user |
| | 52 | | /// interface strings in the JSON response objects. Any links in the response |
| | 53 | | /// objects to Bing.com properties will apply the specified language. |
| | 54 | | /// </param> |
| | 55 | | /// <param name='pragma'> |
| | 56 | | /// By default, Bing returns cached content, if available. To prevent Bing from |
| | 57 | | /// returning cached content, set the Pragma header to no-cache (for example, |
| | 58 | | /// Pragma: no-cache). |
| | 59 | | /// </param> |
| | 60 | | /// <param name='userAgent'> |
| | 61 | | /// The user agent originating the request. Bing uses the user agent to provide |
| | 62 | | /// mobile users with an optimized experience. Although optional, you are |
| | 63 | | /// strongly encouraged to always specify this header. The user-agent should be |
| | 64 | | /// the same string that any commonly used browser would send. For information |
| | 65 | | /// about user agents, see [RFC |
| | 66 | | /// 2616](http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html). |
| | 67 | | /// </param> |
| | 68 | | /// <param name='clientId'> |
| | 69 | | /// Bing uses this header to provide users with consistent behavior across Bing |
| | 70 | | /// API calls. Bing often flights new features and improvements, and it uses |
| | 71 | | /// the client ID as a key for assigning traffic on different flights. If you |
| | 72 | | /// do not use the same client ID for a user across multiple requests, then |
| | 73 | | /// Bing may assign the user to multiple conflicting flights. Being assigned to |
| | 74 | | /// multiple conflicting flights can lead to an inconsistent user experience. |
| | 75 | | /// For example, if the second request has a different flight assignment than |
| | 76 | | /// the first, the experience may be unexpected. Also, Bing can use the client |
| | 77 | | /// ID to tailor web results to that client ID’s search history, providing a |
| | 78 | | /// richer experience for the user. Bing also uses this header to help improve |
| | 79 | | /// result rankings by analyzing the activity generated by a client ID. The |
| | 80 | | /// relevance improvements help with better quality of results delivered by |
| | 81 | | /// Bing APIs and in turn enables higher click-through rates for the API |
| | 82 | | /// consumer. IMPORTANT: Although optional, you should consider this header |
| | 83 | | /// required. Persisting the client ID across multiple requests for the same |
| | 84 | | /// end user and device combination enables 1) the API consumer to receive a |
| | 85 | | /// consistent user experience, and 2) higher click-through rates via better |
| | 86 | | /// quality of results from the Bing APIs. Each user that uses your application |
| | 87 | | /// on the device must have a unique, Bing generated client ID. If you do not |
| | 88 | | /// include this header in the request, Bing generates an ID and returns it in |
| | 89 | | /// the X-MSEdge-ClientID response header. The only time that you should NOT |
| | 90 | | /// include this header in a request is the first time the user uses your app |
| | 91 | | /// on that device. Use the client ID for each Bing API request that your app |
| | 92 | | /// makes for this user on the device. Persist the client ID. To persist the ID |
| | 93 | | /// in a browser app, use a persistent HTTP cookie to ensure the ID is used |
| | 94 | | /// across all sessions. Do not use a session cookie. For other apps such as |
| | 95 | | /// mobile apps, use the device's persistent storage to persist the ID. The |
| | 96 | | /// next time the user uses your app on that device, get the client ID that you |
| | 97 | | /// persisted. Bing responses may or may not include this header. If the |
| | 98 | | /// response includes this header, capture the client ID and use it for all |
| | 99 | | /// subsequent Bing requests for the user on that device. If you include the |
| | 100 | | /// X-MSEdge-ClientID, you must not include cookies in the request. |
| | 101 | | /// </param> |
| | 102 | | /// <param name='clientIp'> |
| | 103 | | /// The IPv4 or IPv6 address of the client device. The IP address is used to |
| | 104 | | /// discover the user's location. Bing uses the location information to |
| | 105 | | /// determine safe search behavior. Although optional, you are encouraged to |
| | 106 | | /// always specify this header and the X-Search-Location header. Do not |
| | 107 | | /// obfuscate the address (for example, by changing the last octet to 0). |
| | 108 | | /// Obfuscating the address results in the location not being anywhere near the |
| | 109 | | /// device's actual location, which may result in Bing serving erroneous |
| | 110 | | /// results. |
| | 111 | | /// </param> |
| | 112 | | /// <param name='location'> |
| | 113 | | /// A semicolon-delimited list of key/value pairs that describe the client's |
| | 114 | | /// geographical location. Bing uses the location information to determine safe |
| | 115 | | /// search behavior and to return relevant local content. Specify the key/value |
| | 116 | | /// pair as <key>:<value>. The following are the keys that you use |
| | 117 | | /// to specify the user's location. lat (required): The latitude of the |
| | 118 | | /// client's location, in degrees. The latitude must be greater than or equal |
| | 119 | | /// to -90.0 and less than or equal to +90.0. Negative values indicate southern |
| | 120 | | /// latitudes and positive values indicate northern latitudes. long (required): |
| | 121 | | /// The longitude of the client's location, in degrees. The longitude must be |
| | 122 | | /// greater than or equal to -180.0 and less than or equal to +180.0. Negative |
| | 123 | | /// values indicate western longitudes and positive values indicate eastern |
| | 124 | | /// longitudes. re (required): The radius, in meters, which specifies the |
| | 125 | | /// horizontal accuracy of the coordinates. Pass the value returned by the |
| | 126 | | /// device's location service. Typical values might be 22m for GPS/Wi-Fi, 380m |
| | 127 | | /// for cell tower triangulation, and 18,000m for reverse IP lookup. ts |
| | 128 | | /// (optional): The UTC UNIX timestamp of when the client was at the location. |
| | 129 | | /// (The UNIX timestamp is the number of seconds since January 1, 1970.) head |
| | 130 | | /// (optional): The client's relative heading or direction of travel. Specify |
| | 131 | | /// the direction of travel as degrees from 0 through 360, counting clockwise |
| | 132 | | /// relative to true north. Specify this key only if the sp key is nonzero. sp |
| | 133 | | /// (optional): The horizontal velocity (speed), in meters per second, that the |
| | 134 | | /// client device is traveling. alt (optional): The altitude of the client |
| | 135 | | /// device, in meters. are (optional): The radius, in meters, that specifies |
| | 136 | | /// the vertical accuracy of the coordinates. Specify this key only if you |
| | 137 | | /// specify the alt key. Although many of the keys are optional, the more |
| | 138 | | /// information that you provide, the more accurate the location results are. |
| | 139 | | /// Although optional, you are encouraged to always specify the user's |
| | 140 | | /// geographical location. Providing the location is especially important if |
| | 141 | | /// the client's IP address does not accurately reflect the user's physical |
| | 142 | | /// location (for example, if the client uses VPN). For optimal results, you |
| | 143 | | /// should include this header and the X-Search-ClientIP header, but at a |
| | 144 | | /// minimum, you should include this header. |
| | 145 | | /// </param> |
| | 146 | | /// <param name='actionType'> |
| | 147 | | /// A string that's used by logging to determine whether the request is coming |
| | 148 | | /// from an interactive session or a page load. The following are the possible |
| | 149 | | /// values. 1) Edit—The request is from an interactive session 2) Load—The |
| | 150 | | /// request is from a page load. Possible values include: 'Edit', 'Load' |
| | 151 | | /// </param> |
| | 152 | | /// <param name='appName'> |
| | 153 | | /// The unique name of your app. The name must be known by Bing. Do not include |
| | 154 | | /// this parameter unless you have previously contacted Bing to get a unique |
| | 155 | | /// app name. To get a unique name, contact your Bing Business Development |
| | 156 | | /// manager. |
| | 157 | | /// </param> |
| | 158 | | /// <param name='countryCode'> |
| | 159 | | /// A 2-character country code of the country where the results come from. This |
| | 160 | | /// API supports only the United States market. If you specify this query |
| | 161 | | /// parameter, it must be set to us. If you set this parameter, you must also |
| | 162 | | /// specify the Accept-Language header. Bing uses the first supported language |
| | 163 | | /// it finds from the languages list, and combine that language with the |
| | 164 | | /// country code that you specify to determine the market to return results |
| | 165 | | /// for. If the languages list does not include a supported language, Bing |
| | 166 | | /// finds the closest language and market that supports the request, or it may |
| | 167 | | /// use an aggregated or default market for the results instead of a specified |
| | 168 | | /// one. You should use this query parameter and the Accept-Language query |
| | 169 | | /// parameter only if you specify multiple languages; otherwise, you should use |
| | 170 | | /// the mkt and setLang query parameters. This parameter and the mkt query |
| | 171 | | /// parameter are mutually exclusive—do not specify both. |
| | 172 | | /// </param> |
| | 173 | | /// <param name='clientMachineName'> |
| | 174 | | /// A unique name of the device that the request is being made from. Generate a |
| | 175 | | /// unique value for each device (the value is unimportant). The service uses |
| | 176 | | /// the ID to help debug issues and improve the quality of corrections. |
| | 177 | | /// </param> |
| | 178 | | /// <param name='docId'> |
| | 179 | | /// A unique ID that identifies the document that the text belongs to. Generate |
| | 180 | | /// a unique value for each document (the value is unimportant). The service |
| | 181 | | /// uses the ID to help debug issues and improve the quality of corrections. |
| | 182 | | /// </param> |
| | 183 | | /// <param name='market'> |
| | 184 | | /// The market where the results come from. You are strongly encouraged to |
| | 185 | | /// always specify the market, if known. Specifying the market helps Bing route |
| | 186 | | /// the request and return an appropriate and optimal response. This parameter |
| | 187 | | /// and the cc query parameter are mutually exclusive—do not specify both. |
| | 188 | | /// </param> |
| | 189 | | /// <param name='sessionId'> |
| | 190 | | /// A unique ID that identifies this user session. Generate a unique value for |
| | 191 | | /// each user session (the value is unimportant). The service uses the ID to |
| | 192 | | /// help debug issues and improve the quality of corrections |
| | 193 | | /// </param> |
| | 194 | | /// <param name='setLang'> |
| | 195 | | /// The language to use for user interface strings. Specify the language using |
| | 196 | | /// the ISO 639-1 2-letter language code. For example, the language code for |
| | 197 | | /// English is EN. The default is EN (English). Although optional, you should |
| | 198 | | /// always specify the language. Typically, you set setLang to the same |
| | 199 | | /// language specified by mkt unless the user wants the user interface strings |
| | 200 | | /// displayed in a different language. This parameter and the Accept-Language |
| | 201 | | /// header are mutually exclusive—do not specify both. A user interface string |
| | 202 | | /// is a string that's used as a label in a user interface. There are few user |
| | 203 | | /// interface strings in the JSON response objects. Also, any links to Bing.com |
| | 204 | | /// properties in the response objects apply the specified language. |
| | 205 | | /// </param> |
| | 206 | | /// <param name='userId'> |
| | 207 | | /// A unique ID that identifies the user. Generate a unique value for each user |
| | 208 | | /// (the value is unimportant). The service uses the ID to help debug issues |
| | 209 | | /// and improve the quality of corrections. |
| | 210 | | /// </param> |
| | 211 | | /// <param name='mode'> |
| | 212 | | /// The type of spelling and grammar checks to perform. The following are the |
| | 213 | | /// possible values (the values are case insensitive). The default is Proof. 1) |
| | 214 | | /// Proof—Finds most spelling and grammar mistakes. 2) Spell—Finds most |
| | 215 | | /// spelling mistakes but does not find some of the grammar errors that Proof |
| | 216 | | /// catches (for example, capitalization and repeated words). Possible values |
| | 217 | | /// include: 'proof', 'spell' |
| | 218 | | /// </param> |
| | 219 | | /// <param name='preContextText'> |
| | 220 | | /// A string that gives context to the text string. For example, the text |
| | 221 | | /// string petal is valid. However, if you set preContextText to bike, the |
| | 222 | | /// context changes and the text string becomes not valid. In this case, the |
| | 223 | | /// API suggests that you change petal to pedal (as in bike pedal). This text |
| | 224 | | /// is not checked for grammar or spelling errors. The combined length of the |
| | 225 | | /// text string, preContextText string, and postContextText string may not |
| | 226 | | /// exceed 10,000 characters. You may specify this parameter in the query |
| | 227 | | /// string of a GET request or in the body of a POST request. |
| | 228 | | /// </param> |
| | 229 | | /// <param name='postContextText'> |
| | 230 | | /// A string that gives context to the text string. For example, the text |
| | 231 | | /// string read is valid. However, if you set postContextText to carpet, the |
| | 232 | | /// context changes and the text string becomes not valid. In this case, the |
| | 233 | | /// API suggests that you change read to red (as in red carpet). This text is |
| | 234 | | /// not checked for grammar or spelling errors. The combined length of the text |
| | 235 | | /// string, preContextText string, and postContextText string may not exceed |
| | 236 | | /// 10,000 characters. You may specify this parameter in the query string of a |
| | 237 | | /// GET request or in the body of a POST request. |
| | 238 | | /// </param> |
| | 239 | | /// <param name='cancellationToken'> |
| | 240 | | /// The cancellation token. |
| | 241 | | /// </param> |
| | 242 | | public static async Task<SpellCheckModel> SpellCheckerAsync(this ISpellCheckClient operations, string text, |
| | 243 | | { |
| 1 | 244 | | using (var _result = await operations.SpellCheckerWithHttpMessagesAsync(text, acceptLanguage, pragma, us |
| | 245 | | { |
| 1 | 246 | | return _result.Body; |
| | 247 | | } |
| 1 | 248 | | } |
| | 249 | |
|
| | 250 | | } |
| | 251 | | } |