andreeabodea commited on
Commit
87af43d
·
verified ·
1 Parent(s): 29399bd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -9
app.py CHANGED
@@ -6,8 +6,8 @@ import re
6
  import fitz # PyMuPDF
7
  import json
8
 
9
- files = [f for f in os.listdir("/Users/andreeabodea/") if f.endswith(".pdf")]
10
- print(files)
11
 
12
  """
13
  Extract the text from a section of a PDF file between 'wanted_section' and 'next_section'.
@@ -48,12 +48,8 @@ def get_section(path, wanted_section, next_section):
48
  final_text = new_text.replace(special_char, special_char_replacement_list[index])
49
  return final_text
50
 
51
- for file in files:
52
 
53
- print("for each pdf file...")
54
- path = "/Users/andreeabodea/" + file
55
- pdf = pdfplumber.open(path)
56
- print(path)
57
 
58
  results_dict = {}
59
  results_dict["2.1 Aktualisierte Einordnung des Moduls in das EZ-Programm"] = \
@@ -88,5 +84,11 @@ for file in files:
88
  #json_string = json.dumps(results_dict, indent=4)
89
  #print(json_string)
90
 
91
- # iface = gr.Interface(fn=get_section, inputs="text", outputs="text")
92
- # iface.launch()
 
 
 
 
 
 
 
6
  import fitz # PyMuPDF
7
  import json
8
 
9
+ #files = [f for f in os.listdir("/Users/andreeabodea/") if f.endswith(".pdf")]
10
+ #print(files)
11
 
12
  """
13
  Extract the text from a section of a PDF file between 'wanted_section' and 'next_section'.
 
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
  results_dict = {}
55
  results_dict["2.1 Aktualisierte Einordnung des Moduls in das EZ-Programm"] = \
 
84
  #json_string = json.dumps(results_dict, indent=4)
85
  #print(json_string)
86
 
87
+ # Define the Gradio interface
88
+ iface = gr.Interface(fn=process_pdf,
89
+ inputs=gr.inputs.File(type="file", label="Upload PDF"),
90
+ outputs="text",
91
+ title="PDF Text Extractor",
92
+ description="Upload a PDF file to extract all its text.")
93
+
94
+ iface.launch()