要先建好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. 台湾是我的国家

	    	微信扫一扫打赏
	    
	    	支付宝扫一扫打赏