-
Notifications
You must be signed in to change notification settings - Fork 1
/
IPBES_TCA_Corpus_DMP.qmd
5524 lines (4513 loc) · 156 KB
/
IPBES_TCA_Corpus_DMP.qmd
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
---
title: 'Data Management Report Transformative Change Assessment Corpus - SOD'
date: today
author:
- name:
family: Krug
given: Rainer M.
id: rmk
orcid: 0000-0002-7490-0066
email: Rainer.Krug@Senckenberg.de, Rainer@Krugs.de
affiliation:
- name: Senckenberg
city: Frankfurt (Main)
url: https://www.senckenberg.de/en/institutes/sbik-f/
roles: [author, editor]
abstract: >
The literature search for the assessment corpus was conducted using search terms provided by the experts and refined in co-operation with the Knowldge and Data task force.
The search was conducted using [OpenAlex](https://openalex.org), scripted from [R](https://cran.r-project.org) to use the [API](https://docs.openalex.org). Search terms for the following searches were defined:
**Transformative Change**,
**Nature / Environment** and
**additional search terms for individual chapters and sub-chapters**
To assess the quality of the corpus, sets of key-papers were selected by the experts to verify if these are in the corpus.
These key-papers were selected per chapter / sub-chapter to ensure that the corpus is representative of each chapter.
keywords:
- DMR
- TCA
- Assessment Corpus
license: "CC BY"
citation:
type: report
container-title: Report Transformative Change Assessment Corpus
doi: 10.5281/zenodo.10251349
doi: 10.5281/zenodo.10251349
version: 2.0.0
format:
html:
toc: true
toc-depth: 5
toc_expand: true
embed-resources: true
code-fold: true
code-summary: 'Show the code'
grid:
sidebar-width: 0px
body-width: 4000px
margin-width: 200px
gutter-width: 1.5rem
execute:
message: NA
params:
# s_level_1: (transformation OR transition* OR ((shift OR change) AND (fundamental OR deep OR radical))) AND (socio OR social OR politics OR political OR governance OR economical OR cultural OR system* OR technological OR inner OR personal)
# s_tfc_rev: "('transformative change' OR 'deliberate transformation*' OR 'transformative turn*' OR 'transition*' OR 'social-ecological change*' OR 'deep change' OR 'fundamental alteration' OR 'profound change' OR 'profound transformation' OR 'radical transformation' OR 'transformational change' OR 'complete change' OR 'complete transformation' OR 'drastic change' OR 'in-depth transformation' OR 'progressive change' OR 'radical alteration' OR 'radical change' OR 'revolutionary change' OR 'significant modification' OR 'total transformation' OR 'transition' OR 'pathway' OR 'power' OR 'agency' OR 'scale' OR 'leverage' OR 'context' OR 'process' OR 'regime' OR 'shift' OR 'views' OR 'value*' OR 'structure*' OR 'institution*' OR 'deliberate' OR 'structural' OR 'fundamental' OR 'system*' OR 'deep' OR 'radical' OR 'profound' OR 'drastic' OR 'widespread' OR 'political' OR 'economical' OR 'structur*' OR 'complete' OR 'progressive' OR 'revolutionary' OR 'substantial' OR 'significant') AND ('transformation' OR 'alteration' OR 'change' OR 'turn' OR 'action' OR 'transition' OR 'shift' )"
s_1_oa: ""
s_1_transformative_change: !expr paste0(readLines(file.path("tca_corpus", "input", "search terms", "tfc.txt")), collapse = "\n")
s_1_nature_environment: !expr paste0(readLines(file.path("tca_corpus", "input", "search terms", "nature.txt")), collapse = "\n")
s_1_tca_corpus: !expr paste("(", paste0(readLines(file.path("tca_corpus", "input", "search terms", "nature.txt")), collapse = "\n"), ") \nAND \n(", paste0(readLines(file.path("tca_corpus", "input", "search terms", "tfc.txt")), collapse = "\n"), ")")
s_1_ch1_01: !expr paste0(readLines(file.path("tca_corpus", "input", "search terms", "ch1_01.txt")), collapse = "\n")
s_1_ch1_02: !expr paste0(readLines(file.path("tca_corpus", "input", "search terms", "ch1_02.txt")), collapse = "\n")
s_1_ch1_03: !expr paste0(readLines(file.path("tca_corpus", "input", "search terms", "ch1_03.txt")), collapse = "\n")
s_1_ch1_04: !expr paste0(readLines(file.path("tca_corpus", "input", "search terms", "ch1_04.txt")), collapse = "\n")
s_1_ch1_05: !expr paste0(readLines(file.path("tca_corpus", "input", "search terms", "ch1_05.txt")), collapse = "\n")
s_1_ch1_06: !expr paste0(readLines(file.path("tca_corpus", "input", "search terms", "ch1_06.txt")), collapse = "\n")
s_1_ch2: !expr paste0(readLines(file.path("tca_corpus", "input", "search terms", "ch2.txt")), collapse = "\n")
s_1_ch3_01: !expr paste0(readLines(file.path("tca_corpus", "input", "search terms", "ch3_01.txt")), collapse = "\n")
s_1_ch3_02: !expr paste0(readLines(file.path("tca_corpus", "input", "search terms", "ch3_02.txt")), collapse = "\n")
s_1_ch3_03: !expr paste0(readLines(file.path("tca_corpus", "input", "search terms", "ch3_03.txt")), collapse = "\n")
s_1_ch3_04: !expr paste0(readLines(file.path("tca_corpus", "input", "search terms", "ch3_04.txt")), collapse = "\n")
s_1_ch3_05: !expr paste0(readLines(file.path("tca_corpus", "input", "search terms", "ch3_05.txt")), collapse = "\n")
s_1_ch3_06: !expr paste0(readLines(file.path("tca_corpus", "input", "search terms", "ch3_06.txt")), collapse = "\n")
s_1_ch4_01: !expr paste0(readLines(file.path("tca_corpus", "input", "search terms", "ch4_01.txt")), collapse = "\n")
s_1_ch4_02: !expr paste0(readLines(file.path("tca_corpus", "input", "search terms", "ch4_02.txt")), collapse = "\n")
# s_1_case: !expr paste0(readLines(file.path("tca_corpus", "input", "search terms", "case.txt")), collapse = "\n")
s_1_case: !expr paste("(", paste0(readLines(file.path("tca_corpus", "input", "search terms", "nature.txt")), collapse = "\n"), ") \nAND \n(", paste0(readLines(file.path("tca_corpus", "input", "search terms", "tfc.txt")), collapse = "\n"), ") \nAND \n(", paste0(readLines(file.path("tca_corpus", "input", "search terms", "case.txt")), collapse = "\n"), ")")
st_art: !expr paste0(readLines(file.path("tca_corpus", "input", "search terms", "art.txt")), collapse = "\n")
st_media: !expr paste0(readLines(file.path("tca_corpus", "input", "search terms", "media.txt")), collapse = "\n")
st_imaginative: !expr paste0(readLines(file.path("tca_corpus", "input", "search terms", "imaginative.txt")), collapse = "\n")
st_rights_of_nature: !expr paste0(readLines(file.path("tca_corpus", "input", "search terms", "rights_of_nature.txt")), collapse = "\n")
st_initiative: !expr paste0(readLines(file.path("tca_corpus", "input", "search terms", "initiative.txt")), collapse = "\n")
st_creativity: !expr paste0(readLines(file.path("tca_corpus", "input", "search terms", "creativity.txt")), collapse = "\n")
sts_strategies_options: !expr readLines(file.path("tca_corpus", "input", "search terms", "strategies_options.md"))
sts_actors: !expr readLines(file.path("tca_corpus", "input", "search terms", "actors.md"))
# s_1_ch2_vision_case: !expr paste("(", paste0(readLines(file.path("tca_corpus", "input", "search terms", "ch2.txt")), collapse = "\n"), ") \nAND \n(", paste0(readLines(file.path("tca_corpus", "input", "search terms", "case.txt")), collapse = "\n"), ")")
concept_cuttoff: 0.6
key_papers:
# Ch_1:
- "./tca_corpus/input/key papers/Ch 1 - Arun.csv"
- "./tca_corpus/input/key papers/Ch 1 - pdf.csv"
- "./tca_corpus/input/key papers/Ch 1 - word.csv"
# Ch_2:
- "./tca_corpus/input/key papers/Ch 2 - pdf.csv"
- "./tca_corpus/input/key papers/Ch 2 - Sebastian.csv"
# Ch_3_Cl_1:
- "./tca_corpus/input/key papers/Ch 3 - Cl1.csv"
# Ch_3_Cl_3:
- "./tca_corpus/input/key papers/Ch 3 - Cl3.csv"
# Ch_3_Cl_4:
- "./tca_corpus/input/key papers/Ch 3 - Cl4.csv"
# Ch_3_Cl_5:
- "./tca_corpus/input/key papers/Ch 3 - Cl5.csv"
# Ch_3Cl_6:
- "./tca_corpus/input/key papers/Ch 3 - Cl6.csv"
# Ch_3:
- "./tca_corpus/input/key papers/Ch 3 - pdf.csv"
# Ch_4_Cl_1:
- "./tca_corpus/input/key papers/Ch 4 - Challenge 1.csv"
# Ch_4_Cl_2:
- "./tca_corpus/input/key papers/Ch 4 - Challenge 2.csv"
# Ch_4_Cl_3:
- "./tca_corpus/input/key papers/Ch 4 - Challenge 3.csv"
# Ch_4_Cl_4:
- "./tca_corpus/input/key papers/Ch 4 - Challenge 4.csv"
# Ch_4_Cl_5:
- "./tca_corpus/input/key papers/Ch 4 - Challenge 5.csv"
# Ch_5:
- "./tca_corpus/input/key papers/Ch 5 - Hannah.csv"
- "./tca_corpus/input/key papers/Ch 5 - Victoria.csv"
- "./tca_corpus/input/key papers/Ch 5 -.csv"
gdm_dir: !expr file.path(".", "tca_corpus", "data", "gdm_dir")
pages_dir: !expr file.path(".", "tca_corpus", "data", "pages")
pages_cases_dir: !expr file.path(".", "tca_corpus", "data", "pages_cases")
pages_strategies_dir: !expr file.path(".", "tca_corpus", "data", "pages_strategies")
pages_actors_dir: !expr file.path(".", "tca_corpus", "data", "pages_actors")
corpus_dir: !expr file.path(".", "tca_corpus", "data", "corpus")
corpus_topics_dir: !expr file.path(".", "tca_corpus", "data", "corpus_topics")
corpus_authors_dir: !expr file.path(".", "tca_corpus", "data", "corpus_authors")
corpus_cases_dir: !expr file.path(".", "tca_corpus", "data", "corpus_cases")
duckdb_fn: !expr file.path(".", "tca_corpus", "data", "tca_corpus.duckdb")
sample_size: 10000
mc.cores: 8
---
[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.10251349.svg)](https://doi.org/10.5281/zenodo.10251349)
[![GitHub release](https://img.shields.io/github/release/IPBES-Data/IPBES_TCA_Corpus.svg)](https://github.com/IPBES-Data/IPBES_TCA_Corpus/releases/latest)
[![GitHub commits since latest release](https://img.shields.io/github/commits-since/IPBES-Data/IPBES_TCA_Corpus/latest)](https://github.com/IPBES-Data/IPBES_TCA_Corpus/commits/main)
[![License: CC BY 4.0](https://img.shields.io/badge/License-CC%20BY%204.0-lightgrey.svg)](https://creativecommons.org/licenses/by/4.0/)
```{r}
#| label: setup
#| include: false
# paste(
# "(", paste0(readLines(file.path("tca_corpus", "input", "search terms", "nature.txt")), collapse = "\n"), ") \nAND \n(", paste0(readLines(file.path("tca_corpus", "input", "search terms", "tfc.txt")), collapse = "\n"), ")"
# )
knitr::opts_chunk$set(message = NA)
build <- as.integer(readLines(file.path("tca_corpus", "buildNo")))
build <- build + 1
writeLines(as.character(build), file.path("tca_corpus", "buildNo"))
if (!exists("params")) {
params <- rmarkdown::yaml_front_matter("./IPBES_TCA_Corpus_DMP.qmd")$params
}
knitr::opts_chunk$set(message = NA)
library(parallel)
library(pbmcapply)
library(pbapply)
library(openalexR)
library(dplyr)
library(tibble)
library(ggplot2)
library(patchwork)
library(igraph)
library(ggraph)
library(visNetwork)
library(DT)
library(tictoc)
library(knitr)
library(arrow)
library(parquetize)
library(purrr)
library(base64enc)
library(diffviewer)
library(collapsibleTree)
library(htmlwidgets)
if (!require("plantuml")) {
install.packages("plantuml", repos = c("https://rkrug.r-universe.dev", "https://cran.r-project.org"))
library(plantuml)
}
plantuml::server_set("remote")
# Function to make the search strings compacter
# compact <- function(x) {
# x |>
# gsub(pattern = "\n", replacement = " ") |>
# gsub(pattern = "\\*", replacement = "") |>
# gsub(pattern = "\\s+", replacement = " ") |>
# gsub(pattern = "\\( ", replacement = "(") |>
# gsub(pattern = " )", replacement = ")")
# }
if (!require("IPBES.R")) {
install.packages("IPBES.R", repos = c("https://ipbes-data.r-universe.dev", "https://cloud.r-project.org"))
if (!require("IPBES.R")) {
stop("Package `IPBES.R` is not available and could not be installed!")
}
}
source(file.path("tca_corpus", "R", "functions.R"))
# A single core request is needed to make multicore parallel processing work
invisible(oa_request(oa_query("bidiversity"), count_only = TRUE))
```
# Working Title
IPBES_TCA_Corpus
## Code repo
[Github repository](https://github.com/IPBES-Data/IPBES_TCA_Corpus)
## Build No: ``r build``
# Introduction
The following terminology is used in this document:
- **Individual corpus**: The corpus resulting from one search term, e.g. `transformative` or `nature` or `ChX_Y`
- **Assessment Corpus**: The corpus resulting from the search terms `transformative AND nature`
- **Chapter corpus**: The corpus resulting from `transformative AND Nature AND ChX_Y`
The following searches are conducted on Title and Abstrat only as the availability of fulltext drops in 2020. OpenAlex did "inherit" fro Microsoft Academic their initial corpus in 2021 which contained a lot of fulltext for searches. After that time, other sources had to be used which did not include fulltext for searches. To eliminate this bias, we linit the search for terms in abstract and title only.
## Schematic Overview
```{r}
#| label: tca_corpus_overview_plantuml
#|
basename <- file.path("tca_corpus", "figures")
nf <- list.files(
path = dirname(basename),
pattern = basename(basename)
) |>
length()
if (nf < 3) {
puml <- readLines(file.path("tca_corpus", "input", "tca_corpus.plantuml")) |>
paste(collapse = "\n") |>
plantuml::plantuml()
puml |>
plantuml::get_graph(
file = file.path("tca_corpus", "figures", "tca_corpus_overview.pdf")
)
puml |>
plantuml::get_graph(
file = file.path("tca_corpus", "figures", "tca_corpus_overview.svg")
)
puml |>
plantuml::get_graph(
file = file.path("tca_corpus", "figures", "tca_corpus_overview.png")
)
}
```
![Schematic overview of the TCA Corpus as well as othher corpora using the TCA Corpus](tca_corpus/figures/tca_corpus_overview.png)
- To download png, [click here](tca_corpus/tca_corpus_overview.png){target="_blank"}.
- To download high resolution pdf, [click here](tca_corpus/figures/tca_corpus_overview.pdf){target="_blank"}.
- To download high resolution svg, [click here](tca_corpus/figures/tca_corpus_overview.svg){target="_blank"}.
## Search Terms {#sec-search_terms}
Here are the search terms used in this document. They were provided by the authors, and some adaptations were done by the tsu to adopt them for OpenAlex.
### Transformative Change {#sec-transform}
```{r}
#| label: s_1_transformative_change
cat(params$s_1_transformative_change)
```
### Nature {#sec-nature}
```{r}
#| label: s_1_nature_environment
#|
cat(params$s_1_nature_environment)
```
### Assessment Corpus {#sec-tca-corpus}
```{r}
#| label: s_1_tca_corpus
#|
cat(params$s_1_tca_corpus)
```
### Chapter 1
#### 01 {#sec-ch1-01}
```{r}
#| label: s_1_ch1_01
#|
cat(params$s_1_ch1_01)
```
#### 02 {#sec-ch1-02}
```{r}
#| label: s_1_ch1_02
#|
cat(params$s_1_ch1_02)
```
#### 03 {#sec-ch1-03}
```{r}
#| label: s_1_ch1_03
#|
cat(params$s_1_ch1_03)
```
#### 04 {#sec-ch1-04}
```{r}
#| label: s_1_ch1_04
#|
cat(params$s_1_ch1_04)
```
#### 05 {#sec-ch1-05}
```{r}
#| label: s_1_ch1_05
#|
cat(params$s_1_ch1_05)
```
#### 06 {#sec-ch1-06}
```{r}
#| label: s_1_ch1_06
#|
cat(params$s_1_ch1_06)
```
### Chapter 2 {#sec-ch2}
```{r}
#| label: s_1_ch2
#|
cat(params$s_1_ch2)
```
### Chapter 3
#### 01 {#sec-ch3-01}
```{r}
#| label: s_1_ch3_01
#|
cat(params$s_1_ch3_01)
```
#### 02 {#sec-ch3-02}
```{r}
#| label: s_1_ch3_02
#|
cat(params$s_1_ch3_02)
```
#### 03 {#sec-ch3-03}
```{r}
#| label: s_1_ch3_03
#|
cat(params$s_1_ch3_03)
```
#### 04 {#sec-ch3-04}
```{r}
#| label: s_1_ch3_04
#|
cat(params$s_1_ch3_04)
```
#### 05 {#sec-ch3-05}
```{r}
#| label: s_1_ch3_05
#|
cat(params$s_1_ch3_05)
```
#### 06 {#sec-ch3-06}
```{r}
#| label: s_1_ch3_06
#|
cat(params$s_1_ch3_06)
```
### Chapter 4
#### 01 {#sec-ch4-01}
```{r}
#| label: s_1_ch4_01
#|
cat(params$s_1_ch4_01)
```
#### 02 {#sec-ch4-02}
```{r}
#| label: s_1_ch4_02
#|
cat(params$s_1_ch4_02)
```
### Art
```{r}
#| label: st_art
#|
cat(params$st_art)
```
### Media
```{r}
#| label: st_media
#|
cat(params$st_media)
```
### Strategies and Options
In contrast to the other search term, this opne contains multiple sets of search terms
```{r}
#| label: sts_strategies_options
#|
cat(params$sts_strategies_options)
```
### Chapter 5
#### Vision {#sec-ch5_vision}
```{r}
#| label: s_1_ch5_vision
#|
cat(params$s_1_ch5_vision)
```
#### Case {#sec-case}
```{r}
#| label: s_1_case
#|
cat(params$s_1_case)
```
#### Vision & Case {#sec-ch5_vision_case}
## Topics
OpenAlex assigns topics to each work in a hirarchical manner:
![](images/topic_hirarchy.png)
Please see [here](https://help.openalex.org/how-it-works/topics) for more information and [here](https://docs.google.com/spreadsheets/d/1v-MAq64x4YjhO7RWcB-yrKV5D_2vOOsxl4u6GBKEXY8/edit#gid=983250122) for a complete list of all topics and their corresponding subfields, fields and domains.
# Methods
## Get and calculate Data from OpenAlex
These data is gathered from OpenAlex directly, not using the downloaded TCA Corpus. The data is used to assess the quality of the TCA Corpus.
```{r}
#| label: get_search_term_hits
#|
fn <- file.path("tca_corpus", "data", "search_term_hits.rds")
if (!file.exists(fn)) {
s_t <- grep("s_1_", names(params), value = TRUE)
search_term_hits <- parallel::mclapply(
s_t,
function(stn) {
message("getting '", stn, "' ...")
if (grepl("_f_", stn)) {
search <- params[[stn]]()
} else {
search <- params[[stn]]
}
search <- compact(search)
openalexR::oa_query(filter = list(title_and_abstract.search = search)) |>
openalexR::oa_request(count_only = TRUE, verbose = TRUE) |>
unlist()
},
mc.cores = params$mc.cores,
mc.preschedule = FALSE
) |>
do.call(what = cbind) |>
t() |>
as.data.frame() |>
dplyr::mutate(page = NULL, per_page = NULL) |>
dplyr::mutate(count = formatC(count, format = "f", big.mark = ",", digits = 0))
rownames(search_term_hits) <- s_t |>
gsub(pattern = "s_1_", replacement = "") |>
gsub(pattern = "f_", replacement = "") |>
gsub(pattern = "^ch", replacement = "Chapter ") |>
gsub(pattern = "_", replacement = " ")
saveRDS(search_term_hits, file = fn)
} else {
search_term_hits <- readRDS(fn)
}
```
```{r}
#| label: get_additional_search_hits
#|
fn <- file.path(".", "tca_corpus", "data", "additional_search.rds")
if (!file.exists(fn)) {
# oa
st <- params$s_1_tca_corpus |>
compact()
count_all <- openalexR::oa_fetch(title_and_abstract.search = st, count_only = TRUE, verbose = TRUE, output = "list")$count
# art
st <- paste0("(", params$s_1_tca_corpus, ") AND (", params$st_art, ")") |>
compact()
count <- openalexR::oa_fetch(title_and_abstract.search = st, count_only = TRUE, verbose = TRUE, output = "list")$count
result <- data.frame(
Category = "Art",
Count = count,
Proportion = count / count_all,
Timestamp = Sys.time()
)
# media
st <- paste0("(", params$s_1_tca_corpus, ") AND (", params$st_media, ")") |>
compact()
count <- openalexR::oa_fetch(title_and_abstract.search = st, count_only = TRUE, verbose = TRUE, output = "list")$count
result <- rbind(
result,
data.frame(
Category = "Media",
Count = count,
Proportion = count / count_all,
Timestamp = Sys.time()
)
)
# imaginative
st <- paste0("(", params$s_1_tca_corpus, ") AND (", params$st_imaginative, ")") |>
compact()
count <- openalexR::oa_fetch(title_and_abstract.search = st, count_only = TRUE, verbose = TRUE, output = "list")$count
result <- rbind(
result,
data.frame(
Category = "Imaginative",
Count = count,
Proportion = count / count_all,
Timestamp = Sys.time()
)
)
# Rights of Nature
st <- paste0("(", params$s_1_tca_corpus, ") AND (", params$st_rights_of_nature, ")") |>
compact()
count <- openalexR::oa_fetch(title_and_abstract.search = st, count_only = TRUE, verbose = TRUE, output = "list")$count
result <- rbind(
result,
data.frame(
Category = "Rights of Nature",
Count = count,
Proportion = count / count_all,
Timestamp = Sys.time()
)
)
# Initiative
st <- paste0("(", params$s_1_tca_corpus, ") AND (", params$st_initiative, ")") |>
compact()
count <- openalexR::oa_fetch(title_and_abstract.search = st, count_only = TRUE, verbose = TRUE, output = "list")$count
result <- rbind(
result,
data.frame(
Category = "Initiative",
Count = count,
Proportion = count / count_all,
Timestamp = Sys.time()
)
)
# Creativity
st <- paste0("(", params$s_1_tca_corpus, ") AND (", params$st_creativity, ")") |>
compact()
count <- openalexR::oa_fetch(title_and_abstract.search = st, count_only = TRUE, verbose = TRUE, output = "list")$count
result <- rbind(
result,
data.frame(
Category = "Creativity",
Count = count,
Proportion = count / count_all,
Timestamp = Sys.time()
)
)
# save it
saveRDS(result, file = fn)
}
```
```{r}
#| label: get_key_papers
#|
fn <- file.path(".", "tca_corpus", "data", "key_papers.rds")
if (!file.exists(fn)) {
key_papers <- lapply(
params$key_papers,
function(fn) {
message("Processing '", fn, "' ...")
sapply(
fn,
function(x) {
read.csv(x) |>
select(DOI)
}
) |>
unlist()
}
)
names(key_papers) <- gsub("\\.csv", "", basename(params$key_papers))
key_papers <- list(
Ch_1 = unlist(key_papers[grepl("Ch 1 -", names(key_papers))], recursive = FALSE) |> as.vector(),
Ch_2 = unlist(key_papers[grepl("Ch 2 -", names(key_papers))], recursive = FALSE) |> as.vector(),
Ch_3_Cl_1 = unlist(key_papers[grepl("Ch 3 - Cl1", names(key_papers))], recursive = FALSE) |> as.vector(),
Ch_3_Cl_3 = unlist(key_papers[grepl("Ch 3 - Cl3", names(key_papers))], recursive = FALSE) |> as.vector(),
Ch_3_Cl_4 = unlist(key_papers[grepl("Ch 3 - Cl4", names(key_papers))], recursive = FALSE) |> as.vector(),
Ch_3_Cl_5 = unlist(key_papers[grepl("Ch 3 - Cl5", names(key_papers))], recursive = FALSE) |> as.vector(),
Ch_3_Cl_6 = unlist(key_papers[grepl("Ch 3 - Cl6", names(key_papers))], recursive = FALSE) |> as.vector(),
Ch_3 = unlist(key_papers[grepl("Ch 3 - p", names(key_papers))], recursive = FALSE) |> as.vector(),
Ch_4_Cl_1 = unlist(key_papers[grepl("Ch 4 - Challenge 1", names(key_papers))], recursive = FALSE) |> as.vector(),
Ch_4_Cl_2 = unlist(key_papers[grepl("Ch 4 - Challenge 2", names(key_papers))], recursive = FALSE) |> as.vector(),
Ch_4_Cl_3 = unlist(key_papers[grepl("Ch 4 - Challenge 3", names(key_papers))], recursive = FALSE) |> as.vector(),
Ch_4_Cl_4 = unlist(key_papers[grepl("Ch 4 - Challenge 4", names(key_papers))], recursive = FALSE) |> as.vector(),
Ch_4_Cl_5 = unlist(key_papers[grepl("Ch 4 - Challenge 5", names(key_papers))], recursive = FALSE) |> as.vector(),
Ch_5 = unlist(key_papers[grepl("Ch 5 -", names(key_papers))], recursive = FALSE) |> as.vector()
)
saveRDS(key_papers, file = fn)
} else {
key_papers <- readRDS(fn)
}
```
```{r}
#| label: get_key_works
#|
fn_kw <- file.path(".", "tca_corpus", "data", "key_works.rds")
fn_kw_df <- file.path(".", "tca_corpus", "data", "key_works_df.rds")
if (!all(file.exists(fn_kw, fn_kw_df))) {
key_works <- parallel::mclapply(
key_papers,
function(kp) {
dois <- kp[kp != ""] |>
unlist() |>
tolower() |>
unique()
openalexR::oa_fetch(doi = dois, output = "list")
},
mc.cores = params$mc.cores,
mc.preschedule = FALSE
)
found <- sapply(
key_works,
function(x) {
length(x) > 0
}
)
key_works <- key_works[found]
print("The following key paper sets were excluded as they contained no papers in OpenAlex:\n")
print(names(found)[!found])
saveRDS(key_works, file = fn_kw)
key_works_df <- lapply(
key_works,
oa2df,
entity = "works"
)
saveRDS(key_works_df, fn_kw_df)
} else {
key_works <- readRDS(file = fn_kw)
key_works_df <- readRDS(fn_kw_df)
}
```
```{r}
#| label: get_key_works_hits
#|
fn <- file.path(".", "tca_corpus", "data", "key_works_hits.rds")
if (!file.exists(fn)) {
kws <- key_works_df
kws$all <- key_works_df |>
bind_rows()
nms <- names(kws)
key_works_hits <- pbapply::pblapply(
nms,
function(nm) {
message("Getting key paper set for ", nm, " ...")
dois <- kws[[nm]] |>
select(doi) |>
distinct() |>
unlist() |>
unique() |>
tolower()
s_t <- grep("s_1_", names(params), value = TRUE)
kw_h <- parallel::mclapply(
s_t,
function(stn) {
message(" getting '", stn, "' ...")
if (grepl("_f_", stn)) {
search <- compact(params[[stn]]())
} else {
search <- compact(params[[stn]])
}
get_count(dois = dois, list(title_and_abstract.search = search), verbose = FALSE)
},
mc.cores = params$mc.cores,
mc.preschedule = FALSE
) |>
do.call(what = cbind) |>
as.data.frame()
message("Done")
names(kw_h) <- s_t
# if (ncol(kw_h) == 1){
# kw_h <- t(kw_h)
# rownames(kw_h) <- dois
# }
kw_h <- rbind(
kw_h,
colSums(kw_h)
)
rownames(kw_h)[[nrow(kw_h)]] <- "Total"
return(kw_h)
}
)
names(key_works_hits) <- nms
for (i in nms) {
# key_works_hits[[i]] <- cbind(
# key_works_hits[[i]],
# key_works_hits_tca_filtered[[i]]
# )
key_works_hits[[i]] <- cbind(
key_works_hits[[i]],
Total = rowSums(key_works_hits[[i]])
) |>
mutate(Total = Total - 1) # |>
# relocate(tca_corpus_SDG, .after = s_1_tca_corpus)
}
###
saveRDS(key_works_hits, file = fn)
} else {
key_works_hits <- readRDS(file = fn)
}
```
```{r}
#| label: get_languages_tca_corpus
#|
fn <- file.path(".", "tca_corpus", "data", "tca_corpus_languages.rds")
if (!file.exists(fn)) {
list(
timestamp <- Sys.time(),
languages = openalexR::oa_fetch(
entity = "works",
title_and_abstract.search = compact(params$s_1_tca_corpus),
group_by = "language",
output = "list",
verbose = TRUE
) |>
lapply(
function(x) {
result <- data.frame(
language = ifelse(
is.null(x["key_display_name"]),
as.character(NA),
as.character(x["key_display_name"])
),
count = ifelse(
is.null(x["count"]),
as.integer(NA),
as.integer(x["count"])
)
)
return(result)
}
) |>
do.call(what = rbind) |>
dplyr::arrange(desc(count)) |>
dplyr::filter(count > 0)
) |>
saveRDS(file = fn)
}
```
### Works over Time
Get works over time for different search terms
```{r}
#| label: get_count_years
#|
fn <- file.path(".", "tca_corpus", "data", "oa_count.rds")
if (!file.exists(fn)) {
oa_count <- list(
timestamp = Sys.time()
)