指定资料类别 Azure AI 语言的中由个人识别资讯 (侦测) 所辨识的实体类别 - Azure AI services | Microsoft Learn
要先建好Azure Language Services或 Azure AI Service (包含很多azure服务)
Azure语法能用各种语言不用装套件直接打, 也能用Postman测, 就是官网範例是错的
.net语法可参考 [AI] Azure PII进行资料遮罩(旧写法,仍可用)
以下为呼叫方法:
URL: https://XXXX.cognitiveservices.azure.com/language/:analyze-text?api-version=2024-11-15-preview
Header: Ocp-Apim-Subscription-Key=你的key
Body:以json格式传送如下内容:
{"kind": "PiiEntityRecognition",
"parameters":{
"modelVersion": "latest",
"piiCategories": ["Address","Person","CreditCardNumber","PhoneNumber","TWNationalID","TWResidentCertificate","TWPassportNumber"] ,
"redactionPolicy": {"policyKind": "CharacterMask",//CharacterMask, NoMask, EntityMask
"redactionCharacter": "*"}},
"analysisInput":{
"documents":
[{"id":"1","text":"ebay 王大明 Ms. Mary 台湾国台北巿独立路一段自由巷 帐户:4987135588888888"},
{"id":"2","text":"卡号:4987135588888888 王小强 Mr.John Lee, TEL:0800080080 No. 123, Ziyou Road, Hualien City, Taiwan"}
]
}
}
回覆资料如下:
{
"kind": "PiiEntityRecognitionResults",
"results": {
"documents": [
{
"redactedText": "ebay *** Ms. **** ************** 帐户:4987135588888888",
"id": "1",
"entities": [
{
"text": "王大明",
"category": "Person",
"type": "Person",
"offset": 5,
"length": 3,
"confidenceScore": 0.97,
"tags": [
{
"name": "Person",
"confidenceScore": 0.97
}
]
},
{
"text": "Mary",
"category": "Person",
"type": "Person",
"offset": 13,
"length": 4,
"confidenceScore": 0.58,
"tags": [
{
"name": "Person",
"confidenceScore": 0.58
}
]
},
{
"text": "台湾国台北巿独立路一段自由巷",
"category": "Address",
"type": "Address",
"offset": 18,
"length": 14,
"confidenceScore": 0.9,
"tags": [
{
"name": "Address",
"confidenceScore": 0.9
}
]
}
],
"warnings": []
},
{
"redactedText": "卡号***************** *** Mr.********, TEL:********** *****************************************",
"id": "2",
"entities": [
{
"text": ":4987135588888888",
"category": "CreditCardNumber",
"type": "CreditCardNumber",
"offset": 2,
"length": 17,
"confidenceScore": 0.94,
"tags": [
{
"name": "CreditCardNumber",
"confidenceScore": 0.94
}
]
},
{
"text": "王小强",
"category": "Person",
"type": "Person",
"offset": 20,
"length": 3,
"confidenceScore": 0.99,
"tags": [
{
"name": "Person",
"confidenceScore": 0.99
}
]
},
{
"text": "John Lee",
"category": "Person",
"type": "Person",
"offset": 27,
"length": 8,
"confidenceScore": 0.93,
"tags": [
{
"name": "Person",
"confidenceScore": 0.93
}
]
},
{
"text": "0800080080",
"category": "PhoneNumber",
"type": "PhoneNumber",
"offset": 41,
"length": 10,
"confidenceScore": 0.8,
"tags": [
{
"name": "PhoneNumber",
"confidenceScore": 0.8
}
]
},
{
"text": "No. 123, Ziyou Road, Hualien City, Taiwan",
"category": "Address",
"type": "Address",
"offset": 52,
"length": 41,
"confidenceScore": 0.94,
"tags": [
{
"name": "Address",
"confidenceScore": 0.94
}
]
}
],
"warnings": []
}
],
"errors": [],
"modelVersion": "2025-02-01"
}
}
Taiwan is a country. 台湾是我的国家