Skip to content

Instantly share code, notes, and snippets.

@naoyaikeda
Created June 5, 2018 09:33
Show Gist options
  • Save naoyaikeda/e9df92246a0993811c7e65eddb9a4792 to your computer and use it in GitHub Desktop.
Save naoyaikeda/e9df92246a0993811c7e65eddb9a4792 to your computer and use it in GitHub Desktop.
Text Sentiment
$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