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 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 50,
   "id": "1f939e73",
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "data = pd.read_csv('/home/xj/toolAugEnv/code/toolConstraint/database/restaurants/zomato.csv')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 51,
   "id": "876e4fff",
   "metadata": {},
   "outputs": [],
   "source": [
    "data_dict = data.to_dict(orient = 'split')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 52,
   "id": "dbaee06c",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['Restaurant ID',\n",
       " 'Restaurant Name',\n",
       " 'Country Code',\n",
       " 'City',\n",
       " 'Address',\n",
       " 'Locality',\n",
       " 'Locality Verbose',\n",
       " 'Longitude',\n",
       " 'Latitude',\n",
       " 'Cuisines',\n",
       " 'Average Cost for two',\n",
       " 'Currency',\n",
       " 'Has Table booking',\n",
       " 'Has Online delivery',\n",
       " 'Is delivering now',\n",
       " 'Switch to order menu',\n",
       " 'Price range',\n",
       " 'Aggregate rating',\n",
       " 'Rating color',\n",
       " 'Rating text',\n",
       " 'Votes']"
      ]
     },
     "execution_count": 52,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data_dict['columns']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 53,
   "id": "cb540128",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "9551"
      ]
     },
     "execution_count": 53,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "len(data_dict['data'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "ea9858c5",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[6600970,\n",
       " 'Pizza 礞 Bessa',\n",
       " 30,\n",
       " 'Bras韄lia',\n",
       " 'SCS 214, Bloco C, Loja 40, Asa Sul, Bras韄lia',\n",
       " 'Asa Sul',\n",
       " 'Asa Sul, Bras韄lia',\n",
       " -47.91566667,\n",
       " -15.83116667,\n",
       " 'Pizza',\n",
       " 50,\n",
       " 'Brazilian Real(R$)',\n",
       " 'No',\n",
       " 'No',\n",
       " 'No',\n",
       " 'No',\n",
       " 2,\n",
       " 3.2,\n",
       " 'Orange',\n",
       " 'Average',\n",
       " 11]"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "data_dict['data'][26]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "id": "e21af5d1",
   "metadata": {},
   "outputs": [],
   "source": [
    "flight = pd.read_csv('/home/xj/toolAugEnv/code/toolConstraint/database/flights/clean_Flights_2022.csv')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "966feef9",
   "metadata": {},
   "outputs": [],
   "source": [
    "flight = flight.to_dict(orient = 'split')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 93,
   "id": "c5f81f43",
   "metadata": {},
   "outputs": [],
   "source": [
    "city_set = open('/home/xj/toolAugEnv/code/toolConstraint/database/background/citySet.txt','r').read().strip().split('\\n')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 94,
   "id": "bfce5f56",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "['San Diego',\n",
       " 'Pellston',\n",
       " 'Buffalo',\n",
       " 'Charlotte Amalie',\n",
       " 'Flagstaff',\n",
       " 'Evansville',\n",
       " 'Hilo',\n",
       " 'Twin Falls',\n",
       " 'Newark',\n",
       " 'State College',\n",
       " 'Johnstown',\n",
       " 'Charleston',\n",
       " 'Montgomery',\n",
       " 'Redding',\n",
       " 'Lynchburg',\n",
       " 'South Bend',\n",
       " 'Sarasota',\n",
       " 'Sioux Falls',\n",
       " 'Paducah',\n",
       " 'Kahului',\n",
       " 'Atlantic City',\n",
       " 'Bemidji',\n",
       " 'Toledo',\n",
       " 'Abilene',\n",
       " 'Sacramento',\n",
       " 'Amarillo',\n",
       " 'Moline',\n",
       " 'Hilton Head',\n",
       " 'Manhattan',\n",
       " 'Minneapolis',\n",
       " 'Fort Myers',\n",
       " 'Roswell',\n",
       " 'Harlingen',\n",
       " 'Seattle',\n",
       " 'Manchester',\n",
       " 'Gulfport',\n",
       " 'Gainesville',\n",
       " 'Pago Pago',\n",
       " 'Wrangell',\n",
       " 'Augusta',\n",
       " 'Waterloo',\n",
       " 'Yuma',\n",
       " 'Saipan',\n",
       " 'Christiansted',\n",
       " 'North Bend',\n",
       " 'Richmond',\n",
       " 'Albuquerque',\n",
       " 'Nashville',\n",
       " 'Aberdeen',\n",
       " 'Harrisburg',\n",
       " 'Fort Wayne',\n",
       " 'Green Bay',\n",
       " 'Wenatchee',\n",
       " 'Santa Fe',\n",
       " 'St. Petersburg',\n",
       " 'Belleville',\n",
       " 'Greensboro',\n",
       " 'Lake Charles',\n",
       " 'Traverse City',\n",
       " 'Erie',\n",
       " 'Niagara Falls',\n",
       " 'Pocatello',\n",
       " 'Idaho Falls',\n",
       " 'Alpena',\n",
       " 'Wilmington',\n",
       " 'Ontario',\n",
       " 'Iron Mountain',\n",
       " 'Lubbock',\n",
       " 'Helena',\n",
       " 'Kalamazoo',\n",
       " 'Cleveland',\n",
       " 'Grand Island',\n",
       " 'Bishop',\n",
       " 'New Bern',\n",
       " 'Melbourne',\n",
       " 'Bristol',\n",
       " 'Orlando',\n",
       " 'Bismarck',\n",
       " 'Fresno',\n",
       " 'Billings',\n",
       " 'Jackson',\n",
       " 'Daytona Beach',\n",
       " 'College Station',\n",
       " 'Jacksonville',\n",
       " 'Salt Lake City',\n",
       " 'Corpus Christi',\n",
       " 'Florence',\n",
       " 'Moab',\n",
       " 'Grand Forks',\n",
       " 'Las Vegas',\n",
       " 'Fairbanks',\n",
       " 'Petersburg',\n",
       " 'Wichita',\n",
       " 'Rhinelander',\n",
       " 'Kansas City',\n",
       " 'Dothan',\n",
       " 'Alamosa',\n",
       " 'Adak Island',\n",
       " 'Islip',\n",
       " 'Wichita Falls',\n",
       " 'Presque Isle',\n",
       " 'San Luis Obispo',\n",
       " 'Dayton',\n",
       " 'Brunswick',\n",
       " 'Fort Smith',\n",
       " \"Martha's Vineyard\",\n",
       " 'Portland',\n",
       " 'Waco',\n",
       " 'New York',\n",
       " 'Columbus',\n",
       " 'Tampa',\n",
       " 'Dallas',\n",
       " 'Little Rock',\n",
       " 'Kona',\n",
       " 'Clarksburg',\n",
       " 'San Angelo',\n",
       " 'Saginaw',\n",
       " 'Houston',\n",
       " 'Duluth',\n",
       " 'Valparaiso',\n",
       " 'Phoenix',\n",
       " 'Oakland',\n",
       " 'Watertown',\n",
       " 'Ogden',\n",
       " 'Cedar Rapids',\n",
       " 'Cape Girardeau',\n",
       " 'Sun Valley',\n",
       " 'Sault Ste. Marie',\n",
       " 'Trenton',\n",
       " 'Missoula',\n",
       " 'Pasco',\n",
       " 'Brainerd',\n",
       " 'Newburgh',\n",
       " 'Gustavus',\n",
       " 'Branson',\n",
       " 'Providence',\n",
       " 'Minot',\n",
       " 'Huntsville',\n",
       " 'San Antonio',\n",
       " 'Marquette',\n",
       " 'Owensboro',\n",
       " 'Del Rio',\n",
       " 'Portsmouth',\n",
       " 'Bloomington',\n",
       " 'Lexington',\n",
       " 'Santa Barbara',\n",
       " 'Baltimore',\n",
       " 'Panama City',\n",
       " 'Kodiak',\n",
       " 'Jacksonville',\n",
       " 'Yakima',\n",
       " 'Vernal',\n",
       " 'Salisbury',\n",
       " 'Mission',\n",
       " 'Newport News',\n",
       " 'Charlottesville',\n",
       " 'Grand Junction',\n",
       " 'Baton Rouge',\n",
       " 'Beaumont',\n",
       " 'Staunton',\n",
       " 'Kalispell',\n",
       " 'Key West',\n",
       " 'Worcester',\n",
       " 'West Palm Beach',\n",
       " 'Boise',\n",
       " 'Grand Rapids',\n",
       " 'Salina',\n",
       " 'Fort Leonard Wood',\n",
       " 'Walla Walla',\n",
       " 'Everett',\n",
       " 'Dillingham',\n",
       " 'Bellingham',\n",
       " 'Lansing',\n",
       " 'Madison',\n",
       " 'Victoria',\n",
       " 'Sioux City',\n",
       " 'Hattiesburg',\n",
       " 'Stockton',\n",
       " 'Anchorage',\n",
       " 'Charlotte',\n",
       " 'Jamestown',\n",
       " 'Laramie',\n",
       " 'Decatur',\n",
       " 'Durango',\n",
       " 'Longview',\n",
       " 'Syracuse',\n",
       " 'St. Cloud',\n",
       " 'Santa Rosa',\n",
       " 'Bakersfield',\n",
       " 'North Platte',\n",
       " 'La Crosse',\n",
       " 'Plattsburgh',\n",
       " 'Concord',\n",
       " 'Atlanta',\n",
       " 'Provo',\n",
       " 'Ogdensburg',\n",
       " 'Ithaca',\n",
       " 'Colorado Springs',\n",
       " 'Washington',\n",
       " 'Williston',\n",
       " 'Tulsa',\n",
       " 'Midland',\n",
       " 'Champaign',\n",
       " 'Devils Lake',\n",
       " 'Greer',\n",
       " 'Muskegon',\n",
       " 'Hibbing',\n",
       " 'Santa Ana',\n",
       " 'Ponce',\n",
       " 'Prescott',\n",
       " 'Indianapolis',\n",
       " 'International Falls',\n",
       " 'Rapid City',\n",
       " 'Ketchikan',\n",
       " 'St. Louis',\n",
       " 'Santa Maria',\n",
       " 'Elmira',\n",
       " 'Alexandria',\n",
       " 'San Jose',\n",
       " 'Tucson',\n",
       " 'San Juan',\n",
       " 'Dubuque',\n",
       " 'Burbank',\n",
       " 'Gunnison',\n",
       " 'Cedar City',\n",
       " 'Hyannis',\n",
       " 'Raleigh',\n",
       " 'Norfolk',\n",
       " 'New Orleans',\n",
       " 'Medford',\n",
       " 'White Plains',\n",
       " 'Oklahoma City',\n",
       " 'Chicago',\n",
       " 'El Paso',\n",
       " 'Rockford',\n",
       " 'Aguadilla',\n",
       " 'Omaha',\n",
       " 'Scottsbluff',\n",
       " 'Yakutat',\n",
       " 'Arcata',\n",
       " 'Spokane',\n",
       " 'Brownsville',\n",
       " 'Bend',\n",
       " 'Hagerstown',\n",
       " 'Peoria',\n",
       " 'Appleton',\n",
       " 'Roanoke',\n",
       " 'Eugene',\n",
       " 'Rock Springs',\n",
       " 'Dodge City',\n",
       " 'Austin',\n",
       " 'Miami',\n",
       " 'Dallas',\n",
       " 'Mosinee',\n",
       " 'Killeen',\n",
       " 'Lihue',\n",
       " 'Pittsburgh',\n",
       " 'Tallahassee',\n",
       " 'Butte',\n",
       " 'Lawton',\n",
       " 'Honolulu',\n",
       " 'Greenville',\n",
       " 'Juneau',\n",
       " 'Myrtle Beach',\n",
       " 'Boston',\n",
       " 'Charleston',\n",
       " 'Latrobe',\n",
       " 'Knoxville',\n",
       " 'Denver',\n",
       " 'Bangor',\n",
       " 'Albany',\n",
       " 'Punta Gorda',\n",
       " 'Fort Lauderdale',\n",
       " 'Philadelphia',\n",
       " 'Binghamton',\n",
       " 'Great Falls',\n",
       " 'Shreveport',\n",
       " 'Asheville',\n",
       " 'Cheyenne',\n",
       " 'Milwaukee',\n",
       " 'Nome',\n",
       " 'Laredo',\n",
       " 'Des Moines',\n",
       " 'Fayetteville',\n",
       " 'Lewisburg',\n",
       " 'Fort Dodge',\n",
       " 'Cody',\n",
       " 'Chattanooga',\n",
       " 'Deadhorse',\n",
       " 'Kotzebue',\n",
       " 'Sitka',\n",
       " 'Bozeman',\n",
       " 'Palm Springs',\n",
       " 'Memphis',\n",
       " 'Nantucket',\n",
       " 'Texarkana',\n",
       " 'Lewiston',\n",
       " 'Valdosta',\n",
       " 'Birmingham',\n",
       " 'Scranton',\n",
       " 'Pensacola',\n",
       " 'Hancock',\n",
       " 'Los Angeles',\n",
       " 'Mason City',\n",
       " 'Savannah',\n",
       " 'West Yellowstone',\n",
       " 'Long Beach',\n",
       " 'Reno',\n",
       " 'Akron',\n",
       " 'Louisville',\n",
       " 'Hartford',\n",
       " 'Cincinnati',\n",
       " 'Rochester',\n",
       " 'San Francisco',\n",
       " 'Detroit',\n",
       " 'Monterey',\n",
       " 'Escanaba',\n",
       " 'Eau Claire']"
      ]
     },
     "execution_count": 94,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "city_set"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "cd0f41fb",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "1 Restaurant Name\n",
      "3 City\n",
      "9 Cuisines\n",
      "10 Average Cost for two\n",
      "11 Currency\n",
      "17 Aggregate rating\n"
     ]
    }
   ],
   "source": [
    "for idx, unit in enumerate(data_dict['columns']):\n",
    "    if unit in ['Restaurant Name', 'City', 'Cuisines', 'Average Cost for two','Aggregate rating','Currency']:\n",
    "        print(idx,unit)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "id": "04fe71b7",
   "metadata": {},
   "outputs": [],
   "source": [
    "currency_set = set()\n",
    "for unit in data_dict['data']:\n",
    "    currency_set.add(unit[11])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "3988186d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'Botswana Pula(P)',\n",
       " 'Brazilian Real(R$)',\n",
       " 'Dollar($)',\n",
       " 'Emirati Diram(AED)',\n",
       " 'Indian Rupees(Rs.)',\n",
       " 'Indonesian Rupiah(IDR)',\n",
       " 'NewZealand($)',\n",
       " 'Pounds(專)',\n",
       " 'Qatari Rial(QR)',\n",
       " 'Rand(R)',\n",
       " 'Sri Lankan Rupee(LKR)',\n",
       " 'Turkish Lira(TL)'}"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "currency_set"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "id": "257e6a76",
   "metadata": {},
   "outputs": [],
   "source": [
    "exchange_rate = {\"Botswana Pula(P)\":0.074,\n",
    "                 \"Brazilian Real(R$)\":0.21, \n",
    "                 'Dollar($)':1, \n",
    "                 'Emirati Diram(AED)':0.27,\n",
    "                 \"Indian Rupees(Rs.)\":0.012087,\n",
    "                \"Indonesian Rupiah(IDR)\":0.000066,\n",
    "                'NewZealand($)':0.61,\n",
    "                \"Pounds(專)\":1.28,\n",
    "                \"Qatari Rial(QR)\":0.27,\n",
    "                'Rand(R)': 0.054,\n",
    "                 \"Sri Lankan Rupee(LKR)\":0.0031,\n",
    "                 'Turkish Lira(TL)':0.037\n",
    "                }"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 119,
   "id": "c6b2691e",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "application/vnd.jupyter.widget-view+json": {
       "model_id": "3984855550f54090b3264d7adc859433",
       "version_major": 2,
       "version_minor": 0
      },
      "text/plain": [
       "0it [00:00, ?it/s]"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "from tqdm.autonotebook import tqdm\n",
    "import random\n",
    "new_data = []\n",
    "\n",
    "for idx, unit in tqdm(enumerate(data_dict['data'])):\n",
    "    tmp_dict = {k:\"\" for k in ['Name', 'City', 'Cuisines', 'Average Cost','Aggregate Rating']}\n",
    "    tmp_dict[\"Name\"] = unit[1]\n",
    "    tmp_dict[\"City\"] = random.sample(city_set,1)[0]\n",
    "    tmp_dict[\"Cuisines\"] = unit[9]\n",
    "    tmp_dict[\"Average Cost\"] = max(random.randint(10,100),int(unit[10] / 2 * exchange_rate[unit[11]]))\n",
    "    tmp_dict[\"Aggregate Rating\"] = unit[17]\n",
    "    new_data.append(tmp_dict)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 120,
   "id": "f27aaff1",
   "metadata": {},
   "outputs": [],
   "source": [
    "countries = [\"Chinese\", \"American\", \"Italian\", \"Mexican\", \"Indian\",\"Mediterranean\",\"French\"]\n",
    "cuisine = [\"Tea\",\"Seafood\",\"Bakery\",\"Desserts\",\"BBQ\",\"Fast Food\",\"Cafe\",\"Pizza\"]\n",
    "total_cuisine = countries + cuisine\n",
    "for unit in new_data:\n",
    "    flag = False\n",
    "    final_cuisine = set()\n",
    "#     for c in total_cuisine:\n",
    "#         if c in str(unit['Cuisines']):\n",
    "#             final_cuisine.add(c)\n",
    "    choice_number = random.choices([1,1,2])[0]\n",
    "    for x in random.sample(countries,choice_number):\n",
    "        final_cuisine.add(x)\n",
    "    choice_number = random.choices([2,3,4])[0]\n",
    "    for x in random.sample(cuisine,choice_number):\n",
    "        final_cuisine.add(x)\n",
    "    unit['Cuisines'] = \", \".join(x for x in final_cuisine)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 121,
   "id": "9e3afb30",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'Name': 'Karak韄y G韄ll韄o埕lu',\n",
       " 'City': 'Phoenix',\n",
       " 'Cuisines': 'Bakery, Indian, Desserts, Seafood',\n",
       " 'Average Cost': 75,\n",
       " 'Aggregate Rating': 4.7}"
      ]
     },
     "execution_count": 121,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "new_data[-7]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 122,
   "id": "bfb243c0",
   "metadata": {},
   "outputs": [],
   "source": [
    "df = pd.DataFrame(new_data)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 123,
   "id": "af7e3411",
   "metadata": {},
   "outputs": [],
   "source": [
    "df.to_csv('/home/xj/toolAugEnv/code/toolConstraint/database/restaurants/clean_restaurant_2022.csv')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 92,
   "id": "dad9bf9f",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>Name</th>\n",
       "      <th>City</th>\n",
       "      <th>Cuisines</th>\n",
       "      <th>Average Cost</th>\n",
       "      <th>Aggregate Rating</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>Le Petit Souffle</td>\n",
       "      <td>Eagle</td>\n",
       "      <td>Desserts, French, Fast Food, Chinese, Indian</td>\n",
       "      <td>40</td>\n",
       "      <td>4.8</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>Izakaya Kikufuji</td>\n",
       "      <td>Hilton Head</td>\n",
       "      <td>Mexican, BBQ, Mediterranean, Pizza</td>\n",
       "      <td>95</td>\n",
       "      <td>4.5</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>Heat - Edsa Shangri-La</td>\n",
       "      <td>Trenton</td>\n",
       "      <td>Tea, Pizza, French, Indian, Mediterranean, Sea...</td>\n",
       "      <td>148</td>\n",
       "      <td>4.4</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>Ooma</td>\n",
       "      <td>Portland</td>\n",
       "      <td>Tea, Pizza, French, BBQ, Cafe</td>\n",
       "      <td>89</td>\n",
       "      <td>4.9</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>Sambo Kojin</td>\n",
       "      <td>Milwaukee</td>\n",
       "      <td>Desserts, Tea, Italian, Cafe, Mediterranean</td>\n",
       "      <td>60</td>\n",
       "      <td>4.8</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9546</th>\n",
       "      <td>Naml郾 Gurme</td>\n",
       "      <td>Worcester</td>\n",
       "      <td>Tea, BBQ, Fast Food, Chinese, American, Medite...</td>\n",
       "      <td>72</td>\n",
       "      <td>4.1</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9547</th>\n",
       "      <td>Ceviz A埕ac郾</td>\n",
       "      <td>San Francisco</td>\n",
       "      <td>Cafe, Mexican, Pizza, Bakery</td>\n",
       "      <td>14</td>\n",
       "      <td>4.2</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9548</th>\n",
       "      <td>Huqqa</td>\n",
       "      <td>Guam</td>\n",
       "      <td>Pizza, Italian, French, Mexican, BBQ, Chinese,...</td>\n",
       "      <td>25</td>\n",
       "      <td>3.7</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9549</th>\n",
       "      <td>A侓侓k Kahve</td>\n",
       "      <td>Louisville</td>\n",
       "      <td>Chinese, Tea, Mexican, Cafe, Indian</td>\n",
       "      <td>96</td>\n",
       "      <td>4.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9550</th>\n",
       "      <td>Walter's Coffee Roastery</td>\n",
       "      <td>Monroe</td>\n",
       "      <td>Pizza, Italian, Cafe, Indian, Mediterranean</td>\n",
       "      <td>79</td>\n",
       "      <td>4.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>9551 rows × 5 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "                          Name           City  \\\n",
       "0             Le Petit Souffle          Eagle   \n",
       "1             Izakaya Kikufuji    Hilton Head   \n",
       "2       Heat - Edsa Shangri-La        Trenton   \n",
       "3                         Ooma       Portland   \n",
       "4                  Sambo Kojin      Milwaukee   \n",
       "...                        ...            ...   \n",
       "9546               Naml郾 Gurme      Worcester   \n",
       "9547               Ceviz A埕ac郾  San Francisco   \n",
       "9548                     Huqqa           Guam   \n",
       "9549                A侓侓k Kahve     Louisville   \n",
       "9550  Walter's Coffee Roastery         Monroe   \n",
       "\n",
       "                                               Cuisines  Average Cost  \\\n",
       "0          Desserts, French, Fast Food, Chinese, Indian            40   \n",
       "1                    Mexican, BBQ, Mediterranean, Pizza            95   \n",
       "2     Tea, Pizza, French, Indian, Mediterranean, Sea...           148   \n",
       "3                         Tea, Pizza, French, BBQ, Cafe            89   \n",
       "4           Desserts, Tea, Italian, Cafe, Mediterranean            60   \n",
       "...                                                 ...           ...   \n",
       "9546  Tea, BBQ, Fast Food, Chinese, American, Medite...            72   \n",
       "9547                       Cafe, Mexican, Pizza, Bakery            14   \n",
       "9548  Pizza, Italian, French, Mexican, BBQ, Chinese,...            25   \n",
       "9549                Chinese, Tea, Mexican, Cafe, Indian            96   \n",
       "9550        Pizza, Italian, Cafe, Indian, Mediterranean            79   \n",
       "\n",
       "      Aggregate Rating  \n",
       "0                  4.8  \n",
       "1                  4.5  \n",
       "2                  4.4  \n",
       "3                  4.9  \n",
       "4                  4.8  \n",
       "...                ...  \n",
       "9546               4.1  \n",
       "9547               4.2  \n",
       "9548               3.7  \n",
       "9549               4.0  \n",
       "9550               4.0  \n",
       "\n",
       "[9551 rows x 5 columns]"
      ]
     },
     "execution_count": 92,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 48,
   "id": "e168b1c5",
   "metadata": {},
   "outputs": [],
   "source": [
    "cuisine_dict = {}\n",
    "for unit in new_data:\n",
    "    for x in str(unit['Cuisines']).split(', '):\n",
    "        if x not in cuisine_dict:\n",
    "            cuisine_dict[x] = 1\n",
    "        else:\n",
    "            cuisine_dict[x] += 1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 49,
   "id": "564d4bda",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "French 29\n",
      "Japanese 135\n",
      "Desserts 653\n",
      "Seafood 174\n",
      "Asian 233\n",
      "Filipino 10\n",
      "Indian 70\n",
      "Sushi 75\n",
      "Korean 21\n",
      "Chinese 2735\n",
      "European 148\n",
      "Mexican 181\n",
      "American 390\n",
      "Ice Cream 226\n",
      "Cafe 703\n",
      "Italian 764\n",
      "Pizza 381\n",
      "Bakery 745\n",
      "Mediterranean 112\n",
      "Fast Food 1986\n",
      "Brazilian 28\n",
      "Arabian 28\n",
      "Bar Food 39\n",
      "Grill 21\n",
      "International 21\n",
      "Peruvian 1\n",
      "Latin American 11\n",
      "Burger 251\n",
      "Juices 29\n",
      "Healthy Food 150\n",
      "Beverages 229\n",
      "Lebanese 69\n",
      "Sandwich 53\n",
      "Steak 62\n",
      "BBQ 33\n",
      "Gourmet Fast Food 1\n",
      "Mineira 1\n",
      "North Eastern 9\n",
      "nan 9\n",
      "Coffee and Tea 19\n",
      "Vegetarian 23\n",
      "Tapas 19\n",
      "Breakfast 41\n",
      "Diner 6\n",
      "Southern 24\n",
      "Southwestern 7\n",
      "Spanish 16\n",
      "Argentine 2\n",
      "Caribbean 7\n",
      "German 10\n",
      "Vietnamese 21\n",
      "Thai 234\n",
      "Modern Australian 11\n",
      "Teriyaki 2\n",
      "Cajun 10\n",
      "Canadian 1\n",
      "Tex-Mex 19\n",
      "Middle Eastern 22\n",
      "Greek 15\n",
      "Bubble Tea 1\n",
      "Tea 48\n",
      "Australian 5\n",
      "Fusion 4\n",
      "Cuban 2\n",
      "Hawaiian 8\n",
      "Salad 93\n",
      "Irish 1\n",
      "New American 2\n",
      "Soul Food 1\n",
      "Turkish 15\n",
      "Pub Food 2\n",
      "Persian 2\n",
      "Continental 736\n",
      "Singaporean 4\n",
      "Malay 1\n",
      "Cantonese 2\n",
      "Dim Sum 3\n",
      "Western 10\n",
      "Finger Food 114\n",
      "British 16\n",
      "Deli 3\n",
      "Indonesian 14\n",
      "North Indian 3960\n",
      "Mughlai 995\n",
      "Biryani 177\n",
      "South Indian 636\n",
      "Pakistani 12\n",
      "Afghani 14\n",
      "Hyderabadi 26\n",
      "Rajasthani 21\n",
      "Street Food 562\n",
      "Goan 20\n",
      "African 8\n",
      "Portuguese 7\n",
      "Gujarati 11\n",
      "Armenian 3\n",
      "Mithai 380\n",
      "Maharashtrian 10\n",
      "Modern Indian 16\n",
      "Charcoal Grill 4\n",
      "Malaysian 22\n",
      "Burmese 10\n",
      "Chettinad 11\n",
      "Parsi 8\n",
      "Tibetan 44\n",
      "Raw Meats 114\n",
      "Kerala 23\n",
      "Belgian 2\n",
      "Kashmiri 20\n",
      "South American 2\n",
      "Bengali 29\n",
      "Iranian 3\n",
      "Lucknowi 13\n",
      "Awadhi 11\n",
      "Nepalese 9\n",
      "Drinks Only 2\n",
      "Oriya 2\n",
      "Bihari 6\n",
      "Assamese 4\n",
      "Andhra 10\n",
      "Mangalorean 4\n",
      "Malwani 1\n",
      "Cuisine Varies 1\n",
      "Moroccan 5\n",
      "Naga 8\n",
      "Sri Lankan 5\n",
      "Peranakan 1\n",
      "Sunda 3\n",
      "Ramen 2\n",
      "Kiwi 6\n",
      "Asian Fusion 2\n",
      "Taiwanese 2\n",
      "Fish and Chips 1\n",
      "Contemporary 9\n",
      "Scottish 3\n",
      "Curry 6\n",
      "Patisserie 4\n",
      "South African 6\n",
      "Durban 1\n",
      "Kebab 10\n",
      "Turkish Pizza 8\n",
      "Izgara 2\n",
      "World Cuisine 4\n",
      "D韄ner 1\n",
      "Restaurant Cafe 4\n",
      "B韄rek 1\n"
     ]
    }
   ],
   "source": [
    "for unit in cuisine_dict:\n",
    "    print(unit,cuisine_dict[unit])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "967426f0",
   "metadata": {},
   "outputs": [],
   "source": [
    "cuisine = [\"Chinese\", \"American\", \"Italian\", \"Mexican\", \"Indian\",\"Mediterranean\",\"Middle Eastern\",\"Breakfast\",\"Korean\",\"Asian\",\"French\",\"Tea\",\"Seafood\",\"Bakery\",\"Street Food\"]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 67,
   "id": "880dd6bf",
   "metadata": {},
   "outputs": [],
   "source": [
    "countries = [\"Chinese\", \"American\", \"Italian\", \"Mexican\", \"Indian\",\"Mediterranean\",\"Middle Eastern\",,\"Korean\",\"Asian\",\"French\"]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 68,
   "id": "89d9aba9",
   "metadata": {},
   "outputs": [],
   "source": [
    "cuisine = [\"Tea\",\"Seafood\",\"Bakery\",\"Street Food\",\"Desserts\",\"BBQ\",\"Street Food\",\"Fast Food\",\"Cafe\",\"Pizza\"]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "ff103725",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.16"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}