Update app.py
Browse files
app.py
CHANGED
@@ -22,28 +22,38 @@ txt = st.text_area("Job description")
|
|
22 |
data1 = pd.Series(txt, index = ["Job Description"])
|
23 |
st.dataframe(data1)
|
24 |
|
|
|
|
|
25 |
uploaded_files = st.file_uploader(
|
26 |
"Choose a PDF file(s) and job description as pdf", accept_multiple_files=True, type="pdf"
|
27 |
)
|
28 |
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
|
|
|
|
35 |
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
|
44 |
data = {"Text": text_data, **entity_dict}
|
45 |
-
|
46 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
47 |
|
48 |
|
49 |
|
|
|
22 |
data1 = pd.Series(txt, index = ["Job Description"])
|
23 |
st.dataframe(data1)
|
24 |
|
25 |
+
|
26 |
+
|
27 |
uploaded_files = st.file_uploader(
|
28 |
"Choose a PDF file(s) and job description as pdf", accept_multiple_files=True, type="pdf"
|
29 |
)
|
30 |
|
31 |
+
if uploaded_files:
|
32 |
+
all_data = [] # Store dictionaries of text and entities for each PDF
|
33 |
+
for uploaded_file in uploaded_files:
|
34 |
+
try:
|
35 |
+
pdf_reader = PdfReader(uploaded_file)
|
36 |
+
text_data = ""
|
37 |
+
for page in pdf_reader.pages:
|
38 |
+
text_data += page.extract_text()
|
39 |
|
40 |
+
model = GLiNER.from_pretrained("urchade/gliner_base")
|
41 |
+
labels = ["person", "country", "organization", "time", "role"]
|
42 |
+
entities = model.predict_entities(text_data, labels)
|
43 |
|
44 |
+
entity_dict = {}
|
45 |
+
for label in labels:
|
46 |
+
entity_dict[label] = [entity["text"] for entity in entities if entity["label"] == label]
|
47 |
|
48 |
data = {"Text": text_data, **entity_dict}
|
49 |
+
all_data.append(data)
|
50 |
+
|
51 |
+
except Exception as e:
|
52 |
+
st.error(f"Error processing file {uploaded_file.name}: {e}")
|
53 |
+
|
54 |
+
if all_data:
|
55 |
+
df = pd.DataFrame(all_data)
|
56 |
+
st.dataframe(df)
|
57 |
|
58 |
|
59 |
|