public async Task AnnotateTextAsync()
        {
            Mock <LanguageService.LanguageServiceClient> mockGrpcClient = new Mock <LanguageService.LanguageServiceClient>(MockBehavior.Strict);
            AnnotateTextRequest expectedRequest = new AnnotateTextRequest
            {
                Document     = new Document(),
                Features     = new AnnotateTextRequest.Types.Features(),
                EncodingType = EncodingType.None,
            };
            AnnotateTextResponse expectedResponse = new AnnotateTextResponse
            {
                Language = "language-1613589672",
            };

            mockGrpcClient.Setup(x => x.AnnotateTextAsync(expectedRequest, It.IsAny <CallOptions>()))
            .Returns(new Grpc.Core.AsyncUnaryCall <AnnotateTextResponse>(Task.FromResult(expectedResponse), null, null, null, null));
            LanguageServiceClient client = new LanguageServiceClientImpl(mockGrpcClient.Object, null);
            Document document            = new Document();

            AnnotateTextRequest.Types.Features features = new AnnotateTextRequest.Types.Features();
            EncodingType         encodingType           = EncodingType.None;
            AnnotateTextResponse response = await client.AnnotateTextAsync(document, features, encodingType);

            Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }
 public virtual AnnotateTextResponse AnnotateText(Document document, AnnotateTextRequest.Types.Features features, EncodingType?encodingType, gaxgrpc::CallSettings callSettings = null) =>
 AnnotateText(new AnnotateTextRequest
 {
     Document     = gax::GaxPreconditions.CheckNotNull(document, nameof(document)),
     Features     = gax::GaxPreconditions.CheckNotNull(features, nameof(features)),
     EncodingType = encodingType ?? EncodingType.None,
 }, callSettings);
Exemplo n.º 3
0
 /// <summary>
 /// Advanced API that analyzes the document and provides a full set of text
 /// annotations, including semantic, syntactic, and sentiment information. This
 /// API is intended for users who are familiar with machine learning and need
 /// in-depth text features to build upon.
 /// </summary>
 /// <param name="document">Input document.</param>
 /// <param name="features">The enabled features.</param>
 /// <param name="encodingType">The encoding type used by the API to calculate offsets.</param>
 /// <param name="callSettings">If not null, applies overrides to this RPC call.</param>
 /// <returns>The RPC response.</returns>
 public virtual AnnotateTextResponse AnnotateText(
     Document document,
     AnnotateTextRequest.Types.Features features,
     EncodingType encodingType,
     CallSettings callSettings = null)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 4
0
 /// <summary>
 /// A convenience method that provides all the features that analyzeSentiment,
 /// analyzeEntities, and analyzeSyntax provide in one call.
 /// </summary>
 /// <param name="document">
 /// Input document.
 /// </param>
 /// <param name="features">
 /// The enabled features.
 /// </param>
 /// <param name="encodingType">
 /// The encoding type used by the API to calculate offsets.
 /// </param>
 /// <param name="cancellationToken">
 /// A <see cref="CancellationToken"/> to use for this RPC.
 /// </param>
 /// <returns>
 /// A Task containing the RPC response.
 /// </returns>
 public virtual Task <AnnotateTextResponse> AnnotateTextAsync(
     Document document,
     AnnotateTextRequest.Types.Features features,
     EncodingType encodingType,
     CancellationToken cancellationToken) => AnnotateTextAsync(
     document,
     features,
     encodingType,
     CallSettings.FromCancellationToken(cancellationToken));
Exemplo n.º 5
0
 /// <summary>
 /// A convenience method that provides all the features that analyzeSentiment,
 /// analyzeEntities, and analyzeSyntax provide in one call.
 /// </summary>
 /// <param name="document">
 /// Input document.
 /// </param>
 /// <param name="features">
 /// The enabled features.
 /// </param>
 /// <param name="encodingType">
 /// The encoding type used by the API to calculate offsets.
 /// </param>
 /// <param name="callSettings">
 /// If not null, applies overrides to this RPC call.
 /// </param>
 /// <returns>
 /// A Task containing the RPC response.
 /// </returns>
 public virtual Task <AnnotateTextResponse> AnnotateTextAsync(
     Document document,
     AnnotateTextRequest.Types.Features features,
     EncodingType encodingType,
     CallSettings callSettings = null) => AnnotateTextAsync(
     new AnnotateTextRequest
 {
     Document     = GaxPreconditions.CheckNotNull(document, nameof(document)),
     Features     = GaxPreconditions.CheckNotNull(features, nameof(features)),
     EncodingType = encodingType,
 },
     callSettings);
Exemplo n.º 6
0
 /// <summary>
 /// A convenience method that provides all the features that analyzeSentiment,
 /// analyzeEntities, and analyzeSyntax provide in one call.
 /// </summary>
 /// <param name="document">
 /// Input document.
 /// </param>
 /// <param name="features">
 /// The enabled features.
 /// </param>
 /// <param name="encodingType">
 /// The encoding type used by the API to calculate offsets.
 /// </param>
 /// <param name="callSettings">
 /// If not null, applies overrides to this RPC call.
 /// </param>
 /// <returns>
 /// The RPC response.
 /// </returns>
 public virtual AnnotateTextResponse AnnotateText(
     Document document,
     AnnotateTextRequest.Types.Features features,
     EncodingType encodingType,
     CallSettings callSettings = null) => AnnotateText(
     new AnnotateTextRequest
 {
     Document     = document,
     Features     = features,
     EncodingType = encodingType,
 },
     callSettings);
Exemplo n.º 7
0
 /// <summary>
 /// Advanced API that analyzes the document and provides a full set of text
 /// annotations, including semantic, syntactic, and sentiment information. This
 /// API is intended for users who are familiar with machine learning and need
 /// in-depth text features to build upon.
 /// </summary>
 /// <param name="document">Input document.</param>
 /// <param name="features">The enabled features.</param>
 /// <param name="encodingType">The encoding type used by the API to calculate offsets.</param>
 /// <param name="callSettings">If not null, applies overrides to this RPC call.</param>
 /// <returns>A Task containing the RPC response.</returns>
 public override Task <AnnotateTextResponse> AnnotateTextAsync(
     Document document,
     AnnotateTextRequest.Types.Features features,
     EncodingType encodingType,
     CallSettings callSettings = null) => _callAnnotateText.Async(
     new AnnotateTextRequest
 {
     Document     = document,
     Features     = features,
     EncodingType = encodingType,
 },
     callSettings);
        /// <summary>Snippet for AnnotateText</summary>
        public void AnnotateText2()
        {
            // Snippet: AnnotateText(Document, AnnotateTextRequest.Types.Features, CallSettings)
            // Create client
            LanguageServiceClient languageServiceClient = LanguageServiceClient.Create();
            // Initialize request argument(s)
            Document document = new Document();

            AnnotateTextRequest.Types.Features features = new AnnotateTextRequest.Types.Features();
            // Make the request
            AnnotateTextResponse response = languageServiceClient.AnnotateText(document, features);
            // End snippet
        }
Exemplo n.º 9
0
        /// <summary>
        /// A convenience method that provides all the features that analyzeSentiment,
        /// analyzeEntities, and analyzeSyntax provide in one call.
        /// </summary>
        /// <param name="document">
        /// Input document.
        /// </param>
        /// <param name="features">
        /// The enabled features.
        /// </param>
        /// <param name="encodingType">
        /// The encoding type used by the API to calculate offsets.
        /// </param>
        /// <param name="callSettings">
        /// If not null, applies overrides to this RPC call.
        /// </param>
        /// <returns>
        /// The RPC response.
        /// </returns>
        public override AnnotateTextResponse AnnotateText(
            Document document,
            AnnotateTextRequest.Types.Features features,
            EncodingType encodingType,
            CallSettings callSettings = null)
        {
            AnnotateTextRequest request = new AnnotateTextRequest
            {
                Document     = document,
                Features     = features,
                EncodingType = encodingType,
            };

            Modify_AnnotateTextRequest(ref request, ref callSettings);
            return(_callAnnotateText.Sync(request, callSettings));
        }
Exemplo n.º 10
0
        public async Task AnnotateTextAsync()
        {
            // Snippet: AnnotateTextAsync(Document,AnnotateTextRequest.Types.Features,EncodingType,CallSettings)
            // Additional: AnnotateTextAsync(Document,AnnotateTextRequest.Types.Features,EncodingType,CancellationToken)
            // Create client
            LanguageServiceClient languageServiceClient = LanguageServiceClient.Create();
            // Initialize request argument(s)
            Document document = new Document();

            AnnotateTextRequest.Types.Features features = new AnnotateTextRequest.Types.Features();
            EncodingType encodingType = EncodingType.None;
            // Make the request
            AnnotateTextResponse response = await languageServiceClient.AnnotateTextAsync(document, features, encodingType);

            // End snippet
        }
        public void AnnotateText2()
        {
            Mock <LanguageService.LanguageServiceClient> mockGrpcClient = new Mock <LanguageService.LanguageServiceClient>(MockBehavior.Strict);
            AnnotateTextRequest expectedRequest = new AnnotateTextRequest
            {
                Document = new Document(),
                Features = new AnnotateTextRequest.Types.Features(),
            };
            AnnotateTextResponse expectedResponse = new AnnotateTextResponse
            {
                Language = "language-1613589672",
            };

            mockGrpcClient.Setup(x => x.AnnotateText(expectedRequest, It.IsAny <CallOptions>()))
            .Returns(expectedResponse);
            LanguageServiceClient client = new LanguageServiceClientImpl(mockGrpcClient.Object, null);
            Document document            = new Document();

            AnnotateTextRequest.Types.Features features = new AnnotateTextRequest.Types.Features();
            AnnotateTextResponse response = client.AnnotateText(document, features);

            Assert.Same(expectedResponse, response);
            mockGrpcClient.VerifyAll();
        }