Azure Text Analytics (Azure AI Language), metinlerdeki duygu durumunu, anahtar kelimeleri ve dili otomatik olarak analiz edebilir. PowerShell ile bu servisi entegre ederek veri işleme süreçlerinizi akıllı hale getirebilirsiniz.
Duygu Analizi Yapmak
PowerShell
$endpoint = "https://my-language.cognitiveservices.azure.com/"
$apiKey = (Get-AzKeyVaultSecret -VaultName "myVault" -Name "language-key" -AsPlainText)
$headers = @{ "Ocp-Apim-Subscription-Key" = $apiKey; "Content-Type" = "application/json" }
$body = @{
documents = @(
@{ id = "1"; language = "tr"; text = "PowerShell harika bir platform!" }
@{ id = "2"; language = "tr"; text = "Azure guzel bir platform" }
)
} | ConvertTo-Json -Depth 3
$url = "$endpoint/text/analytics/v3.1/sentiment"
$response = Invoke-RestMethod -Uri $url -Headers $headers -Method Post -Body $body
$response.documents | ForEach-Object {
Write-Host "Belge $($_.id): $($_.sentiment) (Pozitif: $([math]::Round($_.confidenceScores.positive*100,1))%)"
}

Anahtar Kelime Çıkarımı
PowerShell
$kpUrl = "$endpoint/text/analytics/v3.1/keyPhrases"
$body2 = @{
documents = @(
@{ id = "1"; language = "tr"; text = "PowerShell ile Azure yönetimi çok daha verimli hale geliyor. Otomasyon scriptleri operasyonel maliyetleri düşürüyor." }
)
} | ConvertTo-Json -Depth 3
$kpResult = Invoke-RestMethod -Uri $kpUrl -Headers $headers -Method Post -Body $body2
Write-Host "Anahtar kelimeler:"
$kpResult.documents[0].keyPhrases | ForEach-Object { Write-Host " - $_" }

Dil Tespiti
PowerShell
$langUrl = "$endpoint/text/analytics/v3.1/languages"
$texts = @("Hello, how are you?", "Bonjour le monde", "Merhaba dünya", "Hola mundo")
$docs = $texts | ForEach-Object -Begin { $i=0 } { @{ id = "$i"; text = $_ }; $i++ }
$body3 = @{ documents = $docs } | ConvertTo-Json -Depth 3
$langResult = Invoke-RestMethod -Uri $langUrl -Headers $headers -Method Post -Body $body3
$langResult.documents | ForEach-Object {
Write-Host "Belge $($_.id): $($_.detectedLanguage.name) ($($_.detectedLanguage.iso6391Name))"
}
