Spaces:
Sleeping
Sleeping
File size: 971 Bytes
53d8966 7edad11 fa07efb 8a84b3b fa07efb 8a84b3b fa07efb 53d8966 fa07efb |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
import gradio as gr
import requests
def extract_pii(text):
res = requests.post(
"https://6b044.cognitiveservices.azure.com/language/:analyze-text?api-version=2022-05-01",
headers={
"Ocp-Apim-Subscription-Key": "941b608ce2634805b169eca63f51b856",
"Content-Type": "application/json",
},
json={
"kind": "PiiEntityRecognition",
"parameters": {
"modelVersion": "latest",
},
"analysisInput":{
"documents":[
{
"id":"1",
"language": "en",
"text": text,
},
],
},
},
)
pii_entities = res.json()["results"]["documents"][0]["entities"]
return str(pii_entities)
demo = gr.Interface(fn=extract_pii, inputs="textbox", outputs="textbox")
if __name__ == "__main__":
demo.launch() |