Spaces:
Sleeping
Sleeping
| 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() |