Skip to content

Commit b39ddab

Browse files
committed
Update to work with dataset
1 parent 23df648 commit b39ddab

11 files changed

Lines changed: 113 additions & 50 deletions

DESCRIPTION

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Package: wbdataset
22
Title: Making Datasets Truly Interoperable and Reusable in R with Wikibase
3-
Version: 0.1.1050
4-
Date: 2024-04-20
3+
Version: 0.1.1051
4+
Date: 2024-05-17
55
Authors@R:
66
c(person(given="Daniel", family="Antal",
77
email= "daniel.antal@dataobservatory.eu",

R/add_statement.R

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ add_statement <- function(
1717
wikibase_type = c("item", "string", "numeric", "external-id"),
1818
wikibase_api_url = "https://reprexbase.eu/demowiki/api.php",
1919
csrf) {
20+
2021
if (!is.character(wikibase_type) || length(wikibase_type) != 1) {
2122
stop("add_statement(): 'wikibase_type' must be a single character string.")
2223
}

R/copy_wikidata_item.R

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,20 @@
2929
#' @param wikibase_api_url The full URL of the Wikibase API, which is the
3030
#' address that the \code{wbdataset} R client sends requests to when
3131
#' interacting with the knowledge base. For example,
32-
#' \code{'https://reprexbase.eu/demowiki/api.php'}. The URL must end with
33-
#' api.php.
32+
#' \code{'https://reprexbase.eu/jekyll/api.php'}. The URL must end with
33+
#' api.php. It is either given as a parameter or resolved from
34+
#' \code{wikibase_session}.
3435
#' @param data_curator The name of the data curator who runs the function and
3536
#' creates the log file, created with \link[utils]{person}.
37+
#' It is either given as a parameter or resolved from
38+
#' \code{wikibase_session}. If no curator is given, then filled with
39+
#' \code{person("Unknown", "Curator")}.
3640
#' @param log_file_name An explicitly stated full path to a possible CSV log
3741
#' file, defaults to \code{NULL}. If the value is \code{NULL}, no log file
3842
#' will be created.
3943
#' @param csrf The CSRF token of your session, received with
40-
#' \code{\link{get_csrf}}.
44+
#' \code{\link{get_csrf}}. It is either given as a parameter or resolved
45+
#' from \code{wikibase_session}.
4146
#' @param wikibase_session An optional named list of default values to reuse
4247
#' across multiple function calls. If any of the main parameters (such as
4348
#' \code{language}, \code{data_curator}, \code{log_file_name},
@@ -77,10 +82,10 @@ copy_wikidata_item <- function(
7782
language = "en",
7883
classification_property = NA_character_,
7984
classification_id = NA_character_,
80-
wikibase_api_url,
85+
wikibase_api_url = NULL,
8186
data_curator = NULL,
8287
log_file_name = NULL,
83-
csrf,
88+
csrf = NULL,
8489
wikibase_session = NULL) {
8590

8691
language <- resolve_from_session("language", language, wikibase_session)
@@ -91,6 +96,9 @@ copy_wikidata_item <- function(
9196
csrf <- resolve_from_session("csrf", csrf, wikibase_session)
9297
qid_equivalence_property <- resolve_from_session("qid_equivalence_property", qid_equivalence_property, wikibase_session)
9398

99+
if (is.null(data_curator)) {
100+
data_curator <- person("Unknown", "Curator", role = "dtm")
101+
}
94102

95103
validate_copy_entity_args(
96104
language = language,
@@ -139,7 +147,7 @@ copy_wikidata_item <- function(
139147

140148
# Assert that qid_on_wikidata looks like a QID
141149
qid_on_wikidata <- as.character(qid_on_wikidata)
142-
assertthat::assert_that(is_qid(qid_on_wikidata),
150+
assert_that(is_qid(qid_on_wikidata),
143151
msg = "qid_on_wikidata must start with Q followed by digits."
144152
)
145153

R/copy_wikidata_property.R

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,20 @@
3131
#' @param wikibase_api_url The full URL of the Wikibase API, which is the
3232
#' address that the \code{wbdataset} R client sends requests to when
3333
#' interacting with the knowledge base. For example,
34-
#' \code{'https://reprexbase.eu/demowiki/api.php'}. The URL must end with
35-
#' api.php.
34+
#' \code{'https://reprexbase.eu/jekyll/api.php'}. The URL must end with
35+
#' api.php. It is either given as a parameter or resolved from
36+
#' \code{wikibase_session}.
3637
#' @param data_curator The name of the data curator who runs the function and
3738
#' creates the log file, created with \link[utils]{person}.
39+
#' It is either given as a parameter or resolved from
40+
#' \code{wikibase_session}. If no curator is given, then filled with
41+
#' \code{person("Unknown", "Curator")}.
3842
#' @param log_file_name An explicitly stated full path to a possible CSV log
3943
#' file, defaults to \code{NULL}. If the value is \code{NULL}, no log file
4044
#' will be created.
4145
#' @param csrf The CSRF token of your session, received with
42-
#' \code{\link{get_csrf}}.
46+
#' \code{\link{get_csrf}}. It is either given as a parameter or resolved
47+
#' from \code{wikibase_session}.
4348
#' @param wikibase_session An optional named list of default values to reuse
4449
#' across multiple function calls. If any of the main parameters (such as
4550
#' \code{language}, \code{data_curator}, \code{log_file_name},
@@ -77,14 +82,14 @@ copy_wikidata_property <- function(
7782
pid_on_wikidata,
7883
pid_equivalence_property,
7984
language = "en",
80-
wikibase_api_url,
85+
wikibase_api_url = NULL,
8186
classification_property = NA_character_,
8287
classification_id = NA_character_,
8388
equivalence_property = NA_character_,
8489
equivalence_id = NA_character_,
8590
data_curator = NULL,
8691
log_file_name = NULL,
87-
csrf,
92+
csrf = NULL,
8893
wikibase_session = NULL) {
8994

9095
language <- resolve_from_session("language", language, wikibase_session)
@@ -97,6 +102,10 @@ copy_wikidata_property <- function(
97102

98103
csrf <- resolve_from_session("csrf", csrf, wikibase_session)
99104

105+
if (is.null(data_curator)) {
106+
data_curator <- person("Unknown", "Curator", role = "dtm")
107+
}
108+
100109
validate_copy_entity_args(
101110
language = language,
102111
wikibase_api_url = wikibase_api_url,

R/create_item.R

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,20 @@
3333
#' @param wikibase_api_url The full URL of the Wikibase API, which is the
3434
#' address that the \code{wbdataset} R client sends requests to when
3535
#' interacting with the knowledge base. For example,
36-
#' \code{'https://reprexbase.eu/demowiki/api.php'}. The URL must end with
37-
#' api.php.
36+
#' \code{'https://reprexbase.eu/jekyll/api.php'}. The URL must end with
37+
#' api.php. It is either given as a parameter or resolved from
38+
#' \code{wikibase_session}.
3839
#' @param data_curator The name of the data curator who runs the function and
3940
#' creates the log file, created with \link[utils]{person}.
41+
#' It is either given as a parameter or resolved from
42+
#' \code{wikibase_session}. If no curator is given, then filled with
43+
#' \code{person("Unknown", "Curator")}.
4044
#' @param log_file_name An explicitly stated full path to a possible CSV log
4145
#' file, defaults to \code{NULL}. If the value is \code{NULL}, no log file
4246
#' will be created.
4347
#' @param csrf The CSRF token of your session, received with
44-
#' \code{\link{get_csrf}}.
48+
#' \code{\link{get_csrf}}. It is either given as a parameter or resolved
49+
#' from \code{wikibase_session}.
4550
#' @param wikibase_session An optional named list of default values to reuse
4651
#' across multiple function calls. If any of the main parameters (such as
4752
#' \code{language}, \code{data_curator}, \code{log_file_name},
@@ -98,11 +103,11 @@ create_item <- function(label,
98103
equivalence_id = NA_character_,
99104
classification_property = NA_character_,
100105
classification_id = NA_character_,
101-
wikibase_api_url,
106+
wikibase_api_url = NULL,
102107
data_curator = NULL,
103108
log_file_name = NULL,
104-
csrf,
105-
wikibase_session=NULL) {
109+
csrf = NULL,
110+
wikibase_session = NULL) {
106111

107112
language <- resolve_from_session("language", language, wikibase_session)
108113
data_curator <- resolve_from_session("data_curator", data_curator, wikibase_session)
@@ -112,6 +117,10 @@ create_item <- function(label,
112117
classification_property <- resolve_from_session("wikibase_api_url", classification_property , wikibase_session)
113118
csrf <- resolve_from_session("csrf", csrf, wikibase_session)
114119

120+
if (is.null(data_curator)) {
121+
data_curator <- person("Unknown", "Curator", role = "dtm")
122+
}
123+
115124
validate_create_entity_args(
116125
label = label,
117126
description = description,

R/create_property.R

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,23 @@
3535
#' interacting with the knowledge base. For example,
3636
#' \code{'https://reprexbase.eu/demowiki/api.php'}. The URL must end with
3737
#' api.php.
38+
#' @param wikibase_api_url The full URL of the Wikibase API, which is the
39+
#' address that the \code{wbdataset} R client sends requests to when
40+
#' interacting with the knowledge base. For example,
41+
#' \code{'https://reprexbase.eu/jekyll/api.php'}. The URL must end with
42+
#' api.php. It is either given as a parameter or resolved from
43+
#' \code{wikibase_session}.
3844
#' @param data_curator The name of the data curator who runs the function and
3945
#' creates the log file, created with \link[utils]{person}.
40-
#' @param csrf The CSRF token of your session, received with
41-
#' \code{\link{get_csrf}}.
46+
#' It is either given as a parameter or resolved from
47+
#' \code{wikibase_session}. If no curator is given, then filled with
48+
#' \code{person("Unknown", "Curator")}.
4249
#' @param log_file_name An explicitly stated full path to a possible CSV log
4350
#' file, defaults to \code{NULL}. If the value is \code{NULL}, no log file
4451
#' will be created.
52+
#' @param csrf The CSRF token of your session, received with
53+
#' \code{\link{get_csrf}}. It is either given as a parameter or resolved
54+
#' from \code{wikibase_session}.
4555
#' @param wikibase_session An optional named list of default values to reuse
4656
#' across multiple function calls. If any of the main parameters (such as
4757
#' \code{language}, \code{data_curator}, \code{log_file_name},
@@ -94,10 +104,10 @@ create_property <- function(label,
94104
datatype,
95105
equivalence_property = NA_character_,
96106
equivalence_id = NA_character_,
97-
wikibase_api_url,
107+
wikibase_api_url = NULL,
98108
data_curator = NULL,
99109
log_file_name = NULL,
100-
csrf,
110+
csrf = NULL,
101111
wikibase_session = NULL) {
102112

103113
language <- resolve_from_session("language", language, wikibase_session)
@@ -111,6 +121,10 @@ create_property <- function(label,
111121
stop ("create_property(..., datatype): ", datatype, " is not a valid Wikibase property type.")
112122
}
113123

124+
if (is.null(data_curator)) {
125+
data_curator <- person("Unknown", "Curator", role = "dtm")
126+
}
127+
114128
validate_create_entity_args(
115129
label = label,
116130
description = description,

man/check_existing_item.Rd

Lines changed: 5 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/copy_wikidata_item.Rd

Lines changed: 11 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/copy_wikidata_property.Rd

Lines changed: 11 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/create_item.Rd

Lines changed: 11 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)