Update app.py
Browse files
app.py
CHANGED
@@ -19,27 +19,27 @@ from PyPDF2 import PdfReader
|
|
19 |
from gliner import GLiNER
|
20 |
|
21 |
txt = st.text_area("Job description")
|
|
|
|
|
22 |
|
23 |
uploaded_files = st.file_uploader(
|
24 |
"Choose a PDF file(s) and job description as pdf", accept_multiple_files=True, type="pdf"
|
25 |
)
|
26 |
|
27 |
-
|
28 |
-
all_data = []
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
for page in pdf_reader.pages:
|
34 |
-
text_data += page.extract_text()
|
35 |
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
|
44 |
data = {"Text": text_data, **entity_dict}
|
45 |
|
@@ -48,17 +48,14 @@ if uploaded_files:
|
|
48 |
|
49 |
all_data.append(data)
|
50 |
|
51 |
-
|
52 |
-
st.error(f"Error processing file {uploaded_file.name}: {e}")
|
53 |
|
54 |
|
55 |
if all_data:
|
56 |
df = pd.DataFrame(all_data)
|
57 |
st.dataframe(df)
|
58 |
|
59 |
-
|
60 |
-
result = pd.concat([df, data1], axis=1, ignore_index=True)
|
61 |
-
st.dataframe(result)
|
62 |
|
63 |
|
64 |
|
|
|
19 |
from gliner import GLiNER
|
20 |
|
21 |
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 |
+
for uploaded_file in uploaded_files:
|
30 |
+
all_data = []
|
31 |
+
pdf_reader = PdfReader(uploaded_file)
|
32 |
+
text_data = ""
|
33 |
+
for page in pdf_reader.pages:
|
34 |
+
text_data += page.extract_text()
|
|
|
|
|
35 |
|
36 |
+
model = GLiNER.from_pretrained("urchade/gliner_base")
|
37 |
+
labels = ["person", "country", "organization", "time", "role"]
|
38 |
+
entities = model.predict_entities(text_data, labels)
|
39 |
|
40 |
+
entity_dict = {}
|
41 |
+
for label in labels:
|
42 |
+
entity_dict[label] = [entity["text"] for entity in entities if entity["label"] == label]
|
43 |
|
44 |
data = {"Text": text_data, **entity_dict}
|
45 |
|
|
|
48 |
|
49 |
all_data.append(data)
|
50 |
|
51 |
+
|
|
|
52 |
|
53 |
|
54 |
if all_data:
|
55 |
df = pd.DataFrame(all_data)
|
56 |
st.dataframe(df)
|
57 |
|
58 |
+
|
|
|
|
|
59 |
|
60 |
|
61 |
|