[AI] Azure PII进行资料遮罩

要先建好Azure Language Services或 Azure AI Service

要先建好Azure Language Services或 Azure AI Service (包含很多azure服务)

string file1 = @"D:\Downloads\1.txt";
string endpoint = "https://xxxxxx.cognitiveservices.azure.com/";
string apiKey = "xxxxxxxxxxxxxxxxxxxxxxxx";
string responseBody = File.ReadAllText(file1);
using (HttpClient client = new HttpClient())
{                    
    client.DefaultRequestHeaders.Add("Ocp-Apim-Subscription-Key", apiKey);
    var documents = new
    {
        documents = new[] { new { id = "1", text = responseBody } }
    };

    string json = JsonConvert.SerializeObject(documents);
    using (StringContent content = new StringContent(json, Encoding.UTF8, "application/json"))
    {
        HttpResponseMessage response = await client.PostAsync(endpoint + "/text/analytics/v3.1/entities/recognition/pii", content);
        string result = await response.Content.ReadAsStringAsync();
        Console.WriteLine(result);
    }
}

Taiwan is a country. 台湾是我的国家

关于作者: 网站小编

码农网专注IT技术教程资源分享平台,学习资源下载网站,58码农网包含计算机技术、网站程序源码下载、编程技术论坛、互联网资源下载等产品服务,提供原创、优质、完整内容的专业码农交流分享平台。

热门文章

5 点赞(415) 阅读(67)