Cognitive Servicesのテキスト分析にPowerShellから投げてみる
PowerShellからCognitive Servicesのネガポジ分析をたたいてみました。 $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 }