Alexander Hux commited on
Commit ·
b6a1908
1
Parent(s): 13858f1
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
import PyPDF2
|
| 3 |
+
from io import BytesIO
|
| 4 |
+
|
| 5 |
+
keywords = ["Youth Development", "Teacher", "Childcare Assistant",
|
| 6 |
+
"Afterschool Counselor", "summer camp leader"]
|
| 7 |
+
|
| 8 |
+
def extract_text_from_pdf(file):
|
| 9 |
+
pdf_file_obj = BytesIO(file)
|
| 10 |
+
pdf_reader = PyPDF2.PdfFileReader(pdf_file_obj)
|
| 11 |
+
text = ''
|
| 12 |
+
for page_num in range(pdf_reader.numPages):
|
| 13 |
+
page_obj = pdf_reader.getPage(page_num)
|
| 14 |
+
text += page_obj.extractText()
|
| 15 |
+
return text
|
| 16 |
+
|
| 17 |
+
def KeywordExtractor(file):
|
| 18 |
+
text = extract_text_from_pdf(file)
|
| 19 |
+
found_keywords = [keyword for keyword in keywords if keyword.lower() in text.lower()]
|
| 20 |
+
return found_keywords
|
| 21 |
+
|
| 22 |
+
description_text = "Extract relevant keywords from a resume. Created by A. Leschik."
|
| 23 |
+
|
| 24 |
+
demo = gr.Interface(fn=KeywordExtractor, inputs=gr.inputs.File(label="Upload a PDF"), outputs="textbox", title="Resume Keyword Extractor", description=description_text)
|
| 25 |
+
|
| 26 |
+
if __name__ == "__main__":
|
| 27 |
+
demo.launch()
|