qq1023 commited on
Commit
1a0823d
·
1 Parent(s): 7271383

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -4
app.py CHANGED
@@ -205,6 +205,8 @@ def flag_if_shared(flag_method):
205
  def process_and_output_files(input_files):
206
  data = []
207
 
 
 
208
  for file in input_files:
209
  # Extract and categorize text for each file
210
  text = extract_text(file)
@@ -232,13 +234,24 @@ def process_and_output_files(input_files):
232
  "Amount(Rs.)": response_dict.get("total")
233
  }
234
 
 
 
235
  # Append the relevant data for this file to the data list
236
  data.append(extracted_data)
237
 
238
- #data_dicts = [json.loads(item[0]) for item in data]
239
 
 
 
 
 
 
 
 
240
 
241
- return data
 
 
 
242
 
243
 
244
 
@@ -335,8 +348,9 @@ with gr.Blocks(title="Automatic Reimbursement Tool Demo") as page:
335
  interactive=False,
336
  height=240,
337
  )
338
- information = gr.JSON(label="Extracted information")
339
-
 
340
  with gr.Row():
341
  flag_incorrect_button = gr.Button(
342
  "Flag as incorrect", variant="stop", interactive=True
 
205
  def process_and_output_files(input_files):
206
  data = []
207
 
208
+ total_amount = 0
209
+
210
  for file in input_files:
211
  # Extract and categorize text for each file
212
  text = extract_text(file)
 
234
  "Amount(Rs.)": response_dict.get("total")
235
  }
236
 
237
+ total_amount+=response_dict.get("total")
238
+
239
  # Append the relevant data for this file to the data list
240
  data.append(extracted_data)
241
 
 
242
 
243
+ string_data = []
244
+ for item in data:
245
+ string_item = {key: str(value) for key, value in item.items()}
246
+ string_data.append(string_item)
247
+
248
+ df = pd.DataFrame(string_data)
249
+ table_html = df.to_html(classes="table table-bordered", index=True)
250
 
251
+ scrollable_table = f'<div style="overflow-x: auto;">{table_html}</div>'
252
+ return scrollable_table
253
+
254
+ #return data
255
 
256
 
257
 
 
348
  interactive=False,
349
  height=240,
350
  )
351
+ #information = gr.JSON(label="Extracted information")
352
+ information = gr.HTML()
353
+
354
  with gr.Row():
355
  flag_incorrect_button = gr.Button(
356
  "Flag as incorrect", variant="stop", interactive=True