Created
June 5, 2018 09:33
-
-
Save naoyaikeda/e9df92246a0993811c7e65eddb9a4792 to your computer and use it in GitHub Desktop.
Text Sentiment
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$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" | |
id = "1" | |
text = $text | |
}) | |
} | |
$json = ConvertTo-Json $obj | |
$result = Invoke-RestMethod -Uri $endPoint -Headers $headers -Body $json -ContentType 'application/json; charset=utf-8' -Method Post | |
$items = $result.documents | |
$item = $items[0] | |
$item.score | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment