Example #1
0
        public string analyze(string s)
        {
            var inputDocuments = new TextAnalyticsBatchInput()
            {
                Documents = new List <TextAnalyticsInput>()
                {
                    new TextAnalyticsInput()
                    {
                        Id   = "1",
                        Text = s
                    }
                }
            };

            var    sentimentV3Prediction = TextAnalyticsSentimentV3Client.SentimentV3PreviewPredictAsync(inputDocuments).Result;
            string res = "" + sentimentV3Prediction.Documents[0].Sentiment;

            return(res);
        }
Example #2
0
        public static void Main(string[] args)
        {
            var inputDocuments = new TextAnalyticsBatchInput()
            {
                Documents = new List <TextAnalyticsInput>()
                {
                    new TextAnalyticsInput()
                    {
                        Id = "1",

                        Text = "Hello world. This is some input text."
                    },

                    new TextAnalyticsInput()
                    {
                        Id = "2",

                        Text = "It's incredibly sunny outside! I'm so happy."
                    },

                    new TextAnalyticsInput()
                    {
                        Id = "3",

                        Text = "Pike place market is not my favorite Seattle attraction."
                    }
                }
            };
            //If you’re using C# 7.1 or greater, you can use an async main() method to await the function
            var sentimentV3Prediction = TextAnalyticsSentimentV3Client.SentimentV3PreviewPredictAsync(inputDocuments).Result;

            // Replace with whatever you wish to print or simply consume the sentiment v3 prediction
            Console.WriteLine("Document ID=" + sentimentV3Prediction.Documents[0].Id + " : Sentiment=" + sentimentV3Prediction.Documents[0].Sentiment);
            Console.WriteLine("Document ID=" + sentimentV3Prediction.Documents[1].Id + " : Sentiment=" + sentimentV3Prediction.Documents[1].Sentiment);
            Console.WriteLine("Document ID=" + sentimentV3Prediction.Documents[2].Id + " : Sentiment=" + sentimentV3Prediction.Documents[2].Sentiment);
            Console.ReadKey();
        }