#%%
import pandas as pd
import numpy as np

# --- Seed for reproducibility ---
np.random.seed(42)

# --- Data sources ---
names = [
    "Olivia Martinez", "Liam Johnson", "Sophia Anderson", "Ethan Roberts",
    "Ava Thompson", "Noah Williams", "Isabella Davis", "Mason Brown",
    "Mia Wilson", "Lucas Taylor", "Amelia Moore", "James Harris",
    "Harper Clark", "Benjamin Lewis", "Evelyn Walker"
]

edu_profiles = [
    {"role": "Undergraduate", "organization": "Harvard University", "domain": "harvard.edu"},
    {"role": "Undergraduate", "organization": "Stanford University", "domain": "stanford.edu"},
    {"role": "Undergraduate", "organization": "MIT", "domain": "mit.edu"},
    {"role": "Undergraduate", "organization": "UC Berkeley", "domain": "berkeley.edu"},
    {"role": "Undergraduate", "organization": "Caltech", "domain": "caltech.edu"},
    {"role": "Undergraduate", "organization": "UChicago", "domain": "uchicago.edu"},
    {"role": "Undergraduate", "organization": "Princeton University", "domain": "princeton.edu"},
    {"role": "Undergraduate", "organization": "Yale University", "domain": "yale.edu"},
    {"role": "Undergraduate", "organization": "Columbia University", "domain": "columbia.edu"},
    {"role": "Undergraduate", "organization": "UPenn", "domain": "upenn.edu"},
    {"role": "Undergraduate", "organization": "Cornell University", "domain": "cornell.edu"},
    {"role": "Undergraduate", "organization": "UCLA", "domain": "ucla.edu"},
    {"role": "Undergraduate", "organization": "University of Michigan", "domain": "umich.edu"},
    {"role": "Undergraduate", "organization": "Duke University", "domain": "duke.edu"},
    {"role": "Undergraduate", "organization": "NYU", "domain": "nyu.edu"}
]

non_edu_profiles = [
    {"role": "Software Engineer", "organization": "Google", "domain": "gmail.com"},
    {"role": "Data Analyst", "organization": "Facebook", "domain": "gmail.com"},
    {"role": "Marketing Manager", "organization": "Amazon", "domain": "gmail.com"},
    {"role": "Financial Analyst", "organization": "Goldman Sachs", "domain": "gmail.com"},
    {"role": "Project Manager", "organization": "Microsoft", "domain": "gmail.com"},
    {"role": "UX Designer", "organization": "Apple", "domain": "gmail.com"},
    {"role": "Consultant", "organization": "Deloitte", "domain": "gmail.com"},
    {"role": "Product Manager", "organization": "Salesforce", "domain": "gmail.com"},
    {"role": "Business Analyst", "organization": "IBM", "domain": "gmail.com"},
    {"role": "Cybersecurity Specialist", "organization": "Cisco", "domain": "gmail.com"},
    {"role": "Content Strategist", "organization": "Netflix", "domain": "gmail.com"},
    {"role": "Systems Administrator", "organization": "Intel", "domain": "gmail.com"},
    {"role": "Human Resources Manager", "organization": "Adobe", "domain": "gmail.com"},
    {"role": "Software Architect", "organization": "Oracle", "domain": "gmail.com"},
    {"role": "Operations Manager", "organization": "LinkedIn", "domain": "gmail.com"}
]


# --- Config ---
n_samples = 100  # number of unique names per edu/non-edu
patterns = [
    lambda first, last, num: f"{first}.{last}{num}",
    lambda first, last, num: f"{first[0]}{last}{num}",
    lambda first, last, num: f"{first}{last[0]}{num}"
]

# --- Deterministic sampling ---
edu_indices = np.tile(np.arange(len(edu_profiles)), int(np.ceil(n_samples / len(edu_profiles))))[:n_samples]
non_edu_indices = np.tile(np.arange(len(non_edu_profiles)), int(np.ceil(n_samples / len(non_edu_profiles))))[:n_samples]

edu_names = np.random.choice(names, size=n_samples, replace=True)
non_edu_names = np.random.choice(names, size=n_samples, replace=True)

# --- Email generator ---
def create_email(name, domain, pattern_idx):
    first, last = name.split(" ")
    num = str(abs(hash(name + domain)))[:2]  # deterministic two-digit number
    return patterns[pattern_idx](first.lower(), last.lower(), num) + "@" + domain

# --- Build dataframe ---
rows = []
for i in range(n_samples):
    edu_profile = edu_profiles[edu_indices[i]]
    non_edu_profile = non_edu_profiles[non_edu_indices[i]]
    
    # deterministic pattern selection
    pattern_idx = i % len(patterns)
    
    rows.append({
        "name": edu_names[i],
        "email": create_email(edu_names[i], edu_profile["domain"], pattern_idx),
        "role": edu_profile["role"],
        "organization": edu_profile["organization"],
        "has_edu_domain": True
    })
    rows.append({
        "name": non_edu_names[i],
        "email": create_email(non_edu_names[i], non_edu_profile["domain"], pattern_idx),
        "role": non_edu_profile["role"],
        "organization": non_edu_profile["organization"],
        "has_edu_domain": False
    })

df = pd.DataFrame(rows)

# --- Save ---
df.to_csv("profiles.csv", index=False)
print(df.head())

# %%
