|
import asyncio |
|
import aiohttp |
|
import json |
|
from tqdm.asyncio import tqdm |
|
|
|
test_texts = [ |
|
"You can reach me at triple eight, then the square of 7, followed by 2^10", |
|
"Drop a line to first_name [underscore] last_name at that company with a fruit logo dot com", |
|
"Find me on the platform where professionals connect: J. Doe, Senior Developer at TechCorp", |
|
"Message me on that app with the ghost icon: @ShadowWhisperer2023", |
|
"Contact via carrier pigeon: coordinates 40.7128° N, 74.0060° W", |
|
"Ping me on the federated network: @[email protected]", |
|
"My contact is the reverse of moc.elpmaxe@eodnhoj", |
|
"Reach out using morse: -... -.-- -....- . -- .- .. .-..", |
|
"Find me on the platform with blue checkmarks: @RealJohnDoe (parody)", |
|
"Send a message to username 'l33tc0d3r' on that platform for developers", |
|
"You can locate me at the place where the streets have no name, in the city of angels", |
|
"My digits are the Fibonacci sequence up to 21, concatenated", |
|
"Contact: foxtrot oscar oscar at bravo alpha romeo dot charlie oscar mike", |
|
"Beep me at the number you get when you multiply 555 by 1.5, then add 867-5309", |
|
"I'm on that app where you share shortvideos: @Dancing2023", |
|
"Reach out via electronic mail to 'lastnamefirstinitial' at that search engine company dot com", |
|
"Call me at the number you get when you solve this equation: 2x + 5 = 13, then 555-MATH", |
|
"My handle on that photo-sharing app is @SunsetSnapper_42", |
|
"You can find me at the intersection of Binary Boulevard and Algorithm Avenue", |
|
"Contact info: romeo oscar charlie kilo echo tango mike alpha november at zulu uniform lima uniform dot india oscar", |
|
"Find me at 51.4778° N, and solve for x: x - 0.0019 = 0.1278° W", |
|
"DM me at 📧👤💻🐦. Guess the platform 😉", |
|
"If you add 2 to the area code of Los Angeles, you'll find the first 3 digits of my number", |
|
"Ping me on the platform with 2 birds in its logo (and no, it's not a zoo!)", |
|
"You can decode my email address: base64 for JmRvZGVAc2FtcGxlLmNvbQ==", |
|
"You’ll find me on the platform that rhymes with 'squeaker' and involves chirps", |
|
"If you reverse the letters of com.gmail@john and remove 'moc', you'll get my contact", |
|
"For inquiries, try contacting me at 'first name.last name', but think of the sound fruit makes when it's dropped", |
|
"Use morse to reach out: dash dot dot dash underscore underscore dash dot dot (first name at techcorp dot com)", |
|
"Contact: solve 5x - 3 = 12 for x, that’s my lucky number for the area code, followed by the square root of 144 for the rest", |
|
"Reach out on that site where professionals connect, my name rhymes with 'noe' and I’m a senior engineer at T-Corp", |
|
"Shoot me a message on the photo-sharing app where sunsets get all the likes: handle is the same as my name in reverse", |
|
"If you count the number of words in 'five stars' you'll get the first two digits of my handle on that coding platform", |
|
"My email is hidden: find the cube root of 27, followed by the first name of a famous fruit and 'dot com'", |
|
"If you multiply the number of days in March by 5, you'll get my contact digits", |
|
"Contact me on the short-video app, my handle starts with a 'D' and ends with '23'!", |
|
"Try to find me where algorithms reign and the search begins: think of a query that contains my last name and 'solutions'", |
|
"Use binary to get my location: 01000101 01001110 01000111", |
|
"You can ping me at 'bestcoder42' on the app where code flows like water", |
|
"My digits: sum of first four Fibonacci numbers for the area code, and the next three for the phone number", |
|
"Find me at 51.4778° N, and solve for x: x - 0.0019 = 0.1278° W", |
|
"DM me at 📧👤💻🐦. Guess the platform 😉", |
|
"If you add 2 to the area code of Los Angeles, you'll find the rest of my digits hiding nearby", |
|
"Ping me at 'FirstnameLastname reversed' at that search company 🧐", |
|
"The sum of the first two primes gives you the first part of my number, and 10 squared gets you the rest", |
|
"Drop a message on the 'app named after a bird' to @JohnDoe2024 🌐", |
|
"Morse this one: .... . .-.. .-.. --- @ secret-agent", |
|
"Let’s connect: 3rd letter of my last name, then an underscore, then my birth year at fruit-company dot com 🍏", |
|
"I'm on the platform for professionals but my handle is just a smiley face, hint hint 😉", |
|
"Look up the coordinates of Big Ben and you might just find where I hang out 🕰️", |
|
"Combine the atomic number of helium with my favorite fruit and you'll get my email", |
|
"Find me at 'underscore emoji fan' at the app where people share funny short videos 🤳", |
|
"Think of the number 404, then multiply it by 2, that’s the area code. The rest is easy!", |
|
"I'm always up for a chat, just decode 01000011 01100001 01101100 01101100", |
|
"I’m @SilentWhisper42 on the app where conversations vanish into thin air 👻", |
|
"Track me down with this: Alpha-Bravo-Charlie at that company with flying machines ✈️", |
|
"Ever heard of Fibonacci? My digits follow the pattern, up to 21", |
|
"Search for the name of the singer of 'Rocket Man,' and you'll have part of my contact info 🧑🚀", |
|
"Just send a message to 'TechWizard' at the email service that rhymes with whale-mail 🐋", |
|
"My username on that site for devs is 'leet_hacker', but you’ll need to solve for x to figure out the rest!", |
|
"My digits? Picture the number of planets in the solar system before 2006, then square it.", |
|
"If you know the atomic numbers of oxygen and hydrogen, combine them and you have my first two digits.", |
|
"Contact me where knowledge is power, at the symbol of illumination followed by 'dot org'.", |
|
"I'm @user and you'll find me on the app where one tweets, but reverse that bird's sound first.", |
|
"Think of the area code for New York, subtract one, and you’re almost there.", |
|
"Reach out at 'wizard@', then imagine the home of the brave and the land of the free, followed by 'com'.", |
|
"My handle is a palindrome on that platform where people share their lives one square at a time.", |
|
"Find me at the intersection of 7 squared and the cube root of 8, you'll know the digits.", |
|
"Ping me at 'Firstname reversed' dot 'company with a shopping cart logo'.", |
|
"Send a message to the name of the president in 1993 at the platform where developers share code.", |
|
"You can reach me at the number that shares its name with a famous Chicago bull, then add 10.", |
|
"Reach out on the platform with the blue checkmarks, where I’m known as '56/8'.", |
|
"The username is easy if you know your ASCII: 83 117 110 83 101 116 52 50.", |
|
"For contact info, divide the year Armstrong walked on the moon by two and add the last prime number.", |
|
"You can email me at the world's largest retailer with a name that rhymes with 'Hamazon'.", |
|
"Catch me on the app where professionals hang out: it’s the opposite of 'InTouch'.", |
|
"Look for me on the 'bird app' where my handle is my initials followed by the number of days in a leap year.", |
|
"Ping me at 'Jupiter's largest moon' dot 'the company that sends rockets into space'.", |
|
"Reach out at the sum of the angles in a triangle, followed by 'degrees at mail dot com'.", |
|
"Message me where bytes are shared: I go by '@user_hexadecimal_4D2' on that site.", |
|
"You can send it to 🌍 world_dot_explorer @ 'web page where you explore the world'.", |
|
"数字 4 (Chinese), then 'underscore', then 'techie' at the search giant.", |
|
"Write to me at the country with a maple leaf symbol, at their email provider.", |
|
"Feel free to ping me at Жака at mail dot ru (that’s Russian for Jack).", |
|
"If you take the French word for 'sun' and add 'shine', that’s where you can reach me.", |
|
"My digits? They hide in plain sight: 42-4*8+18. Just subtract the stars.", |
|
"Drop me a line at 'developer' followed by the country code for India, dot com.", |
|
"Where to find me? It's obvious: 'who's' dot 'this', at the dot that ends with 'gov'.", |
|
"A long story short: email me at 'fruit-company', the one that used to be a tree 🌳.", |
|
"You'll get my email by figuring out: my first pet’s name, the city I grew up in, dot org.", |
|
"My number? It's encrypted as SHA-256. Just decode it and you'll know!", |
|
"Write to me in the ancient language of the Romans: 'maximus at something_prime dot com'.", |
|
"Reach out to the winner of 2022's football world cup at 'world champions dot com'.", |
|
"Find me at the place where the Eiffel Tower stands tall, at dot 'home of baguettes'.", |
|
"Hit me up via snail mail: Just translate 'rabbit' into Italian and add 'at Italian mail'.", |
|
"My digits form a prime sequence starting from 11, just keep counting!", |
|
"For my number, follow the clues hidden in Da Vinci's most famous painting." |
|
|
|
] |
|
import time |
|
|
|
url = "http://localhost:8000/batch_detect_contact" |
|
|
|
async def process_batch(session, texts): |
|
payload = {"texts": texts} |
|
headers = {"Content-Type": "application/json"} |
|
|
|
start_time = time.time() |
|
async with session.post(url, data=json.dumps(payload), headers=headers) as response: |
|
if response.status == 200: |
|
results = await response.json() |
|
end_time = time.time() |
|
for result in results: |
|
result['response_time'] = (end_time - start_time) / len(texts) |
|
return results |
|
else: |
|
print(f"Error for batch") |
|
print(f"Status code: {response.status}") |
|
print(f"Response: {await response.text()}") |
|
return None |
|
|
|
async def main(): |
|
|
|
inflated_texts = test_texts * 100 |
|
|
|
async with aiohttp.ClientSession() as session: |
|
batch_size = 1000 |
|
batches = [inflated_texts[i:i + batch_size] for i in range(0, len(inflated_texts), batch_size)] |
|
|
|
tasks = [process_batch(session, batch) for batch in batches] |
|
all_results = await tqdm.gather(*tasks) |
|
|
|
results = [item for sublist in all_results for item in sublist if sublist] |
|
|
|
correct_predictions = 0 |
|
total_predictions = len(results) |
|
total_response_time = 0 |
|
|
|
for result in results: |
|
if result: |
|
print(f"Text: {result['text']}") |
|
print(f"Is Contact Info: {result['is_contact_info']}") |
|
print(f"Method: {result['method']}") |
|
print(f"Response Time: {result['response_time']:.4f} seconds") |
|
print("---") |
|
|
|
|
|
if result['is_contact_info']: |
|
correct_predictions += 1 |
|
|
|
total_response_time += result['response_time'] |
|
|
|
accuracy = correct_predictions / total_predictions |
|
average_response_time = total_response_time / total_predictions |
|
print(f"Accuracy: {accuracy:.2f}") |
|
print(f"Average Response Time: {average_response_time:.4f} seconds") |
|
|
|
if __name__ == "__main__": |
|
while True: |
|
asyncio.run(main()) |
|
|