Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -18,43 +18,47 @@ Parameters:
|
|
18 |
Returns:
|
19 |
- text (str): The extracted text from the specified section range.
|
20 |
"""
|
21 |
-
def get_section(path, wanted_section, next_section):
|
22 |
-
|
23 |
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
|
51 |
|
52 |
def process_pdf(path):
|
53 |
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
|
|
|
|
|
|
|
|
58 |
results_dict["2.1 Aktualisierte Einordnung des Moduls in das EZ-Programm"] = \
|
59 |
get_section(path,"2.1 Aktualisierte Einordnung des Moduls in das EZ-Programm", "2.2 Andere Entwicklungsmaßnahmen im konkreten Interventionsbereich des Moduls")
|
60 |
results_dict["2.2 Andere Entwicklungsmaßnahmen im konkreten Interventionsbereich des Moduls"] = \
|
|
|
18 |
Returns:
|
19 |
- text (str): The extracted text from the specified section range.
|
20 |
"""
|
21 |
+
# def get_section(path, wanted_section, next_section):
|
22 |
+
# print(wanted_section)
|
23 |
|
24 |
+
# # Open the PDF file
|
25 |
+
# doc = pdfplumber.open(path)
|
26 |
+
# start_page = []
|
27 |
+
# end_page = []
|
28 |
|
29 |
+
# # Find the all the pages for the specified sections
|
30 |
+
# for page in range(len(doc.pages)):
|
31 |
+
# if len(doc.pages[page].search(wanted_section, return_chars = False, case = False)) > 0:
|
32 |
+
# start_page.append(page)
|
33 |
+
# if len(doc.pages[page].search(next_section, return_chars = False, case = False)) > 0:
|
34 |
+
# end_page.append(page)
|
35 |
+
# print(max(start_page))
|
36 |
+
# print(max(end_page))
|
37 |
|
38 |
+
# # Extract the text between the start and end page of the wanted section
|
39 |
+
# text = []
|
40 |
+
# for page_num in range(max(start_page), max(end_page)):
|
41 |
+
# page = doc.pages[page_num]
|
42 |
+
# text.append(page.extract_text())
|
43 |
+
# text = " ".join(text)
|
44 |
+
# new_text = text.replace("\n", " ")
|
45 |
+
# special_char_unicode_list = ["\u00e4", "\u00f6", "\u00fc", "\u00df"]
|
46 |
+
# special_char_replacement_list = ["ae", "oe", "ue", "ss"]
|
47 |
+
# for index, special_char in enumerate(special_char_unicode_list):
|
48 |
+
# final_text = new_text.replace(special_char, special_char_replacement_list[index])
|
49 |
+
# return final_text
|
50 |
|
51 |
|
52 |
def process_pdf(path):
|
53 |
|
54 |
+
doc = pdfplumber.open(path)
|
55 |
+
|
56 |
+
return doc
|
57 |
+
|
58 |
+
# results_dict = {}
|
59 |
+
# results_dict["2.1 Aktualisierte Einordnung des Moduls in das EZ-Programm"] = \
|
60 |
+
# get_section(path, "2.1 Aktualisierte Einordnung des Moduls in das EZ-Programm", "2.2 Andere Entwicklungsmaßnahmen im konkreten Interventionsbereich des Moduls")
|
61 |
+
"""
|
62 |
results_dict["2.1 Aktualisierte Einordnung des Moduls in das EZ-Programm"] = \
|
63 |
get_section(path,"2.1 Aktualisierte Einordnung des Moduls in das EZ-Programm", "2.2 Andere Entwicklungsmaßnahmen im konkreten Interventionsbereich des Moduls")
|
64 |
results_dict["2.2 Andere Entwicklungsmaßnahmen im konkreten Interventionsbereich des Moduls"] = \
|