File size: 2,071 Bytes
3c4c0f5 |
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 36 37 38 39 40 41 42 43 44 45 46 47 |
import requests
import json
test_texts = [
"My email is [email protected]",
"Call me at (123) 456-7890",
"I live at 123 Main St, New York, NY 10001",
"Let's meet at the park tomorrow",
"My phone number is 555-1234",
"You can reach me on Skype: user123",
"Reach me at one two three dot four five six dot seven eight nine zero",
"My handle is at_symbol_user_123 on that bird app",
"Drop me a line: first_name (dot) last_name [at] big_search_engine (dot) com",
"Ring me: area code seven-seven-seven then half a dozen, a quartet, and two pairs",
"Find me on the gram: @cool_user_2023",
"I'm on that professional network, just search for John Doe from Acme Corp",
"Send a raven to Winterfell, care of the Stark family",
"Ping me on IRC: /msg CoolDude42",
"You can find me at one two three Fake Street, Anytown, State of Confusion",
"My digits are the first ten prime numbers in order",
"Contact info: tango alpha november golf oscar at yankee alpha hotel oscar oscar dot charlie oscar mike",
"Beep me at 555 (not a real area code) then 867-5309",
"I'm on that app where messages disappear, username: GhostWriter99",
"Reach out via electronic mail to 'surname underscore initial' at that fruit company dot com",
"Call me maybe? Area code is square root of 169, then 555-CHAT",
]
url = "https://vidhitmakvana1-contact-sharing-recognizer-api.hf.space/detect_contact"
for text in test_texts:
payload = {"text": text}
headers = {"Content-Type": "application/json"}
response = requests.post(url, data=json.dumps(payload), headers=headers)
if response.status_code == 200:
result = response.json()
print(f"Text: {result['text']}")
print(f"Contact Probability: {result['contact_probability']:.4f}")
print(f"Is Contact Info: {result['is_contact_info']}")
print("---")
else:
print(f"Error for text: {text}")
print(f"Status code: {response.status_code}")
print(f"Response: {response.text}")
print("---")
|