-
Notifications
You must be signed in to change notification settings - Fork 0
/
08_notes_ASPs_categorization.sql
1536 lines (1483 loc) · 75.4 KB
/
08_notes_ASPs_categorization.sql
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
----FACEBOOK--------FACEBOOK--------FACEBOOK--------FACEBOOK--------FACEBOOK----
----HOTELS FACEBOOK----
create table fb_base_acc_categories as
WITH fb_hotels AS (
with fb_hotels as
(
select cast('Hotel' as text) as cat_acc, cast(null as text) as sub_cat_acc,
regexp_replace(unaccent(name), '[^a-zA-Z0-9]+|HOTEL|Hotel|hotel|official|website|Kosice|Slovakia' , ' ','g') sub_name,
name, id, district_id, geom
from afbplacetest where name like '%Hotel%' and district_id in ('802', '803', '804', '805')
or name like '%hotel%' and district_id in ('802', '803', '804', '805')
or name like '%HOTEL%' and district_id in ('802', '803', '804', '805')
or name like '%Hilton%' and district_id in ('802', '803', '804', '805')
order by sub_name
)
select id, name,
CASE
WHEN sub_name like '%Boutique%' and sub_cat_acc is null then regexp_replace(sub_name, 'Boutique', ' ', 'g')
WHEN sub_name like '%Garni%' and sub_cat_acc is null then regexp_replace(sub_name, 'Garni', ' ', 'g')
WHEN sub_name like '%Congress%' and sub_cat_acc is null then regexp_replace(sub_name, 'Congress', ' ', 'g')
ELSE
sub_name
END,
cat_acc,
CASE
when sub_cat_acc is null and name like '%Boutique%' then 'Boutique'
when sub_cat_acc is null and name like '%Garni%' then 'Garni'
when sub_cat_acc is null and name like '%Congress%' then 'Congress'
ELSE
sub_cat_acc
END,
district_id, geom
from fb_hotels
order by sub_name),
fb_pension AS (
----GUESTHOUSES PENSION FACEBOOK----
with fb_pensions as
(
select cast('Pension' as text) as cat_acc, cast(null as text) as sub_cat_acc,
regexp_replace(unaccent(name), '[^a-zA-Z0-9]+|Pension|Penzion|Penzión|pension|Kosice' , ' ','g') sub_name,
name, id, district_id, geom
from afbplacetest where
name like '%Pension%' and district_id in ('802', '803', '804', '805')
or name like '%Penzion%' and district_id in ('802', '803', '804', '805')
or name like '%Penzión%' and district_id in ('802', '803', '804', '805')
or name like '%pension%' and district_id in ('802', '803', '804', '805')
or name like '%regia%' and district_id in ('802', '803', '804', '805')
or name like '%Thehan%' and district_id in ('802', '803', '804', '805')
order by sub_name
)
select id, name, sub_name, cat_acc, sub_cat_acc, district_id, geom
from fb_pensions),
fb_hostels AS (
----HOSTELS FACEBOOK----
with fb_hostels as
(
select cast('Hostel' as text) as cat_acc, cast(null as text) as sub_cat_acc,
regexp_replace(unaccent(name), '[^a-zA-Z0-9]+|Hostel|hostel|Ubytovna|ubytovna|Turisticka|Vodna 1 Kosice' , ' ','g') sub_name,
name, id, district_id, geom
from afbplacetest where
name like '%Hostel%' and district_id in ('802', '803', '804', '805')
or name like '%hostel%' and district_id in ('802', '803', '804', '805')
or name like '%Ubytovňa%' and district_id in ('802', '803', '804', '805')
or name like '%ubytovňa%' and district_id in ('802', '803', '804', '805')
or name like '%Ubytovna%' and district_id in ('802', '803', '804', '805')
or name like '%ubytovna%' and district_id in ('802', '803', '804', '805')
or name like '%Inštitút vzdelávania veterinárnych lekárov%' and district_id in ('802', '803', '804', '805')
or website = 'http://www.k2kosice.sk/' and district_id in ('802', '803', '804', '805')
order by sub_name
)
select id, name, sub_name, cat_acc, sub_cat_acc, district_id, geom
from fb_hostels),
fb_private AS (
----PRIVATE FACEBOOK----
WITH fb_private as (
select cast('Private' as text) as cat_acc, cast(null as text) as sub_cat_acc,
regexp_replace(unaccent(name), '[^a-zA-Z0-9]+' , ' ','g') sub_name,
name, id, district_id, geom
from afbplacetest where
name like '%Apartman%' and district_id in ('802', '803', '804', '805')
or name like '%Apartmany%' and district_id in ('802', '803', '804', '805')
or name like '%Apartmány%' and district_id in ('802', '803', '804', '805')
or name like '%Apartmán%' and district_id in ('802', '803', '804', '805')
or name like '%apartmány%' and district_id in ('802', '803', '804', '805')
or name like '%apartmán%' and district_id in ('802', '803', '804', '805')
or name like '%Apartment%' and name not like '%Hotel%' and district_id in ('802', '803', '804', '805')
or name like '%Apartments%' and district_id in ('802', '803', '804', '805')
or name like '%apartment%' and district_id in ('802', '803', '804', '805')
or name like '%apartments%' and district_id in ('802', '803', '804', '805')
or name like '%Studio%' and district_id in ('802', '803', '804', '805')
order by sub_name
)
select id, name,
CASE
WHEN sub_name like '%Apartmany%' and sub_cat_acc is null then regexp_replace(sub_name, 'Apartmany', ' ', 'g')
WHEN sub_name like '%Apartmány%' and sub_cat_acc is null then regexp_replace(sub_name, 'Apartmány', ' ', 'g')
WHEN sub_name like '%Apartmán%' and sub_cat_acc is null then regexp_replace(sub_name, 'Apartmán', ' ', 'g')
WHEN sub_name like '%Apartman%' and sub_cat_acc is null then regexp_replace(sub_name, 'Apartman', ' ', 'g')
WHEN sub_name like '%Apartments%' and sub_cat_acc is null then regexp_replace(sub_name, 'Apartments', ' ', 'g')
WHEN sub_name like '%apartments%' and sub_cat_acc is null then regexp_replace(sub_name, 'apartments', ' ', 'g')
WHEN sub_name like '%Apartment%' and sub_cat_acc is null then regexp_replace(sub_name, 'Apartment', ' ', 'g')
WHEN sub_name like '%Studio%' and sub_cat_acc is null then regexp_replace(sub_name, 'Studio', ' ', 'g')
ELSE
sub_name
END,
cat_acc,
CASE
when sub_cat_acc is null and name like '%Apartmány%' then 'Apartment House'
when sub_cat_acc is null and name like '%Apartmany%' then 'Apartment House'
when sub_cat_acc is null and name like '%Apartmán%' then 'Apartment'
when sub_cat_acc is null and name like '%Apartman%' then 'Apartment'
when sub_cat_acc is null and name like '%Apartments%' then 'Apartment House'
when sub_cat_acc is null and name like '%apartments%' then 'Apartment House'
when sub_cat_acc is null and name like '%Apartment%' then 'Apartment'
when sub_cat_acc is null and name like '%Studio%' then 'Studio'
ELSE
sub_cat_acc
END,
district_id, geom
from fb_private
order by sub_name
)
select * from fb_hotels
union all
select * from fb_pension
union all
select * from fb_hostels
union all
select * from fb_private
select * from afbplacetest where
district_id in ('802', '803', '804', '805') and
name not like '%Penzión%' and
name not like '%Penzion%' and
name not like '%Pension%' and
name not like '%pension%' and
name not like '%Hotel%' and
name not like '%hotel%' and
name not like '%Hostel%' and
name not like '%hostel%' and
name not like '%ubytovňa%' and
name not like '%Ubytovňa%' and
name not like '%Ubytovna%' and
name not like '%ubytovna%' and
name not like '%HOTEL%' and
name not like '%Hilton%' and
name not like '%Villa regia%' and
name not like '%Apartment%' and
name not like '%Apartments%' and
name not like '%apartment%' and
name not like '%apartments%' and
name not like '%Apartman%' and
name not like '%Apartmany%' and
name not like '%Apartmány%' and
name not like '%Apartmán%' and
name not like '%apartmány%' and
name not like '%apartmán%' and
name not like '%Studio%' and
name not like '%Thehan%' and
name not like '%Inštitút vzdelávania veterinárnych lekárov%' and
name not like '%Lacné ubytovanie v centre Košíc%'
-----BOOKING---------BOOKING---------BOOKING---------BOOKING---------BOOKING---------BOOKING---------BOOKING----
-----HOTELS BOOKING
create table bk_base_acc_categories as
with bk_hotels AS (
with bk_hotels as
(
select cast('Hotel' as text) as cat_acc, cast(null as text) as sub_cat_acc,
regexp_replace(unaccent(name), '[^a-zA-Z0-9]+|HOTEL|Hotel|hotel|official|website|Kosice|Slovakia' , ' ','g') sub_name,
name, level_0, district_id, geom
from bookingtest where name like '%Hotel%' and district_id in ('802', '803', '804', '805')
or name like '%hotel%' and district_id in ('802', '803', '804', '805')
or name like '%HOTEL%' and district_id in ('802', '803', '804', '805')
or name like '%Hilton%' and district_id in ('802', '803', '804', '805')
or name like '%Dália Dependance***%' and district_id in ('802', '803', '804', '805')
order by sub_name
)
select level_0, name,
CASE
WHEN sub_name like '%Boutique%' and sub_cat_acc is null then regexp_replace(sub_name, 'Boutique', ' ', 'g')
WHEN sub_name like '%Garni%' and sub_cat_acc is null then regexp_replace(sub_name, 'Garni', ' ', 'g')
WHEN sub_name like '%Congress%' and sub_cat_acc is null then regexp_replace(sub_name, 'Congress', ' ', 'g')
WHEN sub_name like '%Kongres%' and sub_cat_acc is null then regexp_replace(sub_name, 'Congress', ' ', 'g')
ELSE
sub_name
END,
cat_acc,
CASE
when sub_cat_acc is null and name like '%Boutique%' then 'Boutique'
when sub_cat_acc is null and name like '%Garni%' then 'Garni'
when sub_cat_acc is null and name like '%Congress%' then 'Congress'
when sub_cat_acc is null and name like '%Kongres%' then 'Congress'
when sub_cat_acc is null and name like '%Dependance%' then 'Dependance'
ELSE
sub_cat_acc
END,
district_id, geom
from bk_hotels
order by sub_name
),
bk_pension as (
-----GUESTHOUSES PENSIONS BOOKING-----
with bk_pensions as
(
select cast('Pension' as text) as cat_acc, cast(null as text) as sub_cat_acc,
regexp_replace(unaccent(name), '[^a-zA-Z0-9]+|Pension|Penzion|Penzión|pension|Kosice|GUESTHOUSE|guesthouse|Slovakia' , ' ','g') sub_name,
name, level_0, district_id, geom
from bookingtest where
name like '%Pension%' and district_id in ('802', '803', '804', '805')
or name like '%Penzion%' and district_id in ('802', '803', '804', '805')
or name like '%Penzión%' and district_id in ('802', '803', '804', '805')
or name like '%pension%' and district_id in ('802', '803', '804', '805')
or name like '%regia%' and district_id in ('802', '803', '804', '805')
or name like '%Thehan%' and district_id in ('802', '803', '804', '805')
or name like '%penzion%' and district_id in ('802', '803', '804', '805')
or name like '%GUESTHOUSE%' and district_id in ('802', '803', '804', '805')
or name like '%guesthouse%' and district_id in ('802', '803', '804', '805')
order by sub_name
)
select level_0, name, sub_name, cat_acc, sub_cat_acc, district_id, geom
from bk_pensions
),
bk_camps AS (
-----CAMPS BOOKING-----
with bk_camps as
(
select cast('Camp' as text) as cat_acc, cast(null as text) as sub_cat_acc,
regexp_replace(unaccent(name), '[^a-zA-Z0-9]+|camp|camping|kemp|kemping|Camp|Camping|Kemp|Kemping|Kosice|Slovakia' , ' ','g') sub_name,
name, level_0, district_id, geom
from bookingtest where
name like '%camp%' and district_id in ('802', '803', '804', '805')
or name like '%camping%' and district_id in ('802', '803', '804', '805')
or name like '%kemp%' and district_id in ('802', '803', '804', '805')
or name like '%kemp%' and district_id in ('802', '803', '804', '805')
or name like '%kemping%' and district_id in ('802', '803', '804', '805')
or name like '%Camp%' and district_id in ('802', '803', '804', '805')
or name like '%Camping%' and district_id in ('802', '803', '804', '805')
or name like '%Kemping%' and district_id in ('802', '803', '804', '805')
order by sub_name
)
select level_0, name, sub_name, cat_acc, sub_cat_acc, district_id, geom
from bk_camps
),
-----HOSTELS BOOKING-----
bk_hostels as (
with bk_hostels as
(
select cast('Hostel' as text) as cat_acc, cast(null as text) as sub_cat_acc,
regexp_replace(unaccent(name), '[^a-zA-Z0-9]+|Hostel|hostel|Ubytovna|ubytovna|Turisticka|Vodna 1 Kosice' , ' ','g') sub_name,
name, level_0, district_id, geom
from bookingtest where
name like '%Hostel%' and district_id in ('802', '803', '804', '805')
or name like '%hostel%' and district_id in ('802', '803', '804', '805')
or name like '%Ubytovňa%' and district_id in ('802', '803', '804', '805')
or name like '%ubytovňa%' and district_id in ('802', '803', '804', '805')
or name like '%Ubytovna%' and district_id in ('802', '803', '804', '805')
or name like '%ubytovna%' and district_id in ('802', '803', '804', '805')
or name like '%ŠD%' and district_id in ('802', '803', '804', '805')
or name like '%WHITE CORAL CLUB%' and district_id in ('802', '803', '804', '805')
order by sub_name
)
select level_0, name, sub_name, cat_acc,
CASE
when sub_cat_acc is null and name like '%ŠD%' then 'student home'
ELSE
sub_cat_acc
END, district_id, geom
from bk_hostels
order by sub_name
),
bk_private as (
-----PRIVATE MAIN BOOKING-----
WITH bk_private as (
select cast('Private' as text) as cat_acc, cast(null as text) as sub_cat_acc,
regexp_replace(unaccent(name), '[^a-zA-Z0-9]+' , ' ','g') sub_name,
name, level_0, district_id, geom
from bookingtest where
name like '%Apartman%' and district_id in ('802', '803', '804', '805')
or name like '%Apartmany%' and district_id in ('802', '803', '804', '805')
or name like '%Apartmány%' and district_id in ('802', '803', '804', '805')
or name like '%Apartmán%' and district_id in ('802', '803', '804', '805')
or name like '%apartmány%' and district_id in ('802', '803', '804', '805')
or name like '%apartmán%' and district_id in ('802', '803', '804', '805')
or name like '%apartman%' and district_id in ('802', '803', '804', '805')
or name like '%Apartment%' and name not like '%Hotel%' and district_id in ('802', '803', '804', '805')
or name like '%Apartments%' and district_id in ('802', '803', '804', '805')
or name like '%apartment%' and name not like '%Hotel%' and district_id in ('802', '803', '804', '805')
or name like '%aparment%' and name not like '%Hotel%' and district_id in ('802', '803', '804', '805')
or name like '%apartments%' and district_id in ('802', '803', '804', '805')
or name like '%Appartment%' and district_id in ('802', '803', '804', '805')
or name like '%APARTMENT%' and district_id in ('802', '803', '804', '805')
or name like '%Apartmen%' and name not like '%Hotel%' and district_id in ('802', '803', '804', '805')
or name like '%Villa Park Komenského%' and district_id in ('802', '803', '804', '805')
or name like '%Villa%' and district_id in ('802', '803', '804', '805') and name not like ('Villa Park Komenského') and name not like ('%Penzion Villa%')
or name like '%Vila%' and district_id in ('802', '803', '804', '805') and name not like ('Villa Park Komenského') and name not like ('%Penzion Villa%')
or name like '%Studio%' and district_id in ('802', '803', '804', '805')
or name like '%studio%' and district_id in ('802', '803', '804', '805')
or name like '%Štúdio%' and district_id in ('802', '803', '804', '805')
or name like '%štúdio%' and district_id in ('802', '803', '804', '805')
or name like '%študio%' and district_id in ('802', '803', '804', '805')
or name like '%Študio%' and district_id in ('802', '803', '804', '805')
or name like 'House%' and district_id in ('802', '803', '804', '805')
or name like '% dom%' and district_id in ('802', '803', '804', '805')
or name like '%Apt%' and district_id in ('802', '803', '804', '805')
or name like '%cottage%' and district_id in ('802', '803', '804', '805')
or name like '%Cottage%' and district_id in ('802', '803', '804', '805')
order by name
)
select level_0, name,
CASE
WHEN sub_name like '%Apartmany%' and sub_cat_acc is null then regexp_replace(sub_name, 'Apartmany', ' ', 'g')
WHEN sub_name like '%Apartmány%' and sub_cat_acc is null then regexp_replace(sub_name, 'Apartmány', ' ', 'g')
WHEN sub_name like '%Apartmán%' and sub_cat_acc is null then regexp_replace(sub_name, 'Apartmán', ' ', 'g')
WHEN sub_name like '%Apartman%' and sub_cat_acc is null then regexp_replace(sub_name, 'Apartman', ' ', 'g')
WHEN sub_name like '%Apartments%' and sub_cat_acc is null then regexp_replace(sub_name, 'Apartments', ' ', 'g')
WHEN sub_name like '%apartments%' and sub_cat_acc is null then regexp_replace(sub_name, 'apartments', ' ', 'g')
WHEN sub_name like '%Apartment%' and sub_cat_acc is null then regexp_replace(sub_name, 'Apartment', ' ', 'g')
WHEN sub_name like '%apartment%' and sub_cat_acc is null then regexp_replace(sub_name, 'apartment', ' ', 'g')
WHEN sub_name like '%apartman%' and sub_cat_acc is null then regexp_replace(sub_name, 'apartman', ' ', 'g')
WHEN sub_name like '%APARTMENT%' and sub_cat_acc is null then regexp_replace(sub_name, 'APARTMENT', ' ', 'g')
WHEN sub_name like '%Appartment%' and sub_cat_acc is null then regexp_replace(sub_name, 'Appartment', ' ', 'g')
WHEN sub_name like '%Apartmen%' and sub_cat_acc is null then regexp_replace(sub_name, 'Apartmen', ' ', 'g')
WHEN sub_name like '%Studio%' and sub_cat_acc is null then regexp_replace(sub_name, 'Studio', ' ', 'g')
WHEN sub_name like '%studio%' and sub_cat_acc is null then regexp_replace(sub_name, 'studio', ' ', 'g')
WHEN sub_name like '%Štúdio%' and sub_cat_acc is null then regexp_replace(sub_name, 'Štúdio', ' ', 'g')
WHEN sub_name like '%štúdio%' and sub_cat_acc is null then regexp_replace(sub_name, 'štúdio', ' ', 'g')
WHEN sub_name like '%študio%' and sub_cat_acc is null then regexp_replace(sub_name, 'študio', ' ', 'g')
WHEN sub_name like '%Študio%' and sub_cat_acc is null then regexp_replace(sub_name, 'Študio', ' ', 'g')
WHEN sub_name like '%Apt%' and sub_cat_acc is null then regexp_replace(sub_name, 'Apt', ' ', 'g')
ELSE
sub_name
END,
cat_acc,
CASE
when sub_cat_acc is null and name like '%Apartmány%' then 'Apartment House'
when sub_cat_acc is null and name like '%Apartmany%' then 'Apartment House'
when sub_cat_acc is null and name like '%Apartmán%' then 'Apartment'
when sub_cat_acc is null and name like '%Apartman%' then 'Apartment'
when sub_cat_acc is null and name like '%Apartments%' then 'Apartment House'
when sub_cat_acc is null and name like '%apartments%' then 'Apartment House'
when sub_cat_acc is null and name like '%apartment%' then 'Apartment'
when sub_cat_acc is null and name like '%Apartmen%' then 'Apartment'
when sub_cat_acc is null and name like '%apartman%' then 'Apartment'
when sub_cat_acc is null and name like '%Apartment%' then 'Apartment'
when sub_cat_acc is null and name like '%APARTMENT%' then 'Apartment'
when sub_cat_acc is null and name like '%Appartment%' then 'Apartment'
when sub_cat_acc is null and name like '%Studio%' then 'Studio'
when sub_cat_acc is null and name like '%studio%' then 'Studio'
when sub_cat_acc is null and name like '%Štúdio%' then 'Studio'
when sub_cat_acc is null and name like '%štúdio%' then 'Studio'
when sub_cat_acc is null and name like '%Študio%' then 'Studio'
when sub_cat_acc is null and name like '%študio%' then 'Studio'
when sub_cat_acc is null and name like '%Vila%' then 'Villa'
when sub_cat_acc is null and name like '%Villa%' and name not like '%Park Komenského%' then 'Villa'
when sub_cat_acc is null and name like 'House%' then 'House'
when sub_cat_acc is null and name like '% dom%' then 'House'
when sub_cat_acc is null and name like '% Apt%' then 'Apartment'
when sub_cat_acc is null and name like '%cottage%' then 'Cottage'
when sub_cat_acc is null and name like '%Cottage%' then 'Cottage'
when sub_cat_acc is null and name like '%Villa Park Komenského%' then 'Apartment House'
ELSE
sub_cat_acc
END, district_id, geom
from bk_private
order by name
),
bk_private_rest as (
-----PRIVATE REST BOOKING--
select level_0, name, name as subname, cast('Private' as text) as cat_acc, cast('Apartment' as text) as sub_cat_acc, district_id, geom from bookingtest where
district_id in ('802', '803', '804', '805') and
name not like '%Hotel%' and
name not like '%hotel%' and
name not like '%HOTEL%' and
name not like '%Hilton%' and
name not like '%Dependance%'
and
name not like '%Penzión%' and
name not like '%Penzion%' and
name not like '%Pension%' and
name not like '%pension%' and
name not like '%GUESTHOUSE%' and
name not like '%guesthouse%' and
name not like '%Villa regia%'
and
name not like '%Hostel%' and
name not like '%hostel%' and
name not like '%ubytovňa%' and
name not like '%Ubytovňa%' and
name not like '%Ubytovna%' and
name not like '%ubytovna%' and
name not like '%ŠD%' and
name not like '%WHITE CORAL CLUB%'
and
name not like '%Camp%' and
name not like '%Camping%' and
name not like '%camping%' and
name not like '%camp%' and
name not like '%kemping%' and
name not like '%Kemping%' and
name not like '%Kemp%' and
name not like '%kemp%'
and
name not like '%Apartment%' and
name not like '%Apartments%' and
name not like '%apartment%' and
name not like '%apartments%' and
name not like '%Apartman%' and
name not like '%Apartmany%' and
name not like '%Apartmány%' and
name not like '%Apartmán%' and
name not like '%apartmány%' and
name not like '%apartmán%' and
name not like '%apartman%' and
name not like '%Studio%' and
name not like '%studio%' and
name not like '%Štúdio%' and
name not like '%štúdio%' and
name not like '%Študio%' and
name not like '%študio%' and
name not like '%Thehan%' and
name not like '%Apartmen%' and
name not like '%aparment%' and
name not like '%APARTMENT%' and
name not like '%Appartment%' and
name not like '%Apt%' and
name not like '%Villa Park Komenského%' and
name not like '%Villa%' and
name not like '%Vila%' and
name not like 'House%' and
name not like '%Villa%'
and
name not like '%Cottage%' and
name not like '%cottage%' and
name <> 'Pekný dom' and
name <> 'City Residence Apartment Hotel'
order by name
)
select * from bk_hotels
union all
select * from bk_pension
union all
select * from bk_camps
union all
select * from bk_hostels
union all
select * from bk_private
union all
select * from bk_private_rest
order by cat_acc, name
--------GOOGLE PLACES ---------------GOOGLE PLACES ---------------GOOGLE PLACES ---------------GOOGLE PLACES -------
--select * from googleplacestest where district_id in ('802', '803', '804', '805')
-----HOTELS GOOGLE PLACES-----
create table gg_base_acc_categories as
with gg_hotels as (
with gg_hotels as
(
select cast('Hotel' as text) as cat_acc, cast(null as text) as sub_cat_acc,
regexp_replace(unaccent(name), '[^a-zA-Z0-9]+|HOTEL|Hotel|hotel|official|website|Kosice|Slovakia' , ' ','g') sub_name,
name, level_0, district_id, geom
from googleplacestest where name like '%Hotel%' and district_id in ('802', '803', '804', '805')
or name like '%hotel%' and district_id in ('802', '803', '804', '805')
or name like '%HOTEL%' and district_id in ('802', '803', '804', '805')
or name like '%Hilton%' and district_id in ('802', '803', '804', '805')
or name like '%Dália Dependance***%' and district_id in ('802', '803', '804', '805')
or name in ('Zlaty Dukat', 'Gloria palace', 'Boutique Chrysso') and district_id in ('802', '803', '804', '805')
order by sub_name
)
select level_0, name,
CASE
WHEN sub_name like '%Boutique%' and sub_cat_acc is null then regexp_replace(sub_name, 'Boutique', ' ', 'g')
WHEN sub_name like '%Garni%' and sub_cat_acc is null then regexp_replace(sub_name, 'Garni', ' ', 'g')
WHEN sub_name like '%Congress%' and sub_cat_acc is null then regexp_replace(sub_name, 'Congress', ' ', 'g')
WHEN sub_name like '%Kongres%' and sub_cat_acc is null then regexp_replace(sub_name, 'Congress', ' ', 'g')
ELSE
sub_name
END,
cat_acc,
CASE
when sub_cat_acc is null and name like '%Boutique%' then 'Boutique'
when sub_cat_acc is null and name like '%Garni%' then 'Garni'
when sub_cat_acc is null and name like '%Congress%' then 'Congress'
when sub_cat_acc is null and name like '%Kongres%' then 'Congress'
when sub_cat_acc is null and name like '%Dependance%' then 'Dependance'
ELSE
sub_cat_acc
END, district_id, geom
from gg_hotels
order by sub_name
),
gg_pension as (
-----GUESTHOUSE PENSIONS GOOGLE PLACES-----
with gg_pensions as
(
select cast('Pension' as text) as cat_acc, cast(null as text) as sub_cat_acc,
regexp_replace(unaccent(name), '[^a-zA-Z0-9]+|Pension|Penzion|Penzión|pension|Kosice|GUESTHOUSE|guesthouse|Slovakia' , ' ','g') sub_name,
name, level_0, district_id, geom
from googleplacestest where
name like '%Pension%' and district_id in ('802', '803', '804', '805')
or name like '%Penzion%' and district_id in ('802', '803', '804', '805')
or name like '%Penzión%' and district_id in ('802', '803', '804', '805')
or name like '%pension%' and district_id in ('802', '803', '804', '805')
or name like '%regia%' and district_id in ('802', '803', '804', '805')
or name like '%Thehan%' and district_id in ('802', '803', '804', '805')
or name like '%penzion%' and district_id in ('802', '803', '804', '805')
or name like '%GUESTHOUSE%' and district_id in ('802', '803', '804', '805')
or name like '%guesthouse%' and district_id in ('802', '803', '804', '805')
or name in ('Hradbová', 'Zlatý Jeleň', 'Horse Inn') and district_id in ('802', '803', '804', '805')
order by sub_name
)
select level_0, name, sub_name, cat_acc, sub_cat_acc, district_id, geom
from gg_pensions
),
gg_camps as (
-----CAMPS Google PLaces-----
with gg_camps as
(
select cast('Camp' as text) as cat_acc, cast(null as text) as sub_cat_acc,
regexp_replace(unaccent(name), '[^a-zA-Z0-9]+|camp|camping|kemp|kemping|Camp|Camping|Kemp|Kemping|Kosice|Slovakia' , ' ','g') sub_name,
name, level_0, district_id, geom
from googleplacestest where
name like '%camp%' and district_id in ('802', '803', '804', '805')
or name like '%camping%' and district_id in ('802', '803', '804', '805')
or name like '%kemp%' and district_id in ('802', '803', '804', '805')
or name like '%kemp%' and district_id in ('802', '803', '804', '805')
or name like '%kemping%' and district_id in ('802', '803', '804', '805')
or name like '%Camp%' and district_id in ('802', '803', '804', '805')
or name like '%Camping%' and district_id in ('802', '803', '804', '805')
or name like '%Kemping%' and district_id in ('802', '803', '804', '805')
order by sub_name
)
select level_0, name, sub_name, cat_acc, sub_cat_acc, district_id, geom
from gg_camps
),
gg_hostels as (
-----HOSTELS GOOGLE PLACES-----
with gg_hostels as
(
select cast('Hostel' as text) as cat_acc, cast(null as text) as sub_cat_acc,
regexp_replace(unaccent(name), '[^a-zA-Z0-9]+|Hostel|hostel|Ubytovna|ubytovna|Turisticka|Vodna 1 Kosice' , ' ','g') sub_name,
name, level_0, district_id, geom
from googleplacestest where
name like '%Hostel%' and district_id in ('802', '803', '804', '805')
or name like '%HOSTEL%' and district_id in ('802', '803', '804', '805')
or name like '%hostel%' and district_id in ('802', '803', '804', '805')
or name like '%Ubytovňa%' and district_id in ('802', '803', '804', '805')
or name like '%ubytovňa%' and district_id in ('802', '803', '804', '805')
or name like '%Ubytovna%' and district_id in ('802', '803', '804', '805')
or name like '%ubytovna%' and district_id in ('802', '803', '804', '805')
or name like '%ŠD%' and district_id in ('802', '803', '804', '805')
or name like '%WHITE CORAL CLUB%' and district_id in ('802', '803', '804', '805')
or name like '%Dormitory%' and district_id in ('802', '803', '804', '805')
or name like '%Internat%' and district_id in ('802', '803', '804', '805')
or name like '%Internáty%' and district_id in ('802', '803', '804', '805')
or name like '%Internát%' and district_id in ('802', '803', '804', '805')
or name like '%Institute%' and district_id in ('802', '803', '804', '805')
or name like '%Internaty%' and district_id in ('802', '803', '804', '805')
or name like '%internát%' and district_id in ('802', '803', '804', '805')
or name like '%internat%' and district_id in ('802', '803', '804', '805')
or name like '%Jedlíkova 13%' and district_id in ('802', '803', '804', '805')
or name = 'Budget & Students' and district_id in ('802', '803', '804', '805')
or name in ('Ubytovanie Jánošík Pub', 'City Building Ltd.') and district_id in ('802', '803', '804', '805')
order by sub_name
)
select level_0, name, sub_name, cat_acc,
CASE
when sub_cat_acc is null and name like '%ŠD%' then 'student home'
when sub_cat_acc is null and name like '%Dormitory%' then 'student home'
when sub_cat_acc is null and name like '%Internat%' then 'student home'
when sub_cat_acc is null and name like '%Internáty%' then 'student home'
when sub_cat_acc is null and name like '%Institute%' then 'student home'
when sub_cat_acc is null and name like '%Internaty%' then 'student home'
when sub_cat_acc is null and name like '%Internát%' then 'student home'
when sub_cat_acc is null and name like '%internát%' then 'student home'
when sub_cat_acc is null and name like '%internat%' then 'student home'
when sub_cat_acc is null and name like '%Jedlíkova 13%' then 'student home'
ELSE
sub_cat_acc
END, district_id, geom
from gg_hostels
order by sub_cat_acc
),
gg_private as(
-----PRIVATE MAIN GOOGLE PLACES-----
WITH gg_private as (
select cast('Private' as text) as cat_acc, cast(null as text) as sub_cat_acc,
regexp_replace(unaccent(name), '[^a-zA-Z0-9]+' , ' ','g') sub_name,
name, level_0, district_id, geom
from googleplacestest where
name like '%Apartman%' and district_id in ('802', '803', '804', '805')
or name like '%Apartmany%' and district_id in ('802', '803', '804', '805')
or name like '%Apartmány%' and district_id in ('802', '803', '804', '805')
or name like '%Apartmán%' and district_id in ('802', '803', '804', '805')
or name like '%apartmány%' and district_id in ('802', '803', '804', '805')
or name like '%apartmán%' and district_id in ('802', '803', '804', '805')
or name like '%apartman%' and district_id in ('802', '803', '804', '805')
or name like '%Apartment%' and name not like '%Hotel%' and district_id in ('802', '803', '804', '805')
or name like '%Apartments%' and district_id in ('802', '803', '804', '805')
or name like '%apartments%' and district_id in ('802', '803', '804', '805')
or name like '%apartment%' and name not like '%Hotel%' and district_id in ('802', '803', '804', '805')
or name like '%Appartment%' and district_id in ('802', '803', '804', '805')
or name like '%APARTMENT%' and name not like '%Hotel%' and district_id in ('802', '803', '804', '805')
or name like '%Apartmen%' and name not like '%Hotel%' and district_id in ('802', '803', '804', '805')
or name like '%Villa Park Komenského%' and district_id in ('802', '803', '804', '805')
or name like '%Villa%' and district_id in ('802', '803', '804', '805') and name not like ('Villa Park Komenského') and name not like ('%Penzion Villa%')
or name like '%Vila%' and district_id in ('802', '803', '804', '805') and name not like ('Villa Park Komenského') and name not like ('%Penzion Villa%')
or name like '%Studio%' and district_id in ('802', '803', '804', '805')
or name like '%studio%' and district_id in ('802', '803', '804', '805')
or name like '%Štúdio%' and district_id in ('802', '803', '804', '805')
or name like '%štúdio%' and district_id in ('802', '803', '804', '805')
or name like '%študio%' and district_id in ('802', '803', '804', '805')
or name like '%Študio%' and district_id in ('802', '803', '804', '805')
or name like 'House%' and district_id in ('802', '803', '804', '805')
or name like '% dom%' and district_id in ('802', '803', '804', '805')
or name like '%Apt%' and district_id in ('802', '803', '804', '805')
or name like '%cottage%' and district_id in ('802', '803', '804', '805')
or name like '%Cottage%' and district_id in ('802', '803', '804', '805')
or name like '%Chata%' and district_id in ('802', '803', '804', '805')
or name = 'Záhrada Zverina' and district_id in ('802', '803', '804', '805')
order by sub_name
)
select level_0, name,
CASE
WHEN sub_name like '%Apartmany%' and sub_cat_acc is null then regexp_replace(sub_name, 'Apartmany', ' ', 'g')
WHEN sub_name like '%Apartmány%' and sub_cat_acc is null then regexp_replace(sub_name, 'Apartmány', ' ', 'g')
WHEN sub_name like '%Apartmán%' and sub_cat_acc is null then regexp_replace(sub_name, 'Apartmán', ' ', 'g')
WHEN sub_name like '%Apartman%' and sub_cat_acc is null then regexp_replace(sub_name, 'Apartman', ' ', 'g')
WHEN sub_name like '%Apartments%' and sub_cat_acc is null then regexp_replace(sub_name, 'Apartments', ' ', 'g')
WHEN sub_name like '%apartments%' and sub_cat_acc is null then regexp_replace(sub_name, 'apartments', ' ', 'g')
WHEN sub_name like '%Apartment%' and sub_cat_acc is null then regexp_replace(sub_name, 'Apartment', ' ', 'g')
WHEN sub_name like '%apartment%' and sub_cat_acc is null then regexp_replace(sub_name, 'apartment', ' ', 'g')
WHEN sub_name like '%apartman%' and sub_cat_acc is null then regexp_replace(sub_name, 'apartman', ' ', 'g')
WHEN sub_name like '%APARTMENT%' and sub_cat_acc is null then regexp_replace(sub_name, 'APARTMENT', ' ', 'g')
WHEN sub_name like '%Appartment%' and sub_cat_acc is null then regexp_replace(sub_name, 'Appartment', ' ', 'g')
WHEN sub_name like '%Apartmen%' and sub_cat_acc is null then regexp_replace(sub_name, 'Apartmen', ' ', 'g')
WHEN sub_name like '%Studio%' and sub_cat_acc is null then regexp_replace(sub_name, 'Studio', ' ', 'g')
WHEN sub_name like '%studio%' and sub_cat_acc is null then regexp_replace(sub_name, 'studio', ' ', 'g')
WHEN sub_name like '%Štúdio%' and sub_cat_acc is null then regexp_replace(sub_name, 'Štúdio', ' ', 'g')
WHEN sub_name like '%štúdio%' and sub_cat_acc is null then regexp_replace(sub_name, 'štúdio', ' ', 'g')
WHEN sub_name like '%študio%' and sub_cat_acc is null then regexp_replace(sub_name, 'študio', ' ', 'g')
WHEN sub_name like '%Študio%' and sub_cat_acc is null then regexp_replace(sub_name, 'Študio', ' ', 'g')
WHEN sub_name like '%Apt%' and sub_cat_acc is null then regexp_replace(sub_name, 'Apt', ' ', 'g')
ELSE
sub_name
END,
cat_acc,
CASE
when sub_cat_acc is null and name like '%Apartmány%' then 'Apartment House'
when sub_cat_acc is null and name like '%Apartmany%' then 'Apartment House'
when sub_cat_acc is null and name like '%Apartmán%' then 'Apartment'
when sub_cat_acc is null and name like '%Apartman%' then 'Apartment'
when sub_cat_acc is null and name like '%Apartments%' then 'Apartment House'
when sub_cat_acc is null and name like '%apartments%' then 'Apartment House'
when sub_cat_acc is null and name like '%apartment%' then 'Apartment'
when sub_cat_acc is null and name like '%Apartmen%' then 'Apartment'
when sub_cat_acc is null and name like '%apartman%' then 'Apartment'
when sub_cat_acc is null and name like '%Apartment%' then 'Apartment'
when sub_cat_acc is null and name like '%APARTMENT%' then 'Apartment'
when sub_cat_acc is null and name like '%Appartment%' then 'Apartment'
when sub_cat_acc is null and name like '%Studio%' then 'Studio'
when sub_cat_acc is null and name like '%studio%' then 'Studio'
when sub_cat_acc is null and name like '%Štúdio%' then 'Studio'
when sub_cat_acc is null and name like '%štúdio%' then 'Studio'
when sub_cat_acc is null and name like '%Študio%' then 'Studio'
when sub_cat_acc is null and name like '%študio%' then 'Studio'
when sub_cat_acc is null and name like '%Vila%' then 'Villa'
when sub_cat_acc is null and name like '%Villa%' and name not like '%Park Komenského%' then 'Villa'
when sub_cat_acc is null and name like 'House%' then 'House'
when sub_cat_acc is null and name like '% dom%' then 'House'
when sub_cat_acc is null and name like '% Apt%' then 'Apartment'
when sub_cat_acc is null and name like '%cottage%' then 'Cottage'
when sub_cat_acc is null and name like '%Cottage%' then 'Cottage'
when sub_cat_acc is null and name like '%Chata%' then 'Cottage'
when sub_cat_acc is null and name like '%chata%' then 'Cottage'
when sub_cat_acc is null and name = 'Záhrada Zverina' then 'Cottage'
when sub_cat_acc is null and name like '%Villa Park Komenského%' then 'Apartment House'
ELSE
sub_cat_acc
END, district_id, geom
from gg_private
order by sub_cat_acc
),
gg_private_rest as (
select level_0, name, name as subname, cast('Private' as text) as cat_acc, cast('Apartment' as text) as sub_cat_acc, district_id, geom
from googleplacestest where
district_id in ('802', '803', '804', '805') and
name not like '%Hotel%' and
name not like '%hotel%' and
name not like '%HOTEL%' and
name not like '%Hilton%' and
name not like '%Dependance%' and
name not in ('Zlaty Dukat', 'Gloria palace', 'Boutique Chrysso')
and
name not like '%Penzión%' and
name not like '%Penzion%' and
name not like '%Pension%' and
name not like '%pension%' and
name not like '%GUESTHOUSE%' and
name not like '%guesthouse%' and
name not like '%Villa regia%' and
name not like '%Zlatý Jeleň%' and
name not like '%Horse Inn%' and
name <> 'Hradbová'
and
name not like '%Hostel%' and
name not like '%hostel%' and
name not like '%ubytovňa%' and
name not like '%Ubytovňa%' and
name not like '%Ubytovna%' and
name not like '%ubytovna%' and
name not like '%HOSTEL%' and
name not like '%ŠD%' and
name not like '%WHITE CORAL CLUB%' and
name not like '%Internaty%' and
name not like '%Dormitory%' and
name not like '%Internat%' and
name not like '%Internát%' and
name not like '%Internáty%' and
name not like '%internát%' and
name not like '%internat%' and
name not like '%Institute%' and
name not like 'Jedlíkova 13' and
name <> 'Budget & Students' and
name <> 'City Building Ltd.' and
name <> 'Ubytovanie Jánošík Pub'
and
name not like '%Camp%' and
name not like '%Camping%' and
name not like '%camping%' and
name not like '%camp%' and
name not like '%kemping%' and
name not like '%Kemping%' and
name not like '%Kemp%' and
name not like '%kemp%'
and
name not like '%Apartment%' and
name not like '%Apartments%' and
name not like '%apartment%' and
name not like '%apartments%' and
name not like '%Apartman%' and
name not like '%Apartmany%' and
name not like '%Apartmány%' and
name not like '%Apartmán%' and
name not like '%apartmány%' and
name not like '%apartmán%' and
name not like '%apartman%' and
name not like '%Studio%' and
name not like '%studio%' and
name not like '%Štúdio%' and
name not like '%štúdio%' and
name not like '%Študio%' and
name not like '%študio%' and
name not like '%Thehan%' and
name not like '%Apartmen%' and
name not like '%aparment%' and
name not like '%APARTMENT%' and
name not like '%Appartment%' and
name not like '%Apt%' and
name not like '%Villa Park Komenského%' and
name not like '%Villa%' and
name not like '%Vila%' and
name not like 'House%' and
name not like '%Villa%'
and
name not like '%Cottage%' and
name not like '%cottage%' and
name not like '%Chata%' and
name not like '%chata%' and
name <> 'Záhrada Zverina'
order by name
)
select * from gg_hotels
union all
select * from gg_pension
union all
select * from gg_camps
union all
select * from gg_hostels
union all
select * from gg_private
union all
select * from gg_private_rest
------FOURSQUARE------FOURSQUARE------FOURSQUARE------FOURSQUARE------FOURSQUARE------FOURSQUARE
---HOTELS FOURSQUARE
--set work_mem = '512MB'
--select * from forsquaretest where district_id in ('802', '803', '804', '805')
create table fq_base_acc_categories as
with fq_hotels as (
with fq_hotels as
(
select cast('Hotel' as text) as cat_acc, cast(null as text) as sub_cat_acc,
regexp_replace(unaccent(name), '[^a-zA-Z0-9]+|HOTEL|Hotel|hotel|official|website|Kosice|Slovakia' , ' ','g') sub_name,
name, level_0, district_id, geom
from forsquaretest where name like '%Hotel%' and district_id in ('802', '803', '804', '805')
or name like '%hotel%' and district_id in ('802', '803', '804', '805')
or name like '%HOTEL%' and district_id in ('802', '803', '804', '805')
or name like '%Hilton%' and district_id in ('802', '803', '804', '805')
or name like '%Dália Dependance***%' and district_id in ('802', '803', '804', '805')
or name in ('Zlaty Dukat', 'Gloria palace', 'Boutique Chrysso') and district_id in ('802', '803', '804', '805')
order by sub_name
)
select level_0, name,
CASE
WHEN sub_name like '%Boutique%' and sub_cat_acc is null then regexp_replace(sub_name, 'Boutique', ' ', 'g')
WHEN sub_name like '%Garni%' and sub_cat_acc is null then regexp_replace(sub_name, 'Garni', ' ', 'g')
WHEN sub_name like '%Congress%' and sub_cat_acc is null then regexp_replace(sub_name, 'Congress', ' ', 'g')
WHEN sub_name like '%Kongres%' and sub_cat_acc is null then regexp_replace(sub_name, 'Congress', ' ', 'g')
ELSE
sub_name
END,
cat_acc,
CASE
when sub_cat_acc is null and name like '%Boutique%' then 'Boutique'
when sub_cat_acc is null and name like '%Garni%' then 'Garni'
when sub_cat_acc is null and name like '%Congress%' then 'Congress'
when sub_cat_acc is null and name like '%Kongres%' then 'Congress'
when sub_cat_acc is null and name like '%Dependance%' then 'Dependance'
ELSE
sub_cat_acc
END, district_id, geom
from fq_hotels
order by sub_name
),
fq_pension as (
---FORSQUARE PENSIONS
with fq_pensions as
(
select cast('Pension' as text) as cat_acc, cast(null as text) as sub_cat_acc,
regexp_replace(unaccent(name), '[^a-zA-Z0-9]+|Pension|Penzion|Penzión|pension|Kosice|GUESTHOUSE|guesthouse|Slovakia' , ' ','g') sub_name,
name, level_0, district_id, geom
from forsquaretest where
name like '%Pension%' and district_id in ('802', '803', '804', '805')
or name like '%Penzion%' and district_id in ('802', '803', '804', '805')
or name like '%Penzión%' and district_id in ('802', '803', '804', '805')
or name like '%pension%' and district_id in ('802', '803', '804', '805')
or name like '%regia%' and district_id in ('802', '803', '804', '805')
or name like '%Thehan%' and district_id in ('802', '803', '804', '805')
or name like '%penzion%' and district_id in ('802', '803', '804', '805')
or name like '%penzión%' and district_id in ('802', '803', '804', '805')
or name like '%GUESTHOUSE%' and district_id in ('802', '803', '804', '805')
or name like '%guesthouse%' and district_id in ('802', '803', '804', '805')
or name in ('Hradbová', 'Zlatý Jeleň', 'Horse Inn') and district_id in ('802', '803', '804', '805')
order by sub_name
)
select level_0, name, sub_name, cat_acc, sub_cat_acc, district_id, geom
from fq_pensions
),
fq_hostels as (
---FORSQUARE HOSTELS
with fq_hostels as
(
select cast('Hostel' as text) as cat_acc, cast(null as text) as sub_cat_acc,
regexp_replace(unaccent(name), '[^a-zA-Z0-9]+|Hostel|hostel|Ubytovna|ubytovna|Turisticka|Vodna 1 Kosice' , ' ','g') sub_name,
name, level_0, district_id, geom
from forsquaretest where
name like '%Hostel%' and district_id in ('802', '803', '804', '805')
or name like '%HOSTEL%' and district_id in ('802', '803', '804', '805')
or name like '%hostel%' and district_id in ('802', '803', '804', '805')
or name like '%Ubytovňa%' and district_id in ('802', '803', '804', '805')
or name like '%ubytovňa%' and district_id in ('802', '803', '804', '805')
or name like '%Ubytovna%' and district_id in ('802', '803', '804', '805')
or name like '%ubytovna%' and district_id in ('802', '803', '804', '805')
or name like '%ŠD%' and district_id in ('802', '803', '804', '805')
or name like '%WHITE CORAL CLUB%' and district_id in ('802', '803', '804', '805')
or name like '%Dormitory%' and district_id in ('802', '803', '804', '805')
or name like '%Internat%' and district_id in ('802', '803', '804', '805')
or name like '%Internáty%' and district_id in ('802', '803', '804', '805')
or name like '%Internát%' and district_id in ('802', '803', '804', '805')
or name like '%Institute%' and district_id in ('802', '803', '804', '805')
or name like '%Internaty%' and district_id in ('802', '803', '804', '805')
or name like '%internát%' and district_id in ('802', '803', '804', '805')
or name like '%internat%' and district_id in ('802', '803', '804', '805')
or name like '%Jedlíkova 13%' and district_id in ('802', '803', '804', '805')
or name = 'Budget & Students' and district_id in ('802', '803', '804', '805')
or name in ('Ubytovanie Jánošík Pub', 'City Building Ltd.') and district_id in ('802', '803', '804', '805')
order by sub_name
)
select level_0, name, sub_name, cat_acc,
CASE
when sub_cat_acc is null and name like '%ŠD%' then 'student home'
when sub_cat_acc is null and name like '%Dormitory%' then 'student home'
when sub_cat_acc is null and name like '%Internat%' then 'student home'
when sub_cat_acc is null and name like '%Internáty%' then 'student home'
when sub_cat_acc is null and name like '%Institute%' then 'student home'
when sub_cat_acc is null and name like '%Internaty%' then 'student home'
when sub_cat_acc is null and name like '%Internát%' then 'student home'
when sub_cat_acc is null and name like '%internát%' then 'student home'
when sub_cat_acc is null and name like '%internat%' then 'student home'
when sub_cat_acc is null and name like '%Jedlíkova 13%' then 'student home'
ELSE
sub_cat_acc
END, district_id, geom
from fq_hostels
order by sub_cat_acc
),
fq_private as (
--FORSQUARE PRIVATE
WITH fq_private as (
select cast('Private' as text) as cat_acc, cast(null as text) as sub_cat_acc,
regexp_replace(unaccent(name), '[^a-zA-Z0-9]+' , ' ','g') sub_name,
name, level_0, district_id, geom
from forsquaretest where
name like '%Apartman%' and district_id in ('802', '803', '804', '805')
or name like '%Apartmany%' and district_id in ('802', '803', '804', '805')
or name like '%Apartmány%' and district_id in ('802', '803', '804', '805')
or name like '%Apartmán%' and district_id in ('802', '803', '804', '805')
or name like '%apartmány%' and district_id in ('802', '803', '804', '805')
or name like '%apartmán%' and district_id in ('802', '803', '804', '805')
or name like '%apartman%' and district_id in ('802', '803', '804', '805')
or name like '%Apartment%' and name not like '%Hotel%' and district_id in ('802', '803', '804', '805')
or name like '%Apartments%' and district_id in ('802', '803', '804', '805')
or name like '%apartments%' and district_id in ('802', '803', '804', '805')
or name like '%apartment%' and name not like '%Hotel%' and district_id in ('802', '803', '804', '805')
or name like '%Appartment%' and district_id in ('802', '803', '804', '805')
or name like '%APARTMENT%' and name not like '%Hotel%' and district_id in ('802', '803', '804', '805')
or name like '%Apartmen%' and name not like '%Hotel%' and district_id in ('802', '803', '804', '805')
or name like '%Villa Park Komenského%' and district_id in ('802', '803', '804', '805')
or name like '%Villa%' and district_id in ('802', '803', '804', '805') and name not like ('Villa Park Komenského') and name not like ('%Penzion Villa%')
or name like '%Vila%' and district_id in ('802', '803', '804', '805') and name not like ('Villa Park Komenského') and name not like ('%Penzion Villa%')
or name like '%Studio%' and district_id in ('802', '803', '804', '805')
or name like '%studio%' and district_id in ('802', '803', '804', '805')
or name like '%Štúdio%' and district_id in ('802', '803', '804', '805')
or name like '%štúdio%' and district_id in ('802', '803', '804', '805')
or name like '%študio%' and district_id in ('802', '803', '804', '805')
or name like '%Študio%' and district_id in ('802', '803', '804', '805')
or name like 'House%' and district_id in ('802', '803', '804', '805')
or name like '% dom%' and district_id in ('802', '803', '804', '805')
or name like '%Apt%' and district_id in ('802', '803', '804', '805')
or name like '%cottage%' and district_id in ('802', '803', '804', '805')
or name like '%Cottage%' and district_id in ('802', '803', '804', '805')
or name like '%Chata%' and district_id in ('802', '803', '804', '805')
or name = 'Záhrada Zverina' and district_id in ('802', '803', '804', '805')
order by sub_name
)
select level_0, name,
CASE
WHEN sub_name like '%Apartmany%' and sub_cat_acc is null then regexp_replace(sub_name, 'Apartmany', ' ', 'g')
WHEN sub_name like '%Apartmány%' and sub_cat_acc is null then regexp_replace(sub_name, 'Apartmány', ' ', 'g')
WHEN sub_name like '%Apartmán%' and sub_cat_acc is null then regexp_replace(sub_name, 'Apartmán', ' ', 'g')
WHEN sub_name like '%Apartman%' and sub_cat_acc is null then regexp_replace(sub_name, 'Apartman', ' ', 'g')
WHEN sub_name like '%Apartments%' and sub_cat_acc is null then regexp_replace(sub_name, 'Apartments', ' ', 'g')
WHEN sub_name like '%apartments%' and sub_cat_acc is null then regexp_replace(sub_name, 'apartments', ' ', 'g')
WHEN sub_name like '%Apartment%' and sub_cat_acc is null then regexp_replace(sub_name, 'Apartment', ' ', 'g')
WHEN sub_name like '%apartment%' and sub_cat_acc is null then regexp_replace(sub_name, 'apartment', ' ', 'g')
WHEN sub_name like '%apartman%' and sub_cat_acc is null then regexp_replace(sub_name, 'apartman', ' ', 'g')
WHEN sub_name like '%APARTMENT%' and sub_cat_acc is null then regexp_replace(sub_name, 'APARTMENT', ' ', 'g')
WHEN sub_name like '%Appartment%' and sub_cat_acc is null then regexp_replace(sub_name, 'Appartment', ' ', 'g')
WHEN sub_name like '%Apartmen%' and sub_cat_acc is null then regexp_replace(sub_name, 'Apartmen', ' ', 'g')
WHEN sub_name like '%Studio%' and sub_cat_acc is null then regexp_replace(sub_name, 'Studio', ' ', 'g')
WHEN sub_name like '%studio%' and sub_cat_acc is null then regexp_replace(sub_name, 'studio', ' ', 'g')
WHEN sub_name like '%Štúdio%' and sub_cat_acc is null then regexp_replace(sub_name, 'Štúdio', ' ', 'g')
WHEN sub_name like '%štúdio%' and sub_cat_acc is null then regexp_replace(sub_name, 'štúdio', ' ', 'g')
WHEN sub_name like '%študio%' and sub_cat_acc is null then regexp_replace(sub_name, 'študio', ' ', 'g')
WHEN sub_name like '%Študio%' and sub_cat_acc is null then regexp_replace(sub_name, 'Študio', ' ', 'g')
WHEN sub_name like '%Apt%' and sub_cat_acc is null then regexp_replace(sub_name, 'Apt', ' ', 'g')
ELSE
sub_name
END,
cat_acc,
CASE
when sub_cat_acc is null and name like '%Apartmány%' then 'Apartment House'
when sub_cat_acc is null and name like '%Apartmany%' then 'Apartment House'
when sub_cat_acc is null and name like '%Apartmán%' then 'Apartment'
when sub_cat_acc is null and name like '%Apartman%' then 'Apartment'
when sub_cat_acc is null and name like '%Apartments%' then 'Apartment House'
when sub_cat_acc is null and name like '%apartments%' then 'Apartment House'
when sub_cat_acc is null and name like '%apartment%' then 'Apartment'