forked from SebastienBoutry/inrae-project-website
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpublications.qmd
103 lines (73 loc) · 2.71 KB
/
publications.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
---
title: Publications
params:
hal_project_name: "DYLAQ"
hal_collection: "EABX"
nocite: |
@*
bibliography: API_HAL_project.bib
---
This page uses the [HAL Open API](https://api.archives-ouvertes.fr/docs) to automatically query the project's bibliographic references. You will need to fill in the following two parameters in your YAML :
* `hal_project_name`
* `hal_collection`
This query relies on the 'Collaboration/Project' field of every HAL upload. To make the best use of this request, you must ensure that this field is always entered consistently with the project acronym (the one you will use in `hal_project_name`).
The query will automatically append its results to the `API_HAL_project.bib` file.
In the following example, the parameters used in the YAML are
```yaml
params:
hal_project_name: "DYLAQ"
hal_collection: "EABX"
```
```{r echo=FALSE, eval=TRUE, warning=FALSE, message=FALSE, error=FALSE, include=FALSE, results="asis"}
library(httr2)
library(wordcloud2)
library(bib2df)
library(data.table)
## API call to HAL
request_project <- paste0(
"https://api.archives-ouvertes.fr/search/?q=*", "&fq=collaboration_s:", params$hal_project_name,
"&fq=collCode_s:", params$hal_collection,
"&rows=10000&wt=bibtex"
)
req <- httr2::req_perform(httr2::request(request_project))
## Write content to bib file
if (length(req$body) > 0) {
file.remove("API_HAL_project.bib")
res <- unlist(httr2::resp_body_string(req))
writeLines(res, "API_HAL_project.bib")
} else {
}
```
## List of publications (based on HAL-INRAE)
::: {#refs}
:::
---
## WordCloud
```{r keywords, echo=FALSE, eval=TRUE, warning=FALSE, message=FALSE, results="asis"}
# Read bib content to dataframe
df_refs <- bib2df::bib2df("API_HAL_project.bib")
if (nrow(df_refs) > 0) {
# Convert df_refs to a data.table
df_refs_dt <- as.data.table(df_refs)
# Filter out NA values and convert keywords to upper case
keywords <- na.omit(df_refs_dt$KEYWORDS)
keywords <- toupper(keywords)
# Concatenate keywords, split by semicolon, and trim whitespace
concatenated_keywords <- paste(keywords, collapse = " ; ")
split_keywords <- unlist(strsplit(concatenated_keywords, ";"))
trimmed_keywords <- trimws(split_keywords)
# Create a data.table with keywords
keywords_dt <- data.table(keywords = trimmed_keywords)
# Count occurrences of each keyword
keywords_count <- keywords_dt[, .N, by = keywords]
wordcloud2::wordcloud2(keywords_count,
backgroundColor = "#275662",
size = 0.2,
color = "white",
minRotation = -pi / 6,
maxRotation = -pi / 6
)
} else {
print("no publications based on HAL-INRAE")
}
```