TKM03 commited on
Commit
8bfd778
·
verified ·
1 Parent(s): 069bc7e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -13
app.py CHANGED
@@ -4,10 +4,8 @@ import gradio as gr
4
  from transformers import pipeline
5
  from collections import Counter
6
 
7
- # Load NER pipeline
8
  ner_pipeline = pipeline("ner", model="dslim/bert-base-NER", tokenizer="dslim/bert-base-NER", aggregation_strategy="simple")
9
-
10
- # Load NEW job classifier with human-readable labels
11
  text_classifier = pipeline("text-classification", model="tkuye/job-description-classifier")
12
 
13
  def clean_resume_text(text):
@@ -60,15 +58,14 @@ def process_resumes(files):
60
  entities = ner_pipeline(cleaned_text)
61
  classification = classify_resume_ner(entities)
62
 
63
- all_results[file_name] = {
64
- "Persons": list({e["word"] for e in entities if e["entity_group"] == "PER"}),
65
- "Organizations": list({e["word"] for e in entities if e["entity_group"] == "ORG"}),
66
- "Locations": list({e["word"] for e in entities if e["entity_group"] == "LOC"}),
67
- "Other Entities": list({e["word"] for e in entities if e["entity_group"] not in ["PER", "ORG", "LOC"]}),
68
- "Cleaned_Text": cleaned_text,
69
- "Classification (NER)": classification
70
- }
71
-
72
  return all_results
73
 
74
  def classify_resumes_with_model(files):
@@ -80,7 +77,7 @@ def classify_resumes_with_model(files):
80
  predictions[file_name] = {"error": error}
81
  continue
82
  cleaned_text = clean_resume_text(resume_text)
83
- result = text_classifier(cleaned_text[:512])
84
  predictions[file_name] = {
85
  "Predicted Job Category": result[0]['label'],
86
  "Confidence Score": round(result[0]['score'], 4)
 
4
  from transformers import pipeline
5
  from collections import Counter
6
 
7
+ # Load pipelines
8
  ner_pipeline = pipeline("ner", model="dslim/bert-base-NER", tokenizer="dslim/bert-base-NER", aggregation_strategy="simple")
 
 
9
  text_classifier = pipeline("text-classification", model="tkuye/job-description-classifier")
10
 
11
  def clean_resume_text(text):
 
58
  entities = ner_pipeline(cleaned_text)
59
  classification = classify_resume_ner(entities)
60
 
61
+ all_results[file_name] = {
62
+ "Persons": list({e["word"] for e in entities if e["entity_group"] == "PER"}),
63
+ "Organizations": list({e["word"] for e in entities if e["entity_group"] == "ORG"}),
64
+ "Locations": list({e["word"] for e in entities if e["entity_group"] == "LOC"}),
65
+ "Other Entities": list({e["word"] for e in entities if e["entity_group"] not in ["PER", "ORG", "LOC"]}),
66
+ "Cleaned_Text": cleaned_text,
67
+ "Classification (NER)": classification
68
+ }
 
69
  return all_results
70
 
71
  def classify_resumes_with_model(files):
 
77
  predictions[file_name] = {"error": error}
78
  continue
79
  cleaned_text = clean_resume_text(resume_text)
80
+ result = text_classifier(cleaned_text[:512]) # Truncate long resumes
81
  predictions[file_name] = {
82
  "Predicted Job Category": result[0]['label'],
83
  "Confidence Score": round(result[0]['score'], 4)