NusretOzates commited on
Commit
fa9ebbc
1 Parent(s): 557995c

Update app.py

Browse files

Redundant open api text `change` function calls removed.

Files changed (1) hide show
  1. app.py +14 -61
app.py CHANGED
@@ -38,58 +38,19 @@ def get_json(mahalle, il, sokak, apartman):
38
  return dump
39
 
40
 
41
- def text_dict_city(input):
42
- eval_result = str(ast.literal_eval(input)["city"])
43
-
44
- return eval_result
45
-
46
-
47
- def text_dict_neighbourhood(input):
48
- eval_result = str(ast.literal_eval(input)["neighbourhood"])
49
-
50
- return eval_result
51
-
52
-
53
- def text_dict_distinct(input):
54
- eval_result = str(ast.literal_eval(input)["distinct"])
55
-
56
- return eval_result
57
-
58
-
59
- def text_dict_street(input):
60
- eval_result = str(ast.literal_eval(input)["street"])
61
-
62
- return eval_result
63
-
64
-
65
- def text_dict_no(input):
66
- eval_result = str(ast.literal_eval(input)["no"])
67
-
68
- return eval_result
69
-
70
-
71
- def text_dict_tel(input):
72
- eval_result = str(ast.literal_eval(input)["tel"])
73
-
74
- return eval_result
75
-
76
-
77
- def text_dict_name(input):
78
- eval_result = str(ast.literal_eval(input)["name_surname"])
79
- return eval_result
80
-
81
-
82
- def text_dict_address(input):
83
- eval_result = str(ast.literal_eval(input)["address"])
84
-
85
- return eval_result
86
-
87
- def text_dict_no(input):
88
- eval_result = str(ast.literal_eval(input)["no"])
89
-
90
- return eval_result
91
-
92
-
93
 
94
  def openai_response(ocr_input):
95
  prompt = f"""Tabular Data Extraction You are a highly intelligent and accurate tabular data extractor from
@@ -165,15 +126,7 @@ with gr.Blocks() as demo:
165
 
166
  ocr_result.change(openai_response, ocr_result, open_api_text, api_name="upload-text")
167
 
168
- open_api_text.change(text_dict_city, [open_api_text], city)
169
- open_api_text.change(text_dict_distinct, [open_api_text], distinct)
170
- open_api_text.change(text_dict_neighbourhood, [open_api_text], neighbourhood)
171
- open_api_text.change(text_dict_street, [open_api_text], street)
172
- open_api_text.change(text_dict_address, [open_api_text], address)
173
- open_api_text.change(text_dict_tel, [open_api_text], tel)
174
- open_api_text.change(text_dict_name, [open_api_text], name_surname)
175
- open_api_text.change(text_dict_no, [open_api_text], no)
176
-
177
 
178
 
179
  if __name__ == "__main__":
 
38
  return dump
39
 
40
 
41
+ def text_dict(input):
42
+ eval_result = ast.literal_eval(input)
43
+
44
+ return (
45
+ str(eval_result['city']),
46
+ str(eval_result['distinct']),
47
+ str(eval_result['neighbourhood']),
48
+ str(eval_result['street']),
49
+ str(eval_result['address']),
50
+ str(eval_result['tel']),
51
+ str(eval_result['name_surname']),
52
+ str(eval_result['no']),
53
+ )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
54
 
55
  def openai_response(ocr_input):
56
  prompt = f"""Tabular Data Extraction You are a highly intelligent and accurate tabular data extractor from
 
126
 
127
  ocr_result.change(openai_response, ocr_result, open_api_text, api_name="upload-text")
128
 
129
+ open_api_text.change(text_dict, open_api_text, [city, distinct, neighbourhood, street, address, tel, name_surname, no])
 
 
 
 
 
 
 
 
130
 
131
 
132
  if __name__ == "__main__":