Skip to content

Commit d47567a

Browse files
committed
Update get_propety_definition.R
1 parent bb2f704 commit d47567a

1 file changed

Lines changed: 14 additions & 18 deletions

File tree

R/get_propety_definition.R

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,14 @@
22
#' @description Receive the label and description of a property on the basis of
33
#' its PID from a Wikibase instance. It will not add further statements about
44
#' the property.
5-
#' @details Currently the languages choose a default, "en", for cases where the
6-
#' user-chosen language return empty labels and descriptions. This feature may
7-
#' be elaborated or changed later. The function receives aliases (alternative
8-
#' labels), too, but does not return them; the format of aliases needs to be
9-
#' decided in view of how other functions will use them, as aliases themselves
10-
#' can break the tidiness of the returned data.
5+
#' @details Currently the language has a choose a default, \code{"en"}, for
6+
#' cases where the user-chosen language return empty labels and descriptions.
7+
#' This feature may be elaborated or changed later. The function receives
8+
#' aliases (alternative labels), too, but does not return them; the format of
9+
#' aliases needs to be decided in view of how other functions will use them,
10+
#' as aliases themselves can break the tidiness of the returned data.
1111
#' @param pid The PID of the property in the Wikibase instance (or Wikidata
1212
#' itself).
13-
#' @param languages Defaults to \code{c("en", "nl", "hu")}. A character string
14-
#' of the languages in which the users wants to receive the labels and
15-
#' descriptions of the property. The vector of languages must use BCP
16-
#' 47-compliant language tags (e.g., "en" for English, "nl" for Dutch and "hu"
17-
#' ofr Hungarian.)
1813
#' @param wikibase_api_url Defaults to
1914
#' \code{"https://www.wikidata.org/w/api.php"}, may be replaced with a similar
2015
#' API address of a Wikibase instance. Private instances may require an
@@ -33,13 +28,14 @@
3328
#' @examples
3429
#' # Receive a data.frame for further use
3530
#' get_property_definition(pid = "P2047", return_type = "data.frame")
31+
#'
3632
#' # Receive JSON for copying with wbeditidentiy
3733
#' get_property_definition(pid = "P2047", languages = c("en", "hu"))
3834
#' @export
3935

4036
get_property_definition <- function(
4137
pid,
42-
languages = c("en", "nl", "hu"),
38+
language = c("en", "nl", "hu"),
4339
wikibase_api_url = "https://www.wikidata.org/w/api.php",
4440
return_type = "JSON") {
4541
## Ensure that the pid is a character string starting with P followed by
@@ -116,15 +112,15 @@ get_property_definition <- function(
116112

117113
## We must determine which labels, descriptions, aliases actually exist
118114
## in the languages requested by the user.
119-
labels_present <- languages[which(languages %in% names(response$entities[[1]]$labels))]
120-
labels_missing <- languages[which(!languages %in% names(response$entities[[1]]$labels))]
115+
labels_present <- language[which(language %in% names(response$entities[[1]]$labels))]
116+
labels_missing <- language[which(!language %in% names(response$entities[[1]]$labels))]
121117

122-
descriptions_present <- languages[which(languages %in% names(response$entities[[1]]$descriptions))]
123-
descriptions_missing <- languages[which(!languages %in% names(response$entities[[1]]$descriptions))]
118+
descriptions_present <- language[which(language %in% names(response$entities[[1]]$descriptions))]
119+
descriptions_missing <- language[which(!language %in% names(response$entities[[1]]$descriptions))]
124120

125121
# We do not work with the aliases now, but they may be used later.
126-
aliases_present <- languages[which(languages %in% names(response$entities[[1]]$aliases))]
127-
aliases_missing <- languages[which(!languages %in% names(response$entities[[1]]$aliases))]
122+
aliases_present <- language[which(language %in% names(response$entities[[1]]$aliases))]
123+
aliases_missing <- language[which(!language %in% names(response$entities[[1]]$aliases))]
128124

129125
## Set a default later, this is now hard coded to English but could be a parameter.
130126

0 commit comments

Comments
 (0)