-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path26_adding_homepage_info_from_www.aql
875 lines (715 loc) · 30.7 KB
/
26_adding_homepage_info_from_www.aql
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
// AQL query to execute IN arangodb QUERIES
// or /usr/bin/arangosh on DB host machine
// to add homepage info to authors from www type publications
FOR pub IN publication
FILTER pub.pub_type == "www"
AND pub.title == "Home Page"
AND pub["@key"] != null
AND pub.author != []
AND pub.crossref == ""
AND (pub.url == null OR pub.url == "" OR pub.url == [] OR pub.url == {})
AND (pub.note == null OR pub.note == "" OR pub.note == [] OR pub.note == {})
AND pub["@publtype"] == ""
AND (pub.cite == null OR pub.cite == "" OR pub.cite == [] OR pub.cite == {})
AND pub.year == ""
AND pub.ee == []
AND pub.editor == []
INSERT pub INTO homepages_temp
FOR pub IN publication
FILTER pub.pub_type == "www"
AND pub.title == "Home Page"
AND pub["@key"] != null
AND pub.author != []
AND pub.crossref == ""
AND (pub.url == null OR pub.url == "" OR pub.url == [] OR pub.url == {})
AND (pub.note == null OR pub.note == "" OR pub.note == [] OR pub.note == {})
AND pub["@publtype"] == ""
AND (pub.cite == null OR pub.cite == "" OR pub.cite == [] OR pub.cite == {})
AND pub.year == ""
AND pub.ee == []
AND pub.editor == []
REMOVE pub IN publication
FOR el IN homepages_temp
FILTER el.crossref == "" OR el.crossref == []
UPDATE el WITH { crossref: null } IN homepages_temp OPTIONS { keepNull: false }
FOR el IN homepages_temp
FILTER el.address == "" OR el.address == []
UPDATE el WITH { address: null } IN homepages_temp OPTIONS { keepNull: false }
FOR el IN homepages_temp
FILTER el.school == "" OR el.school == []
UPDATE el WITH { school: null } IN homepages_temp OPTIONS { keepNull: false }
FOR el IN homepages_temp
FILTER el.year == "" OR el.year == []
UPDATE el WITH { year: null } IN homepages_temp OPTIONS { keepNull: false }
FOR el IN homepages_temp
FILTER el.cdrom == "" OR el.cdrom == []
UPDATE el WITH { cdrom: null } IN homepages_temp OPTIONS { keepNull: false }
FOR el IN homepages_temp
FILTER el["@cdate"] == "" OR el["@cdate"] == []
UPDATE el WITH { "@cdate": null } IN homepages_temp OPTIONS { keepNull: false }
FOR el IN homepages_temp
FILTER el.ee == "" OR el.ee == []
UPDATE el WITH { ee: null } IN homepages_temp OPTIONS { keepNull: false }
FOR el IN homepages_temp
FILTER el.chapter == "" OR el.chapter == []
UPDATE el WITH { chapter: null } IN homepages_temp OPTIONS { keepNull: false }
FOR el IN homepages_temp
FILTER el.number == "" OR el.number == []
UPDATE el WITH { number: null } IN homepages_temp OPTIONS { keepNull: false }
FOR el IN homepages_temp
FILTER el.journal == "" OR el.journal == []
UPDATE el WITH { journal: null } IN homepages_temp OPTIONS { keepNull: false }
FOR el IN homepages_temp
FILTER el.pages == "" OR el.pages == []
UPDATE el WITH { pages: null } IN homepages_temp OPTIONS { keepNull: false }
FOR el IN homepages_temp
FILTER el.month == "" OR el.month == []
UPDATE el WITH { month: null } IN homepages_temp OPTIONS { keepNull: false }
FOR el IN homepages_temp
FILTER el.volume == "" OR el.volume == []
UPDATE el WITH { volume: null } IN homepages_temp OPTIONS { keepNull: false }
FOR el IN homepages_temp
FILTER el.booktitle == "" OR el.booktitle == []
UPDATE el WITH { booktitle: null } IN homepages_temp OPTIONS { keepNull: false }
FOR el IN homepages_temp
FILTER el.url == "" OR el.url == []
UPDATE el WITH { url: null } IN homepages_temp OPTIONS { keepNull: false }
FOR el IN homepages_temp
FILTER el.publisher == "" OR el.publisher == []
UPDATE el WITH { publisher: null } IN homepages_temp OPTIONS { keepNull: false }
FOR el IN homepages_temp
FILTER el.note == "" OR el.note == []
UPDATE el WITH { note: null } IN homepages_temp OPTIONS { keepNull: false }
FOR el IN homepages_temp
FILTER el.cite == "" OR el.cite == []
UPDATE el WITH { cite: null } IN homepages_temp OPTIONS { keepNull: false }
FOR el IN homepages_temp
FILTER el.isbn == "" OR el.isbn == []
UPDATE el WITH { isbn: null } IN homepages_temp OPTIONS { keepNull: false }
FOR el IN homepages_temp
FILTER el["@publtype"] == "" OR el["@publtype"] == []
UPDATE el WITH { "@publtype": null } IN homepages_temp OPTIONS { keepNull: false }
FOR el IN homepages_temp
FILTER el.series == "" OR el.series == []
UPDATE el WITH { series: null } IN homepages_temp OPTIONS { keepNull: false }
FOR el IN homepages_temp
FILTER el.publnr == "" OR el.publnr == []
UPDATE el WITH { publnr: null } IN homepages_temp OPTIONS { keepNull: false }
FOR el IN homepages_temp
FILTER el.editor == "" OR el.editor == []
UPDATE el WITH { editor: null } IN homepages_temp OPTIONS { keepNull: false }
FOR auth IN homepages_temp
FILTER IS_ARRAY(auth.author) AND LENGTH(auth.author) == 1
UPDATE auth WITH { author: auth.author[0] } IN homepages_temp
FOR a IN author
UPDATE a WITH { url: [] } IN author
FOR auth IN homepages_temp
FILTER IS_STRING(auth.author)
FOR a IN author
FILTER a.name == auth.author
UPDATE a WITH { url: PUSH(a.url, { address: auth["@key"], label: auth.title } ) } IN author
FOR auth IN homepages_temp
FILTER IS_STRING(auth.author)
FOR a IN author
FILTER a.name == auth.author
REMOVE auth IN homepages_temp
// Counting appearances of first and second name in publications
FOR auth IN homepages_temp
FILTER LENGTH(auth.author) == 2
LET first_name = COUNT(
FOR pub IN publication
FILTER auth.author[0] IN pub.author
RETURN 1
)
LET second_name = COUNT(
FOR pub IN publication
FILTER auth.author[1] IN pub.author
RETURN 1
)
LIMIT 200
RETURN { appearances_first_name: first_name, appearances_second_name: second_name }
// Count entries with many names
LET lengths = [1, 2, 3, 4, 5, 6, 7]
LET lengths_count = (
FOR l IN lengths
LET counting = COUNT(
FOR el IN homepages_temp
FILTER LENGTH(el.author) == l
RETURN 1
)
RETURN { len: l, total: counting }
)
RETURN lengths_count
// Choose longest name
LET longest_other_names = UNIQUE(
FOR el IN homepages_temp
LET max_length = MAX(
FOR a IN el.author
RETURN LENGTH(a)
)
LET longest = (
FOR au IN el.author
FILTER LENGTH(au) == max_length
RETURN au
)
LET other = MINUS(el.author, [longest[0]])
RETURN { longest_name: longest[0], other_names: other }
)
FOR data IN longest_other_names
INSERT data IN longest_other_names_temp
FOR pub IN publication
FILTER pub.pub_type == "www"
INSERT pub INTO homepages_bloat_temp
FOR pub IN publication
FILTER pub.pub_type == "www"
REMOVE pub IN publication
FOR el IN homepages_bloat_temp
FILTER el.crossref == "" OR el.crossref == []
UPDATE el WITH { crossref: null } IN homepages_bloat_temp OPTIONS { keepNull: false }
FOR el IN homepages_bloat_temp
FILTER el.address == "" OR el.address == []
UPDATE el WITH { address: null } IN homepages_bloat_temp OPTIONS { keepNull: false }
FOR el IN homepages_bloat_temp
FILTER el.school == "" OR el.school == []
UPDATE el WITH { school: null } IN homepages_bloat_temp OPTIONS { keepNull: false }
FOR el IN homepages_bloat_temp
FILTER el.year == "" OR el.year == []
UPDATE el WITH { year: null } IN homepages_bloat_temp OPTIONS { keepNull: false }
FOR el IN homepages_bloat_temp
FILTER el.cdrom == "" OR el.cdrom == []
UPDATE el WITH { cdrom: null } IN homepages_bloat_temp OPTIONS { keepNull: false }
FOR el IN homepages_bloat_temp
FILTER el["@cdate"] == "" OR el["@cdate"] == []
UPDATE el WITH { "@cdate": null } IN homepages_bloat_temp OPTIONS { keepNull: false }
FOR el IN homepages_bloat_temp
FILTER el.ee == "" OR el.ee == []
UPDATE el WITH { ee: null } IN homepages_bloat_temp OPTIONS { keepNull: false }
FOR el IN homepages_bloat_temp
FILTER el.chapter == "" OR el.chapter == []
UPDATE el WITH { chapter: null } IN homepages_bloat_temp OPTIONS { keepNull: false }
FOR el IN homepages_bloat_temp
FILTER el.number == "" OR el.number == []
UPDATE el WITH { number: null } IN homepages_bloat_temp OPTIONS { keepNull: false }
FOR el IN homepages_bloat_temp
FILTER el.journal == "" OR el.journal == []
UPDATE el WITH { journal: null } IN homepages_bloat_temp OPTIONS { keepNull: false }
FOR el IN homepages_bloat_temp
FILTER el.pages == "" OR el.pages == []
UPDATE el WITH { pages: null } IN homepages_bloat_temp OPTIONS { keepNull: false }
FOR el IN homepages_bloat_temp
FILTER el.month == "" OR el.month == []
UPDATE el WITH { month: null } IN homepages_bloat_temp OPTIONS { keepNull: false }
FOR el IN homepages_bloat_temp
FILTER el.volume == "" OR el.volume == []
UPDATE el WITH { volume: null } IN homepages_bloat_temp OPTIONS { keepNull: false }
FOR el IN homepages_bloat_temp
FILTER el.booktitle == "" OR el.booktitle == []
UPDATE el WITH { booktitle: null } IN homepages_bloat_temp OPTIONS { keepNull: false }
FOR el IN homepages_bloat_temp
FILTER el.url == "" OR el.url == []
UPDATE el WITH { url: null } IN homepages_bloat_temp OPTIONS { keepNull: false }
FOR el IN homepages_bloat_temp
FILTER el.publisher == "" OR el.publisher == []
UPDATE el WITH { publisher: null } IN homepages_bloat_temp OPTIONS { keepNull: false }
FOR el IN homepages_bloat_temp
FILTER el.note == "" OR el.note == []
UPDATE el WITH { note: null } IN homepages_bloat_temp OPTIONS { keepNull: false }
FOR el IN homepages_bloat_temp
FILTER el.cite == "" OR el.cite == []
UPDATE el WITH { cite: null } IN homepages_bloat_temp OPTIONS { keepNull: false }
FOR el IN homepages_bloat_temp
FILTER el.isbn == "" OR el.isbn == []
UPDATE el WITH { isbn: null } IN homepages_bloat_temp OPTIONS { keepNull: false }
FOR el IN homepages_bloat_temp
FILTER el["@publtype"] == "" OR el["@publtype"] == []
UPDATE el WITH { "@publtype": null } IN homepages_bloat_temp OPTIONS { keepNull: false }
FOR el IN homepages_bloat_temp
FILTER el.series == "" OR el.series == []
UPDATE el WITH { series: null } IN homepages_bloat_temp OPTIONS { keepNull: false }
FOR el IN homepages_bloat_temp
FILTER el.publnr == "" OR el.publnr == []
UPDATE el WITH { publnr: null } IN homepages_bloat_temp OPTIONS { keepNull: false }
FOR el IN homepages_bloat_temp
FILTER el.editor == "" OR el.editor == []
UPDATE el WITH { editor: null } IN homepages_bloat_temp OPTIONS { keepNull: false }
LET attrs = UNIQUE(
FOR el IN homepages_bloat_temp
RETURN ATTRIBUTES(el, true, true)
)
RETURN attrs
FOR el IN homepages_bloat_temp
UPDATE el WITH { "@mdate": null } IN homepages_bloat_temp OPTIONS { keepNull: false }
LET attrs = UNIQUE(FLATTEN(
FOR el IN homepages_bloat_temp
RETURN ATTRIBUTES(el, true, true)
))
LET count_attrs = (
FOR a IN attrs
LET counting = COUNT(
FOR el IN homepages_bloat_temp
FILTER HAS(el, a)
RETURN 1
)
RETURN { attribut: a, total: counting }
)
RETURN count_attrs
FOR el IN homepages_bloat_temp
FILTER el.editor != null
RETURN el
// manual insertion
FOR el IN homepages_bloat_temp
FILTER el.editor != null
REMOVE el IN homepages_bloat_temp
FOR el IN homepages_bloat_temp
FILTER el.year != null
RETURN el
FOR el IN homepages_bloat_temp
FILTER el.year != null
REMOVE el IN homepages_bloat_temp
FOR el IN homepages_bloat_temp
FILTER el.note != null AND IS_ARRAY(el.note)
LET affiliation_data_bool = UNIQUE(
FOR nt IN el.note
RETURN IS_OBJECT(nt) AND nt["@type"] != null AND nt["@type"] == "affiliation"
)
FILTER true IN affiliation_data_bool
INSERT el IN author_affiliation_data
FOR el IN homepages_bloat_temp
FILTER el.note != null AND IS_ARRAY(el.note)
LET affiliation_data_bool = UNIQUE(
FOR nt IN el.note
RETURN IS_OBJECT(nt) AND nt["@type"] != null AND nt["@type"] == "affiliation"
)
FILTER true IN affiliation_data_bool
REMOVE el IN homepages_bloat_temp
FOR el IN homepages_bloat_temp
FILTER el.note != null AND IS_ARRAY(el.note)
LET award_data_bool = UNIQUE(
FOR nt IN el.note
RETURN IS_OBJECT(nt) AND nt["@type"] != null AND nt["@type"] == "award"
)
FILTER true IN award_data_bool
INSERT el IN author_award_data
FOR el IN homepages_bloat_temp
FILTER el.note != null AND IS_ARRAY(el.note)
LET award_data_bool = UNIQUE(
FOR nt IN el.note
RETURN IS_OBJECT(nt) AND nt["@type"] != null AND nt["@type"] == "award"
)
FILTER true IN award_data_bool
REMOVE el IN homepages_bloat_temp
FOR el IN homepages_bloat_temp
FILTER el.note != null AND IS_ARRAY(el.note)
LET note_object = (
FOR nt IN el.note
FILTER IS_OBJECT(nt) AND (nt["@type"] == null OR nt["@type"] != "uname")
RETURN nt
)
LET note_string = (
FOR ntstr IN el.note
FILTER IS_STRING(ntstr)
RETURN ntstr
)
UPDATE el WITH { note: UNION(note_object, note_string) } IN homepages_bloat_temp
FOR el IN homepages_bloat_temp
FILTER el.note == []
UPDATE el WITH { note: null } IN homepages_bloat_temp OPTIONS { keepNull: false }
FOR el IN homepages_bloat_temp
FILTER IS_STRING(el.url)
UPDATE el WITH { url: [el.url] } IN homepages_bloat_temp
FOR auth IN homepages_bloat_temp
FILTER auth.note != null AND auth.crossref == null
FOR a IN author
FILTER a.name == auth.author[0]
UPDATE a WITH { url: PUSH(a.url, { address: auth["@key"], label: auth.title } ), note: auth.note } IN author
FOR auth IN homepages_bloat_temp
FILTER auth.note != null AND auth.crossref == null
FOR a IN author
FILTER a.name == auth.author[0] AND auth.url != null
LET new_urls = (
FOR u IN auth.url
RETURN { address: u, label: "" }
)
UPDATE a WITH { url: PUSH(a.url, new_urls[0] ) } IN author
FOR auth IN homepages_bloat_temp
FILTER auth.note != null AND auth.crossref == null
FOR a IN author
FILTER a.name == auth.author[0] AND auth.url != null
REMOVE auth IN homepages_bloat_temp
FOR auth IN homepages_bloat_temp
FILTER auth.note != null AND IS_STRING(auth.note)
FOR a IN author
FILTER a.name == auth.author[0]
UPDATE a WITH { url: PUSH(a.url, { address: auth["@key"], label: auth.title } ), note: [auth.note] } IN author
FOR auth IN homepages_bloat_temp
FILTER auth.note != null AND IS_STRING(auth.note)
FOR a IN author
FILTER a.name == auth.author[0]
REMOVE auth IN homepages_bloat_temp
FOR el IN homepages_bloat_temp
FILTER el.note != null AND IS_OBJECT(el.note[0])
FOR a IN author
FILTER a.name == el.author[0]
UPDATE a WITH { url: PUSH(a.url, { address: el["@key"], label: el.title } ), isnot: [ el.note[0]["#text"] ] } IN author
FOR el IN homepages_bloat_temp
FILTER el.note != null AND IS_OBJECT(el.note[0])
FOR a IN author
FILTER a.name == el.author[0]
REMOVE el IN homepages_bloat_temp
// transforming multiple names into longest as main and the rest into other names in homepages_temp
FOR el IN homepages_temp
LET longest_other_names = UNIQUE(
LET max_length = MAX(
FOR a IN el.author
RETURN LENGTH(a)
)
LET longest = (
FOR au IN el.author
FILTER LENGTH(au) == max_length
RETURN au
)
LET other = MINUS(el.author, [longest[0]])
RETURN { longest_name: longest[0], other_names: other }
)
UPDATE el WITH { author: longest_other_names[0].longest_name, other_names: longest_other_names[0].other_names } IN homepages_temp
// doing the same for the authors in author_affiliation_data
FOR el IN author_affiliation_data
LET longest_other_names = UNIQUE(
LET max_length = MAX(
FOR a IN el.author
RETURN LENGTH(a)
)
LET longest = (
FOR au IN el.author
FILTER LENGTH(au) == max_length
RETURN au
)
LET other = MINUS(el.author, [longest[0]])
RETURN { longest_name: longest[0], other_names: other }
)
UPDATE el WITH { author: longest_other_names[0].longest_name, other_names: longest_other_names[0].other_names } IN author_affiliation_data
FOR el IN author_affiliation_data
FILTER IS_STRING(el.author)
UPDATE el WITH { author: [el.author] } IN author_affiliation_data
// doing the same for the authors in author_award_data
FOR el IN author_award_data
LET longest_other_names = UNIQUE(
LET max_length = MAX(
FOR a IN el.author
RETURN LENGTH(a)
)
LET longest = (
FOR au IN el.author
FILTER LENGTH(au) == max_length
RETURN au
)
LET other = MINUS(el.author, [longest[0]])
RETURN { longest_name: longest[0], other_names: other }
)
UPDATE el WITH { author: longest_other_names[0].longest_name, other_names: longest_other_names[0].other_names } IN author_award_data
FOR el IN author_award_data
FILTER IS_STRING(el.author)
UPDATE el WITH { author: [el.author] } IN author_award_data
// doing the same for the authors in homepages_bloat_temp
FOR el IN homepages_bloat_temp
FILTER IS_STRING(el.author)
UPDATE el WITH { author: [el.author] } IN homepages_bloat_temp
FOR el IN homepages_bloat_temp
LET longest_other_names = UNIQUE(
LET max_length = MAX(
FOR a IN el.author
RETURN LENGTH(a)
)
LET longest = (
FOR au IN el.author
FILTER LENGTH(au) == max_length
RETURN au
)
LET other = MINUS(el.author, [longest[0]])
RETURN { longest_name: longest[0], other_names: other }
)
UPDATE el WITH { author: longest_other_names[0].longest_name, other_names: longest_other_names[0].other_names } IN homepages_bloat_temp
// correcting names in publications using names from author_affiliation_data
// LET name_corrections_in_author_affiliation_data = (
// FOR el IN author_affiliation_data
// FILTER el.other_names != null AND IS_ARRAY(el.other_names) AND LENGTH(el.other_names) > 0
// FOR name IN el.other_names
// // LIMIT 4
// RETURN { is_now: name, will_become: el.author[0] }
// )
// FOR corrections IN name_corrections_in_author_affiliation_data
// LET old_name = corrections.is_now
// LET correct_name = corrections.will_become
// FOR pub IN publication
// FILTER pub.author != [] AND old_name IN pub.author
// LET auth_array = pub.author
// LET pos = POSITION( auth_array, old_name, true )
// UPDATE pub WITH { author: REPLACE_NTH(auth_array, pos, correct_name) } IN publication
// // RETURN { old_data: OLD, new_data: NEW }
//
// // correcting names in publications using names from author_award_data
// LET name_corrections_in_author_award_data = (
// FOR el IN author_award_data
// FILTER el.other_names != null AND IS_ARRAY(el.other_names) AND LENGTH(el.other_names) > 0
// FOR name IN el.other_names
// // LIMIT 4
// RETURN { is_now: name, will_become: el.author[0] }
// )
// FOR corrections IN name_corrections_in_author_award_data
// LET old_name = corrections.is_now
// LET correct_name = corrections.will_become
// FOR pub IN publication
// FILTER pub.author != [] AND old_name IN pub.author
// LET auth_array = pub.author
// LET pos = POSITION( auth_array, old_name, true )
// UPDATE pub WITH { author: REPLACE_NTH(auth_array, pos, correct_name) } IN publication
// // RETURN { old_data: OLD, new_data: NEW }
//
// // correcting names in publications using names from homepages_bloat_temp
// LET name_corrections_in_homepages_bloat_temp = (
// FOR el IN homepages_bloat_temp
// FILTER el.other_names != null AND IS_ARRAY(el.other_names) AND LENGTH(el.other_names) > 0
// FOR name IN el.other_names
// // LIMIT 4
// RETURN { is_now: name, will_become: el.author[0] }
// )
// FOR corrections IN name_corrections_in_homepages_bloat_temp
// LET old_name = corrections.is_now
// LET correct_name = corrections.will_become
// FOR pub IN publication
// FILTER pub.author != [] AND old_name IN pub.author
// LET auth_array = pub.author
// LET pos = POSITION( auth_array, old_name, true )
// UPDATE pub WITH { author: REPLACE_NTH(auth_array, pos, correct_name) } IN publication
// // RETURN { old_data: OLD, new_data: NEW }
//
// // correcting names in publications using names from homepages_temp
// LET name_corrections_in_homepages_temp = (
// FOR el IN homepages_temp
// FILTER el.other_names != null AND IS_ARRAY(el.other_names) AND LENGTH(el.other_names) > 0
// FOR name IN el.other_names
// // LIMIT 4
// RETURN { is_now: name, will_become: el.author[0] }
// )
// FOR corrections IN name_corrections_in_homepages_temp
// LET old_name = corrections.is_now
// LET correct_name = corrections.will_become
// FOR pub IN publication
// FILTER pub.author != [] AND old_name IN pub.author
// LET auth_array = pub.author
// LET pos = POSITION( auth_array, old_name, true )
// UPDATE pub WITH { author: REPLACE_NTH(auth_array, pos, correct_name) } IN publication
// // RETURN { old_data: OLD, new_data: NEW }
FOR el IN homepages_bloat_temp
FILTER el.author != null AND IS_STRING(el.author)
UPDATE el WITH { author: [el.author] } IN homepages_bloat_temp
FOR el IN homepages_bloat_temp
FILTER el.author == null
UPDATE el WITH { author: [] } IN homepages_bloat_temp
FOR el IN homepages_temp
FILTER el.author != null AND IS_STRING(el.author)
UPDATE el WITH { author: [el.author] } IN homepages_temp
LET name_corrections_in_author_affiliation_data = (
FOR el1 IN author_affiliation_data
FILTER el1.other_names != null AND IS_ARRAY(el1.other_names) AND LENGTH(el1.other_names) > 0
FOR name1 IN el1.other_names
// LIMIT 4
RETURN { is_now: name1, will_become: el1.author[0] }
)
LET name_corrections_in_author_award_data = (
FOR el2 IN author_award_data
FILTER el2.other_names != null AND IS_ARRAY(el2.other_names) AND LENGTH(el2.other_names) > 0
FOR name2 IN el2.other_names
// LIMIT 4
RETURN { is_now: name2, will_become: el2.author[0] }
)
LET name_corrections_in_homepages_bloat_temp = (
FOR el3 IN homepages_bloat_temp
FILTER el3.other_names != null AND IS_ARRAY(el3.other_names) AND LENGTH(el3.other_names) > 0
FOR name3 IN el3.other_names
// LIMIT 4
RETURN { is_now: name3, will_become: el3.author[0] }
)
LET name_corrections_in_homepages_temp = (
FOR el4 IN homepages_temp
FILTER el4.other_names != null AND IS_ARRAY(el4.other_names) AND LENGTH(el4.other_names) > 0
FOR name4 IN el4.other_names
// LIMIT 4
RETURN { is_now: name4, will_become: el4.author[0] }
)
LET unified_corrections = UNIQUE(UNION(
name_corrections_in_author_affiliation_data,
name_corrections_in_author_award_data,
name_corrections_in_homepages_bloat_temp,
name_corrections_in_homepages_temp))
// RETURN unified_corrections
FOR corrections IN unified_corrections
INSERT corrections INTO all_name_corrections
// correcting names in publications using names from all_name_corrections
FOR corrections IN all_name_corrections
LET old_name = corrections.is_now
LET correct_name = corrections.will_become
FOR pub IN publication
FILTER pub.author != [] AND old_name IN pub.author
LET auth_array = pub.author
LET pos = POSITION( auth_array, old_name, true )
UPDATE pub WITH { author: REPLACE_NTH(auth_array, pos, correct_name) } IN publication
// RETURN { old_data: OLD, new_data: NEW }
FOR a IN author_affiliation_data
UPDATE a WITH { other_names: null } IN author_affiliation_data OPTIONS { keepNull: false }
FOR a IN author_award_data
UPDATE a WITH { other_names: null } IN author_award_data OPTIONS { keepNull: false }
FOR a IN homepages_bloat_temp
UPDATE a WITH { other_names: null } IN homepages_bloat_temp OPTIONS { keepNull: false }
FOR a IN homepages_temp
UPDATE a WITH { other_names: null } IN homepages_temp OPTIONS { keepNull: false }
FOR el IN author_affiliation_data
FILTER IS_STRING(el.url)
UPDATE el WITH { url: [ { address: el.url, label: "" } ] } IN author_affiliation_data
FOR el IN author_affiliation_data
FILTER IS_ARRAY(el.url) AND LENGTH(el.url) == 1 AND IS_STRING(el.url[0])
UPDATE el WITH { url: [ { address: el.url[0], label: "" } ] } IN author_affiliation_data
FOR el IN author_affiliation_data
FILTER IS_ARRAY(el.url) AND LENGTH(el.url) == 1 AND IS_STRING(el.url[0])
UPDATE el WITH { url: [ { address: el.url[0], label: "" } ] } IN author_affiliation_data
FOR el IN author_affiliation_data
FILTER IS_ARRAY(el.url) AND LENGTH(el.url) > 1
LET count_not_strings = COUNT(
FOR u IN el.url
FILTER NOT IS_STRING(u)
RETURN 1
)
FILTER IS_ARRAY(el.url) AND LENGTH(el.url) > 1 AND count_not_strings == 0
LET urls_to_add = (
FOR the_url IN el.url
RETURN { address: the_url, label: "" }
)
UPDATE el WITH { url: urls_to_add } IN author_affiliation_data
FOR inp IN homepages_temp
FOR a IN author
FILTER inp.author != null
AND IS_ARRAY(inp.author)
AND LENGTH(inp.author) == 1
AND inp.author[0] == a.name
AND inp["@key"] != null AND inp["@key"] != ""
AND inp.pub_type == "www"
AND inp.title == "Home Page"
AND ( a.url == null OR (IS_ARRAY(a.url) AND LENGTH(a.url) == 0))
UPDATE a WITH { "url": [ { "address": inp["@key"], "label": "Home Page" } ] } IN author
LET to_delete = UNIQUE(FLATTEN(
FOR inp IN homepages_temp
FOR a IN author
FILTER inp.author != null
AND IS_ARRAY(inp.author)
AND LENGTH(inp.author) == 1
AND inp.author[0] == a.name
AND inp["@key"] != null AND inp["@key"] != ""
AND inp.pub_type == "www"
AND inp.title == "Home Page"
AND ( a.url == null OR (IS_ARRAY(a.url) AND LENGTH(a.url) == 1))
RETURN inp["_key"]
))
FOR d IN to_delete
REMOVE { _key: d } IN homepages_temp
FOR pub IN publication_bloat_temp
FILTER pub.url != null AND IS_ARRAY(pub.url) AND LENGTH(pub.ee) > 1
LET string_ee = (
FOR el1 IN pub.ee
FILTER IS_STRING(el1)
RETURN { type: "", value: el1 }
)
LET object_ee = (
FOR el2 IN pub.ee
FILTER IS_OBJECT(el2) AND el2["#text"] != null
RETURN { type: el2["@type"], value: el2["#text"] }
)
LET all_ee = UNION(string_ee, object_ee)
UPDATE pub WITH { ee: all_ee } IN publication
FOR pub IN homepages_bloat_temp
FILTER pub.url != null AND pub.url != [] AND LENGTH(pub.url) > 0
LET string_url = (
FOR el1 IN pub.url
FILTER IS_STRING(el1)
RETURN { label: "", address: el1 }
)
LET object_url = (
FOR el2 IN pub.url
FILTER IS_OBJECT(el2) AND el2["#text"] != null
RETURN { label: el2["@type"], address: el2["#text"] }
)
LET all_url = UNION(string_url, object_url)
INSERT { author: pub.author, url: all_url } INTO new_urls_for_authors
FOR a1 IN new_urls_for_authors
FOR a2 IN author
FILTER a1.author[0] == a2.name
LET a1_urls = a1.url
LET a2_urls = a2.url == null ? [] : a2.url
FILTER a1_urls != a2_urls
LET all_url = UNION(a1_urls, a2_urls)
UPDATE a2 WITH { url: all_url } IN author
FOR pub IN homepages_bloat_temp
FILTER pub.url != null AND pub.url != [] AND LENGTH(pub.url) > 0
UPDATE pub WITH { url: null } in homepages_bloat_temp OPTIONS { keepNull: false }
FOR a1 IN new_urls_for_authors
FOR a2 IN author
FILTER a1.author[0] == a2.name
LET a1_urls = a1.url
LET a2_urls = a2.url == null ? [] : a2.url
FILTER a1_urls != a2_urls
LET all_url = UNION(a1_urls, a2_urls)
UPDATE a2 WITH { url: all_url } IN author
FOR pub IN homepages_bloat_temp
FOR a IN author
FILTER pub["kind"] != null AND pub.author[0] == a.name
LET pub_urls = [ { "label": pub.title, "address": pub["@key"] } ]
LET a_urls = a.url == null ? [] : a.url
FILTER pub_urls != a_urls
LET all_url = UNION(pub_urls, a_urls)
UPDATE a WITH { url: all_url, kind: "group" } IN author
FOR pub IN homepages_bloat_temp
FILTER pub["kind"] != null
REMOVE pub IN homepages_bloat_temp
FOR pub IN homepages_bloat_temp
FOR a IN author
FILTER pub.author[0] == a.name
LET pub_urls = [ { "label": pub.title, "address": pub["@key"] } ]
LET a_urls = a.url == null ? [] : a.url
FILTER pub_urls != a_urls
LET all_url = UNION(pub_urls, a_urls)
UPDATE a WITH { url: all_url } IN author
FOR aff IN author_affiliation_data
LET aff_urls = aff.url == null ? [] : aff.url
LET aff_homepage = [ { address: aff["@key"], label: (aff.title == null ? "" : aff.title) } ]
FOR a IN author
FILTER aff.author[0] == a.name
LET a_urls = (a.url == null ? [] : a.url)
LET all_url = FLATTEN(UNION(aff_urls, aff_homepage, a_urls))
UPDATE a WITH { url: all_url,
kind: ((aff["@publtype"] != null AND aff["@publtype"] == "group") ? "group" : null) } IN author OPTIONS { keepNull: false }
FOR aff IN author_award_data
LET aff_urls = aff.url == null ? [] : aff.url
LET aff_homepage = [ { address: aff["@key"], label: (aff.title == null ? "" : aff.title) } ]
FOR a IN author
FILTER aff.author[0] == a.name
LET a_urls = (a.url == null ? [] : a.url)
LET all_url = FLATTEN(UNION(aff_urls, aff_homepage, a_urls))
UPDATE a WITH { url: all_url } IN author
FOR a IN author
FILTER a.url != null AND a.url != [] AND LENGTH(a.url) > 0
LET string_url = (
FOR u IN a.url
FILTER IS_STRING(u)
RETURN { address: u, label: "" }
)
LET object_url_bad_format = (
FOR u IN a.url
FILTER IS_OBJECT(u) AND u.address == null
RETURN { address: u["#text"], label: (u["@type"] == null ? "" : u["@label"]) }
)
LET object_url_good_format = (
FOR u IN a.url
FILTER IS_OBJECT(u) AND u.address != null
RETURN u
)
LET all_url = UNIQUE(UNION(string_url, object_url_bad_format, object_url_good_format))
UPDATE a WITH { url: all_url } IN author