KrishGoyani commited on
Commit
e14a9fb
·
verified ·
1 Parent(s): d9d50b8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -5
app.py CHANGED
@@ -72,7 +72,8 @@ def pdf2text(file_path):
72
  return clean_text(text)
73
 
74
 
75
- def ner(text) :
 
76
  return {
77
  "text": text,
78
  "entities": [
@@ -84,14 +85,14 @@ def ner(text) :
84
  "score": 0,
85
  }
86
  for entity in model.predict_entities(
87
- text, labels, flat_ner=False, threshold=0.27
88
  )
89
  ],
90
  }
91
 
92
- def parser(file_path):
93
  text = pdf2text(file_path)
94
- return ner(text)
95
 
96
 
97
  # Define a custom CSS style
@@ -121,7 +122,25 @@ h1 {
121
  with gr.Blocks(css=custom_css) as demo:
122
  gr.HTML("<h1>AI-Powered Resume Parser</h1>")
123
  gr.HTML("<p style='text-align: center;'>This tool uses advanced NLP techniques to extract key information from your resume.</p>")
 
124
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
125
  with gr.Row():
126
  file_input = gr.File(label="Upload Resume",
127
  file_types=['.pdf'],
@@ -136,7 +155,7 @@ with gr.Blocks(css=custom_css) as demo:
136
  combine_adjacent=True
137
  )
138
 
139
- parse_button.click(fn=parser, inputs=file_input, outputs=output)
140
 
141
  gr.HTML("<p style='text-align: center;'>Our resume parser can identify and extract important details such as personal information, education, work experience, skills, and more. Simply upload your resume and let our AI do the work!</p>")
142
 
 
72
  return clean_text(text)
73
 
74
 
75
+ def ner(text, labels, threshold) :
76
+ labels = labels.split(",")
77
  return {
78
  "text": text,
79
  "entities": [
 
85
  "score": 0,
86
  }
87
  for entity in model.predict_entities(
88
+ text, labels, flat_ner=False, threshold=threshold
89
  )
90
  ],
91
  }
92
 
93
+ def parser(file_path, labels):
94
  text = pdf2text(file_path)
95
+ return ner(text, labels, threshold)
96
 
97
 
98
  # Define a custom CSS style
 
122
  with gr.Blocks(css=custom_css) as demo:
123
  gr.HTML("<h1>AI-Powered Resume Parser</h1>")
124
  gr.HTML("<p style='text-align: center;'>This tool uses advanced NLP techniques to extract key information from your resume.</p>")
125
+
126
 
127
+ with gr.Row() as row:
128
+ labels = gr.Textbox(
129
+ value=examples[0][1],
130
+ label="Labels",
131
+ placeholder="Enter your labels here (comma separated)",
132
+ scale=1,
133
+ )
134
+ threshold = gr.Slider(
135
+ 0,
136
+ 1,
137
+ value=0.3,
138
+ step=0.01,
139
+ label="Threshold",
140
+ info="Lower the threshold to increase how many entities get predicted.",
141
+ scale=0,
142
+ )
143
+
144
  with gr.Row():
145
  file_input = gr.File(label="Upload Resume",
146
  file_types=['.pdf'],
 
155
  combine_adjacent=True
156
  )
157
 
158
+ parse_button.click(fn=parser, inputs=[file_input,labels, threshold], outputs=output)
159
 
160
  gr.HTML("<p style='text-align: center;'>Our resume parser can identify and extract important details such as personal information, education, work experience, skills, and more. Simply upload your resume and let our AI do the work!</p>")
161