File size: 1,609 Bytes
c3efe69
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 gradio as gr
import json
import random

# Sample ML Model Simulation
def ml_model_evaluate(application_text):
    # Simulating ML-based approval (Adjust as per real model)
    keywords = ["experience", "Python", "ML", "AI", "certification"]
    score = sum(1 for word in keywords if word.lower() in application_text.lower())
    return score >= 3  # Approve if at least 3 keywords match

# Job Application Processing Function
def process_application(user_id, application_text):
    # Check if the user exists (simulated with JSON storage)
    try:
        with open("applications.json", "r") as file:
            applications = json.load(file)
    except FileNotFoundError:
        applications = {}

    if str(user_id) in applications:
        return f"⚠️ You have already applied. Please wait for approval."

    # ML Model Decision
    approved = ml_model_evaluate(application_text)

    if approved:
        applications[str(user_id)] = "Approved"
        with open("applications.json", "w") as file:
            json.dump(applications, file)
        return f"✅ Application Approved! You are eligible for job postings."
    else:
        return f"❌ Application Rejected. Improve details and resubmit."

# Gradio UI
iface = gr.Interface(
    fn=process_application,
    inputs=["text", "text"],
    outputs="text",
    title="AI Job Application Approval System",
    description="Submit your job application. If everything is correct, it will be approved automatically!",
    examples=[["2345", "I have experience in AI, Python, and ML."]],
)

if __name__ == "__main__":
    iface.launch()