Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -44,8 +44,8 @@ def process_pdf(path):
|
|
| 44 |
return results_dict
|
| 45 |
|
| 46 |
def read_section(path, wanted_section, next_section):
|
| 47 |
-
|
| 48 |
-
doc = pdfplumber.open(path)
|
| 49 |
start_page = []
|
| 50 |
end_page = []
|
| 51 |
|
|
@@ -54,9 +54,9 @@ def read_section(path, wanted_section, next_section):
|
|
| 54 |
start_page.append(page)
|
| 55 |
if len(doc.pages[page].search(next_section, return_chars = False, case = False)) > 0:
|
| 56 |
end_page.append(page)
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
|
| 61 |
text = []
|
| 62 |
for page_num in range(max(start_page), max(end_page)+1):
|
|
@@ -138,6 +138,7 @@ def extract_details(path):
|
|
| 138 |
results["Section 4.2 summary"] = summarize_german_text(sections_dict["4.2 Umgesetzte Maßnahmen / Aktivitäten während des Berichtszeitraums"])
|
| 139 |
results["Section 4.6 summary"] = summarize_german_text(sections_dict["4.6 Bewertung der Wirkungen und Risiken"])
|
| 140 |
results["Section 5.1 summary"] = summarize_german_text(sections_dict["5. Übergeordnete Empfehlungen"])
|
|
|
|
| 141 |
# for key, answer in results.items():
|
| 142 |
# print(f"{key}: {answer}")
|
| 143 |
|
|
|
|
| 44 |
return results_dict
|
| 45 |
|
| 46 |
def read_section(path, wanted_section, next_section):
|
| 47 |
+
|
| 48 |
+
doc = pdfplumber.open(BytesIO(path))
|
| 49 |
start_page = []
|
| 50 |
end_page = []
|
| 51 |
|
|
|
|
| 54 |
start_page.append(page)
|
| 55 |
if len(doc.pages[page].search(next_section, return_chars = False, case = False)) > 0:
|
| 56 |
end_page.append(page)
|
| 57 |
+
print(wanted_section)
|
| 58 |
+
print(max(start_page))
|
| 59 |
+
print(max(end_page)+1)
|
| 60 |
|
| 61 |
text = []
|
| 62 |
for page_num in range(max(start_page), max(end_page)+1):
|
|
|
|
| 138 |
results["Section 4.2 summary"] = summarize_german_text(sections_dict["4.2 Umgesetzte Maßnahmen / Aktivitäten während des Berichtszeitraums"])
|
| 139 |
results["Section 4.6 summary"] = summarize_german_text(sections_dict["4.6 Bewertung der Wirkungen und Risiken"])
|
| 140 |
results["Section 5.1 summary"] = summarize_german_text(sections_dict["5. Übergeordnete Empfehlungen"])
|
| 141 |
+
return results
|
| 142 |
# for key, answer in results.items():
|
| 143 |
# print(f"{key}: {answer}")
|
| 144 |
|