-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathreturn_data_struct.py
48 lines (37 loc) · 1.12 KB
/
return_data_struct.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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
import copy
def get_pdf_ocr_return_json(code,message,ocr_return_data_list):
json = {
"code" : int,
"message" : str,
"data" : list()
}
page_data_struct = {
"page" : int,
"words_block_list" : list(),
}
words_block_struct = {
"words" : str,
"location" : list
}
json["code"] = code
json["message"] = message
for idx, page in enumerate(ocr_return_data_list,0):
page_info = copy.deepcopy(page_data_struct)
page_info["page"] = (idx + 1)
for location,contents in page:
words_block = copy.deepcopy(words_block_struct)
words_block["words"] = contents
words_block["location"] = location
page_info["words_block_list"].append(words_block)
json["data"].append(page_info)
return json
def get_voice_2_word_return_json(code,message,voice_ocr_return_data):
json = {
"code":int,
"message":str,
"data":str
}
json["code"] = code
json["message"] = message
json["data"] = voice_ocr_return_data
return json