public async Task <DetectedLanguage> GetTextLanguageAsync(string text) { // Create a request and dependent object(s). var batchDetectDominantLanguageDetails = new BatchDetectDominantLanguageDetails { Documents = new List <DominantLanguageDocument> { new DominantLanguageDocument { Key = "doc-1", Text = text } } }; var batchDetectDominantLanguageRequest = new BatchDetectDominantLanguageRequest { BatchDetectDominantLanguageDetails = batchDetectDominantLanguageDetails, OpcRequestId = "394ZXI6MCFAHTJX1ZFSX<unique_ID>" }; var response = await client.BatchDetectDominantLanguage(batchDetectDominantLanguageRequest); // Retrieve value from the response. var documentsValue = response.BatchDetectDominantLanguageResult.Documents; //Console.WriteLine(documentsValue[0].Languages[0].ToString()); return(documentsValue[0].Languages[0]); }
protected override void ProcessRecord() { base.ProcessRecord(); BatchDetectDominantLanguageRequest request; try { request = new BatchDetectDominantLanguageRequest { BatchDetectDominantLanguageDetails = BatchDetectDominantLanguageDetails, OpcRequestId = OpcRequestId }; response = client.BatchDetectDominantLanguage(request).GetAwaiter().GetResult(); WriteOutput(response, response.BatchDetectDominantLanguageResult); FinishProcessing(response); } catch (Exception ex) { TerminatingErrorDuringExecution(ex); } }
/// <summary> /// Initiates the asynchronous execution of the BatchDetectDominantLanguage operation. /// </summary> /// /// <param name="request">Container for the necessary parameters to execute the BatchDetectDominantLanguage operation.</param> /// <param name="cancellationToken"> /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. /// </param> /// <returns>The task object representing the asynchronous operation.</returns> /// <seealso href="http://docs.aws.amazon.com/goto/WebAPI/comprehend-2017-11-27/BatchDetectDominantLanguage">REST API Reference for BatchDetectDominantLanguage Operation</seealso> public virtual Task <BatchDetectDominantLanguageResponse> BatchDetectDominantLanguageAsync(BatchDetectDominantLanguageRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken)) { var marshaller = new BatchDetectDominantLanguageRequestMarshaller(); var unmarshaller = BatchDetectDominantLanguageResponseUnmarshaller.Instance; return(InvokeAsync <BatchDetectDominantLanguageRequest, BatchDetectDominantLanguageResponse>(request, marshaller, unmarshaller, cancellationToken)); }
internal virtual BatchDetectDominantLanguageResponse BatchDetectDominantLanguage(BatchDetectDominantLanguageRequest request) { var marshaller = new BatchDetectDominantLanguageRequestMarshaller(); var unmarshaller = BatchDetectDominantLanguageResponseUnmarshaller.Instance; return(Invoke <BatchDetectDominantLanguageRequest, BatchDetectDominantLanguageResponse>(request, marshaller, unmarshaller)); }