< Back

Get-Sentiment

Sun Jan 19, 2020 5:35 pm

NAME Get-Sentiment



SYNOPSIS

Get Sentiment in an input string





SYNTAX

Get-Sentiment [-String] <String> [<CommonParameters>]





DESCRIPTION

This cmdlet utlizes Microsoft cognitive service's "Bing Search" API to know the sentiment of the string.

NOTE : You need to subscribe the "Bing search API" before using the powershell script from the following link and

setup an environment variable like, $env:MS_TextAnalytics_API_key = "YOUR API KEY"



API Subscription Page - https://www.microsoft.com/cognitive-ser ... us/sign-up





PARAMETERS

-String <String>



Required? true

Position? 1

Default value

Accept pipeline input? true (ByValue)

Accept wildcard characters? false



<CommonParameters>

This cmdlet supports the common parameters: Verbose, Debug,

ErrorAction, ErrorVariable, WarningAction, WarningVariable,

OutBuffer, PipelineVariable, and OutVariable. For more information, see

about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).



INPUTS



OUTPUTS



NOTES





Author: Prateek Singh - @SinghPrateik



-------------------------- EXAMPLE 1 --------------------------



PS Root\\>Get-Sentiment -String "Hello Prateek, how are you?"



String Positive % Negative % OverallSentiment

------ ---------- ---------- ----------------

Hello Prateek, how are you? 93.37 6.63 Positive



In above example, I passed an string to cmdlet in order to get the Sentiment of the string.









-------------------------- EXAMPLE 2 --------------------------



PS Root\\>"howdy","what the hell","damn" | Get-Sentiment



String Positive % Negative % OverallSentiment

------ ---------- ---------- ----------------

howdy 99.12 0.88 Positive

what the hell 23.91 76.09 Negative

damn 0.80 99.20 Negative



You can also pass multiple strings as an argument through pipeline to the cmdlet to get the sentiment analysis











RELATED LINKS