Skip to content

Instantly share code, notes, and snippets.

View naoyaikeda's full-sized avatar

Naoya Ikeda naoyaikeda

View GitHub Profile
@naoyaikeda
naoyaikeda / textSentimentW.ps1
Created June 5, 2018 09:39
Watson API from PowerShell
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
$account = @{
"username" = "****"
"password" = "****"
}
$texts = @("ColorfulのSSDめっちゃヤバいwww Galaxy S6や廃棄品のSSDから剥がしたフラッシュやIntelの偽物が搭載されているのが確認されてるらしいwww 安価なNVMe CN600もリマークチップを使ってるとのこと、、、 最近めっちゃ秋葉原で売ってるけど買わない方が良さそうだな、、、")
$endPoint = "https://gateway.watsonplatform.net/natural-language-understanding/api/v1/analyze?version=2018-03-16"
$pass = ConvertTo-SecureString $account.password -AsPlainText -Force
$user = $account.username
$apiKey = "****"
$texts = @("ColorfulのSSDめっちゃヤバいwww Galaxy S6や廃棄品のSSDから剥がしたフラッシュやIntelの偽物が搭載されているのが確認されてるらしいwww 安価なNVMe CN600もリマークチップを使ってるとのこと、、、 最近めっちゃ秋葉原で売ってるけど買わない方が良さそうだな、、、")
$headers = @{ 'Ocp-Apim-Subscription-Key' = $apiKey }
$endPoint = "https://eastasia.api.cognitive.microsoft.com/text/analytics/v2.0/sentiment"
$texts | ForEach-Object {
$text = $_
$obj = @{
documents = @(@{
language = "ja"