Пример #1
0
        // [START auth_cloud_explicit]
        // Other APIs, like Language, accept a channel in their Create()
        // method.
        public object AuthExplicit(string projectId, string jsonPath)
        {
            LanguageServiceClientBuilder builder = new LanguageServiceClientBuilder
            {
                CredentialsPath = jsonPath
            };

            LanguageServiceClient client = builder.Build();

            AnalyzeSentiment(client);
            return(0);
        }
Пример #2
0
        public AnalyzeEntitiesResponse Analyze(string input)
        {
            LanguageServiceClientBuilder builder = new LanguageServiceClientBuilder
            {
                CredentialsPath = _config.GoogleCredentialFile
            };

            var languageServiceClient = builder.Build();

            var document = Document.FromPlainText($"{input}");

            return(languageServiceClient.AnalyzeEntities(document));
        }
Пример #3
0
        // [END auth_cloud_explicit]

        // [START auth_cloud_explicit_compute_engine]
        // Other APIs, like Language, accept a channel in their Create()
        // method.
        public object AuthExplicitComputeEngine(string projectId)
        {
            LanguageServiceClientBuilder builder = new LanguageServiceClientBuilder
            {
                ChannelCredentials = GoogleCredential
                                     .FromComputeCredential()
                                     .ToChannelCredentials()
            };

            LanguageServiceClient client = builder.Build();

            AnalyzeSentiment(client);
            return(0);
        }
Пример #4
0
        public MainWindow()
        {
            InitializeComponent();
            builder = new LanguageServiceClientBuilder
            {
                CredentialsPath = @"C:\Users\vdmil\Downloads\my_key.json"
            };
            client = builder.Build();

            waveOut = new WaveOut();
            waveIn  = new WaveIn();
            waveIn.DataAvailable += WaveIn_DataAvailable;
            waveIn.WaveFormat     = new NAudio.Wave.WaveFormat(16000, 1);
            bwp = new BufferedWaveProvider(waveIn.WaveFormat);
            bwp.DiscardOnBufferOverflow = true;
        }
        public static AnalyzeSyntaxResponse AnalyzeSyntax(string texto)
        {
            GoogleCredential   credential         = GoogleCredential.FromFile(JSON_PATH);
            ChannelCredentials channelCredentials = credential.ToChannelCredentials();
            var builder = new LanguageServiceClientBuilder();

            builder.ChannelCredentials = channelCredentials;
            var client = builder.Build();


            var syntax = client.AnalyzeSyntax(new Document()
            {
                Content  = texto,
                Type     = Document.Types.Type.PlainText,
                Language = "en-US"
            });

            return(syntax);
        }
Пример #6
0
        public AnnotateTextResponse AnalyzeSyntaxFromText(string info)
        {
            var client = new LanguageServiceClientBuilder();

            client.CredentialsPath = ("creds.json");

            var langClient = client.Build();

            var response = langClient.AnnotateText(new Document()
            {
                Content = info,
                Type    = Document.Types.Type.PlainText
            },
                                                   new Features()
            {
                ExtractSyntax = true
            });

            return(response);
        }