car_data-to_dict.py
10.6 KB
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
#!/usr/bin/evn python
#coding=utf-8
import sys
reload(sys)
sys.setdefaultencoding('utf-8')
wenan_logo_dict = {
"key":"CarBrand",
"name":"车辆品牌",
"value":[
{"code":"-1","name":"未知"},
{"code":"00","name":"未识别"},
{"code":"01","name":"大众"},
{"code":"02","name":"现代"},
{"code":"03","name":"丰田"},
{"code":"04","name":"本田"},
{"code":"05","name":"长安"},
{"code":"06","name":"五菱"},
{"code":"07","name":"别克"},
{"code":"08","name":"日产"},
{"code":"09","name":"雪铁龙"},
{"code":"10","name":"奥迪"},
{"code":"11","name":"奇瑞"},
{"code":"12","name":"夏利"},
{"code":"13","name":"起亚"},
{"code":"14","name":"福特"},
{"code":"15","name":"雪佛兰"},
{"code":"16","name":"比亚迪"},
{"code":"17","name":"长城"},
{"code":"18","name":"吉利"},
{"code":"19","name":"铃木"},
{"code":"20","name":"东风风神"},
{"code":"21","name":"马自达"},
{"code":"22","name":"斯柯达"},
{"code":"23","name":"一汽"},
{"code":"24","name":"三菱"},
{"code":"25","name":"宝马"},
{"code":"26","name":"奔驰"},
{"code":"27","name":"标致"},
{"code":"28","name":"海马"},
{"code":"29","name":"哈飞"},
{"code":"30","name":"奔腾"},
{"code":"31","name":"江淮"},
{"code":"32","name":"金杯"},
{"code":"33","name":"中华"},
{"code":"34","name":"昌河"},
{"code":"35","name":"荣威"},
{"code":"36","name":"沃尔沃"},
{"code":"37","name":"帝豪"},
{"code":"38","name":"斯巴鲁"},
{"code":"39","name":"东南"},
{"code":"40","name":"路虎"},
{"code":"41","name":"福田"},
{"code":"42","name":"雷克萨斯"},
{"code":"43","name":"思铭"},
{"code":"44","name":"全球鹰"},
{"code":"45","name":"黄海"},
{"code":"46","name":"纳智捷"},
{"code":"47","name":"欧宝"},
{"code":"48","name":"开瑞"},
{"code":"49","name":"英菲尼迪"},
{"code":"50","name":"众泰"},
{"code":"51","name":"青年莲花"},
{"code":"52","name":"雷诺"},
{"code":"53","name":"凯迪拉克"},
{"code":"54","name":"厦门金龙"},
{"code":"55","name":"Jeep"},
{"code":"56","name":"双环"},
{"code":"57","name":"陆风"},
{"code":"58","name":"福迪"},
{"code":"59","name":"北汽制造"},
{"code":"60","name":"宝骏"},
{"code":"61","name":"力帆"},
{"code":"62","name":"野马"},
{"code":"63","name":"北京汽车"},
{"code":"64","name":"MG"},
{"code":"65","name":"中兴"},
{"code":"66","name":"启辰"},
{"code":"67","name":"菲亚特"},
{"code":"68","name":"英伦"},
{"code":"69","name":"江南奥拓"},
{"code":"70","name":"理念"},
{"code":"71","name":"广汽"},
{"code":"72","name":"DS"},
{"code":"73","name":"华泰"},
{"code":"74","name":"致观"},
{"code":"75","name":"哈弗"},
{"code":"76","name":"江铃"},
{"code":"77","name":"永源"},
{"code":"78","name":"吉奥"},
{"code":"79","name":"瑞麒"},
{"code":"80","name":"保时捷"},
{"code":"81","name":"东风"},
{"code":"82","name":"依维柯"},
{"code":"83","name":"猎豹"},
{"code":"84","name":"宾利"},
{"code":"85","name":"红旗"},
{"code":"86","name":"无用"},
{"code":"87","name":"陕汽"},
{"code":"88","name":"中国重汽"},
{"code":"89","name":"五十铃"},
{"code":"90","name":"日野"},
{"code":"91","name":"海格"},
{"code":"92","name":"恒通"},
{"code":"93","name":"红岩"},
{"code":"94","name":"精功"},
{"code":"95","name":"华菱"},
{"code":"96","name":"三一重工"},
{"code":"97","name":"金旅"},
{"code":"98","name":"跃进"},
{"code":"99","name":"瑞沃"},
{"code":"100","name":"亚星"},
{"code":"101","name":"广通"},
{"code":"102","name":"北方奔驰"},
{"code":"103","name":"长江"},
{"code":"104","name":"霸龙重卡"},
{"code":"105","name":"宇通"},
{"code":"106","name":"中通"},
{"code":"107","name":"青年"},
{"code":"108","name":"联合卡车"},
{"code":"109","name":"三环汽车"},
{"code":"110","name":"京华"},
{"code":"111","name":"安凯"},
{"code":"112","name":"贵州万达"},
{"code":"113","name":"大运"},
{"code":"114","name":"特斯拉"},
{"code":"115","name":"克莱斯勒"},
{"code":"116","name":"兰博基尼"},
{"code":"117","name":"劳斯莱斯"},
{"code":"118","name":"玛莎拉蒂"},
{"code":"119","name":"法拉利"},
{"code":"120","name":"捷豹"},
{"code":"121","name":"MINI"},
{"code":"122","name":"smart"},
{"code":"123","name":"林肯"},
{"code":"124","name":"讴歌"},
{"code":"125","name":"谛艾仕"},
{"code":"126","name":"福建"},
{"code":"127","name":"西雅诗"},
{"code":"128","name":"凯翼"},
{"code":"129","name":"腾势"},
{"code":"130","name":"田野"},
{"code":"131","name":"英致"},
{"code":"132","name":"大宇"},
{"code":"133","name":"少林"},
{"code":"134","name":"大通"},
{"code":"135","name":"汇众"},
{"code":"136","name":"阿斯顿马丁"},
{"code":"137","name":"福特野马"}
]
}
def creat_wenan_code_to_huawei_code(huawei_file_name,wenan_dict):
with open(huawei_file_name, 'r') as f:
file_messages = f.readlines()
huawei_message_list = []
for message in file_messages:
# print(logo)
message = message.split()
message.pop(0)
huawei_message_list.append(message)
# for logo in huawei_logos_list:
# #print logo[1]
wenan_message_list = []
for message_dict in wenan_dict["value"]:
wenan_message_list.append([message_dict['code'], message_dict['name']])
wenan_logo_name_list = []
for wenan_logo in wenan_message_list:
wenan_logo_name_list.append(wenan_logo[1])
new_message_list = []
for logo in huawei_message_list:
if logo[1] in wenan_logo_name_list:
# 匹配的生成一个对应列表[wenan_code:huawei_code]
for i in wenan_message_list:
if i[1] == logo[1]:
wenan_code = i[0]
new_message_list.append([wenan_code, logo[0]])
else:
print logo[1], logo[0], 'No'
# for j in wenan_logo_list:
# if (fuzz.partial_ratio(logo[1],j)):
# print(logo[1],j)
# else:
# #print(logo[1],'wu.....')
# pass
print '新生成的code对应列表为:',new_message_list
s1 = [['01', '001'], ['07', '002'], ['25', '003'], ['04', '004'], ['27', '005'], ['03', '006'], ['14', '007'], ['08', '008'], ['10', '009'], ['21', '010'], ['15', '011'], ['09', '012'], ['02', '013'], ['11', '014'], ['13', '015'], ['35', '016'], ['24', '017'], ['22', '018'], ['18', '019'], ['33', '020'], ['36', '021'], ['42', '022'], ['67', '023'], ['81', '025'], ['16', '026'], ['19', '027'], ['32', '028'], ['28', '029'], ['06', '030'], ['31', '031'], ['38', '032'], ['68', '033'], ['17', '034'], ['29', '035'], ['39', '037'], ['05', '038'], ['41', '039'], ['12', '040'], ['26', '041'], ['23', '042'], ['82', '043'], ['61', '044'], ['52', '047'], ['50', '051'], ['34', '052'], ['54', '053'], ['91', '056'], ['105', '057'], ['88', '058'], ['80', '065'], ['53', '066'], ['49', '067'], ['40', '070'], ['111', '081'], ['132', '083'], ['106', '086'], ['60', '087'], ['57', '090'], ['47', '095'], ['48', '096'], ['124', '103'], ['66', '104'], ['59', '107'], ['46', '108'], ['62', '109'], ['65', '110'], ['115', '112'], ['120', '117'], ['58', '121'], ['56', '124'], ['77', '128'], ['84', '191'], ['85', '230']]
s2 = [['37','024'],['89','036'],['30','045'],['64','049'],['135','054'],['95','060'],['98','061'],['45','062'],['44','068'],
['55','069'],['83','071'],['87','076'],['59','088'],['71','089'],['63','092'],['78','113'],['79','115'],['51','112'],
['113','155'],['-1','999'],['00','999']]
wenan_color_dict = {
"key":"CarColor",
"name":"车身颜色",
"value":[
{"code":"00","name":"未知"},
{"code":"01","name":"黑色"},
{"code":"02","name":"白色"},
{"code":"03","name":"灰色"},
{"code":"04","name":"银色"},
{"code":"05","name":"红色"},
{"code":"06","name":"深红色"},
{"code":"07","name":"绿色"},
{"code":"08","name":"深绿色"},
{"code":"09","name":"蓝色"},
{"code":"11","name":"深蓝色"},
{"code":"12","name":"黄色"},
{"code":"13","name":"深黄色"},
{"code":"14","name":"金色"},
{"code":"15","name":"粉色"},
{"code":"16","name":"紫色"},
{"code":"17","name":"其他"}
]
}
wenan_car_type_dict = {
"key":"CarType",
"name":"车辆类型",
"value":[
{"code":"00","name":"小轿车"},
{"code":"01","name":"大型货车"},
{"code":"02","name":"摩托车"},
{"code":"03","name":"大型客车"},
{"code":"04","name":"行人"},
{"code":"05","name":"遗撒"},
{"code":"06","name":"中型货车"},
{"code":"07","name":"小型货车"},
{"code":"08","name":"中型客车"},
{"code":"09","name":"面包车"},
{"code":"10","name":"其他"},
{"code":"11","name":"未知"}
]
}
wenan_lane_type_dict = {
"key":"RoadType",
"name":"车道类型",
"value":[
{"code":"00","name":"左转"},
{"code":"01","name":"右转"},
{"code":"02","name":"直行"},
{"code":"03","name":"直左混行"},
{"code":"04","name":"直右混行"},
{"code":"05","name":"黄线"},
{"code":"06","name":"自行车道"},
{"code":"07","name":"人行横道"},
{"code":"08","name":"公交车道"},
{"code":"09","name":"应急车道"},
{"code":"10","name":"非机动车道"},
{"code":"11","name":"左转弯待停区"},
{"code":"12","name":"非大货车车道"}
]
}
wenan_palte_color_dict = {
"key":"PlateColor",
"name":"号牌颜色",
"value":[
{"code":"00","name":"未知"},
{"code":"01","name":"黄"},
{"code":"02","name":"蓝"},
{"code":"03","name":"黑"},
{"code":"05","name":"白"},
{"code":"06","name":"绿"},
{"code":"07","name":"黄绿"},
{"code":"09","name":"其他颜色"}
]
}
# huawei_file_name = 'color.txt'
# huawei_file_name = 'car_logos.txt'
huawei_file_name = 'plate_color.txt'
if __name__ == '__main__':
#creat_wenan_code_to_huawei_code(huawei_file_name, wenan_logo_dict)
creat_wenan_code_to_huawei_code(huawei_file_name, wenan_palte_color_dict)