Create an instance of SentimentClassifier class. It is multilingual and supports English, Chinese, Spanish, and German.
Creates SentimentClassifier instance
varsentimentClassifier=newSentimentClassifier();
and call PositiveProbability method
Classifies sentiment by text
varpositiveProbability=sentimentClassifier.PositiveProbability("This is a new must-have thing.");Console.WriteLine($"The probability of a positive sentiment is { positiveProbability }");
or call Classify method
Classifies sentiment by text
varresponse=sentimentClassifier.Classify("This is a new must-have thing.");Console.WriteLine($"The best class name:{response.BestClassName}, probability: {response.BestClassProbability}");
Classifies sentiment by text with 3 classes taxonomy (Negative/Neutral/Positive)
varresponse=sentimentClassifier.Classify("This is a new must-have thing.",taxonomy:Taxonomy.Sentiment3);Console.WriteLine($"The best class name:{response.BestClassName}, probability: {response.BestClassProbability}");
SentimentClassifier class is thread-safe.
Was this page helpful?
Any additional feedback you'd like to share with us?
Please tell us how we can improve this page.
Thank you for your feedback!
We value your opinion. Your feedback will help us improve our documentation.