jonathanjordan21 commited on
Commit
26b9125
·
verified ·
1 Parent(s): 3ffd2dc

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -8
app.py CHANGED
@@ -305,6 +305,7 @@ def respond(
305
  request_details = []
306
  request_numbers = []
307
  request_scores = []
 
308
  for i,score in enumerate(scores):
309
  if score > threshold:
310
  request_details.append(codes[i][6:])
@@ -314,6 +315,7 @@ def respond(
314
  if not request_details:
315
  request_details.append(undetected[6:])
316
  request_numbers.append(undetected_code)
 
317
 
318
  request_numbers_copy = request_numbers
319
  request_details_copy = request_details
@@ -328,9 +330,9 @@ def respond(
328
  # formula = kode_mohon.get("formula")
329
  # description = inspect.getsource(formula).split(":", 2)[-1].strip()
330
 
331
- if len(request_numbers_copy) == 0 and len(plates) ==0:
332
- # + request_details + f"\n\nConfidence score:\n{request_scores}"
333
- return "Request code number:\n" + request_numbers + "\n\nRequest detail:\n" + "\n\nPlate numbers: " + plate_numbers
334
 
335
  out = ""
336
  for plate in plates:
@@ -353,9 +355,13 @@ def respond(
353
  descriptions, result_details = [], []
354
  for code in request_numbers_copy:
355
  result, description, result_detail = get_calculation(code, "")
356
- descriptions.append(description)
357
- result_details.append(result_detail)
358
- out += "\n\n" + build_output_formula(descriptions, result_details)
 
 
 
 
359
 
360
  return out
361
 
@@ -385,12 +391,12 @@ def respond(
385
  elif vehicle_tax_info.get(plate):
386
  out += "\n\n" + build_output_vehicle(plate)
387
  else:
388
- # + request_code[6:] + f"\nConfidence score: {round(scores[s_max].tolist(),3)}"
389
  out += "Request code number: " + request_code[:3] + "\nRequest detail: " + "\nPlate numbers: " + plate_numbers
390
 
391
  if out == "":
392
  if request_code[:3] == undetected_code:
393
- return "Request code number: " + request_code[:3] + "\nRequest detail: " + "\nPlate numbers: " + plate_numbers
394
  else:
395
  result, description, result_detail = get_calculation(request_code[:3], "")
396
  out = build_output_formula([description], [result_detail])
 
305
  request_details = []
306
  request_numbers = []
307
  request_scores = []
308
+ # request_undetected = False
309
  for i,score in enumerate(scores):
310
  if score > threshold:
311
  request_details.append(codes[i][6:])
 
315
  if not request_details:
316
  request_details.append(undetected[6:])
317
  request_numbers.append(undetected_code)
318
+
319
 
320
  request_numbers_copy = request_numbers
321
  request_details_copy = request_details
 
330
  # formula = kode_mohon.get("formula")
331
  # description = inspect.getsource(formula).split(":", 2)[-1].strip()
332
 
333
+ # if request_undetected and len(plates) == 0:
334
+ # + f"\n\nConfidence score:\n{request_scores}"
335
+ # return "Request code number:\n" + request_numbers + "\n\nRequest detail:\n" + request_details + "\n\nPlate numbers: " + plate_numbers
336
 
337
  out = ""
338
  for plate in plates:
 
355
  descriptions, result_details = [], []
356
  for code in request_numbers_copy:
357
  result, description, result_detail = get_calculation(code, "")
358
+ if description != None:
359
+ descriptions.append(description)
360
+ result_details.append(result_detail)
361
+ if descriptions:
362
+ out += "\n\n" + build_output_formula(descriptions, result_details)
363
+ else:
364
+ return "Request code number:\n" + request_numbers + "\n\nRequest detail:\n" + request_details + "\n\nPlate numbers: " + plate_numbers
365
 
366
  return out
367
 
 
391
  elif vehicle_tax_info.get(plate):
392
  out += "\n\n" + build_output_vehicle(plate)
393
  else:
394
+ # + f"\nConfidence score: {round(scores[s_max].tolist(),3)}"
395
  out += "Request code number: " + request_code[:3] + "\nRequest detail: " + "\nPlate numbers: " + plate_numbers
396
 
397
  if out == "":
398
  if request_code[:3] == undetected_code:
399
+ return "Request code number: " + request_code[:3] + "\nRequest detail: " + request_code[6:] + "\nPlate numbers: " + plate_numbers
400
  else:
401
  result, description, result_detail = get_calculation(request_code[:3], "")
402
  out = build_output_formula([description], [result_detail])