Spaces:
Sleeping
Sleeping
Update components/upload.py
Browse files- components/upload.py +14 -4
components/upload.py
CHANGED
|
@@ -1,5 +1,5 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
-
|
| 3 |
from src.metadata_extractor import extract_metadata
|
| 4 |
from src.pdf_parser import extract_text_from_pdf
|
| 5 |
|
|
@@ -40,9 +40,19 @@ def upload_section():
|
|
| 40 |
# ---------------------------------------
|
| 41 |
# Extract Metadata
|
| 42 |
# ---------------------------------------
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 46 |
# Reset file pointer
|
| 47 |
file.seek(0)
|
| 48 |
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
+
from src.grobid import extract_metadata_grobid
|
| 3 |
from src.metadata_extractor import extract_metadata
|
| 4 |
from src.pdf_parser import extract_text_from_pdf
|
| 5 |
|
|
|
|
| 40 |
# ---------------------------------------
|
| 41 |
# Extract Metadata
|
| 42 |
# ---------------------------------------
|
| 43 |
+
try:
|
| 44 |
+
meta = extract_metadata_grobid(file)
|
| 45 |
+
except error:
|
| 46 |
+
meta = {
|
| 47 |
+
|
| 48 |
+
"title": file.name.replace(".pdf", ""),
|
| 49 |
+
|
| 50 |
+
"authors": ["Unknown"],
|
| 51 |
+
|
| 52 |
+
"abstract": ""
|
| 53 |
+
|
| 54 |
+
}
|
| 55 |
+
|
| 56 |
# Reset file pointer
|
| 57 |
file.seek(0)
|
| 58 |
|