Ejemplo n.º 1
0
        internal virtual BatchDetectEntitiesResponse BatchDetectEntities(BatchDetectEntitiesRequest request)
        {
            var marshaller   = new BatchDetectEntitiesRequestMarshaller();
            var unmarshaller = BatchDetectEntitiesResponseUnmarshaller.Instance;

            return(Invoke <BatchDetectEntitiesRequest, BatchDetectEntitiesResponse>(request, marshaller, unmarshaller));
        }
Ejemplo n.º 2
0
        public static void Sample()
        {
            var comprehendClient = new AmazonComprehendClient(Amazon.RegionEndpoint.USWest2);

            var textList = new List <String>()
            {
                { "I love Seattle" },
                { "Today is Sunday" },
                { "Tomorrow is Monday" },
                { "I love Seattle" }
            };

            // Call detectEntities API
            Console.WriteLine("Calling BatchDetectEntities");
            var batchDetectEntitiesRequest = new BatchDetectEntitiesRequest()
            {
                TextList     = textList,
                LanguageCode = "en"
            };
            var batchDetectEntitiesResponse = comprehendClient.BatchDetectEntities(batchDetectEntitiesRequest);

            foreach (var item in batchDetectEntitiesResponse.ResultList)
            {
                Console.WriteLine("Entities in {0}:", textList[item.Index]);
                foreach (Entity entity in item.Entities)
                {
                    PrintEntity(entity);
                }
            }

            // check if we need to retry failed requests
            if (batchDetectEntitiesResponse.ErrorList.Count != 0)
            {
                Console.WriteLine("Retrying Failed Requests");
                var textToRetry = new List <String>();
                foreach (var errorItem in batchDetectEntitiesResponse.ErrorList)
                {
                    textToRetry.Add(textList[errorItem.Index]);
                }

                batchDetectEntitiesRequest = new BatchDetectEntitiesRequest()
                {
                    TextList     = textToRetry,
                    LanguageCode = "en"
                };

                batchDetectEntitiesResponse = comprehendClient.BatchDetectEntities(batchDetectEntitiesRequest);

                foreach (var item in batchDetectEntitiesResponse.ResultList)
                {
                    Console.WriteLine("Entities in {0}:", textList[item.Index]);
                    foreach (var entity in item.Entities)
                    {
                        PrintEntity(entity);
                    }
                }
            }
            Console.WriteLine("End of DetectEntities");
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Initiates the asynchronous execution of the BatchDetectEntities operation.
        /// </summary>
        ///
        /// <param name="request">Container for the necessary parameters to execute the BatchDetectEntities 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/BatchDetectEntities">REST API Reference for BatchDetectEntities Operation</seealso>
        public virtual Task <BatchDetectEntitiesResponse> BatchDetectEntitiesAsync(BatchDetectEntitiesRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken))
        {
            var marshaller   = new BatchDetectEntitiesRequestMarshaller();
            var unmarshaller = BatchDetectEntitiesResponseUnmarshaller.Instance;

            return(InvokeAsync <BatchDetectEntitiesRequest, BatchDetectEntitiesResponse>(request, marshaller,
                                                                                         unmarshaller, cancellationToken));
        }