Skip to content

Commit

Permalink
0.1.1017
Browse files Browse the repository at this point in the history
  • Loading branch information
antaldaniel committed Feb 20, 2025
1 parent 5473af3 commit 0cce548
Show file tree
Hide file tree
Showing 10 changed files with 37 additions and 34 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: wbdataset
Title: Making Datasets Truly Interoperable and Reusable in R with Wikibase
Version: 0.1.1016
Version: 0.1.1017
Date: 2024-02-20
Authors@R:
c(person(given="Daniel", family="Antal",
Expand Down
11 changes: 7 additions & 4 deletions R/copy_wikidata_item.R
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,14 @@ copy_wikidata_item <- function(
qid_equivalence_property <- wikibase_session$qid_equivalence_property
}

if (!is.null(wikibase_session$language)) {
language <- wikibase_session$language
if(!is.null(wikibase_session$language)) {
# overwrite session default if it does not exist
if (is.null(language)) language <- wikibase_session$language
}
if (!is.null(wikibase_session$data_curator)) {
data_curator <- wikibase_session$data_curator

if(!is.null(wikibase_session$data_curator)) {
# overwrite session default if it does not exist
if( is.null(data_curator)) data_curator <- wikibase_session$data_curator
}

if (!is.null(wikibase_session$wikibase_api_url)) {
Expand Down
13 changes: 8 additions & 5 deletions R/copy_wikidata_property.R
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,14 @@ copy_wikidata_property <- function(
pid_equivalence_property <- wikibase_session$pid_equivalence_property
}

if (!is.null(wikibase_session$language)) {
language <- wikibase_session$language
if(!is.null(wikibase_session$language)) {
# overwrite session default if it does not exist
if (is.null(language)) language <- wikibase_session$language
}
if (!is.null(wikibase_session$data_curator)) {
data_curator <- wikibase_session$data_curator

if(!is.null(wikibase_session$data_curator)) {
# overwrite session default if it does not exist
if( is.null(data_curator)) data_curator <- wikibase_session$data_curator
}

if (!is.null(wikibase_session$wikibase_api_url)) {
Expand Down Expand Up @@ -126,7 +129,7 @@ copy_wikidata_property <- function(
# Timestamping ---------------------------------------------------------------------
action_time <- Sys.time()
# Save the time of running the code
action_timestamp <- action_timestamp_create()
action_timestamp <- wbdataset:::action_timestamp_create()
log_file_name <- paste0("wbdataset_copy_wikibase_item_", action_timestamp, ".csv")


Expand Down
11 changes: 7 additions & 4 deletions R/create_item.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#' @title Create a property
#' @description Creates an item entity on a Wikibase instance with a single
#' language labelling and description. New labels and descriptions can be added
#' in further languages later. This is a wrapper for
#' in further language later. This is a wrapper for
#' \href{https://www.wikidata.org/w/api.php?action=help&modules=wbeditentity}{MediaWiki
#' action=wbeditentity}
#' @details Optionally, the function adds an equivalent item to this newly
Expand Down Expand Up @@ -83,11 +83,14 @@ create_item <- function(label,
if (!is.null(wikibase_session)) {
# For repeated queries you can add your variables directly or in a list

if(!is.null(wikibase_session$languages)) {
languages <- wikibase_session$languages
if(!is.null(wikibase_session$language)) {
# overwrite session default if it does not exist
if (is.null(language)) language <- wikibase_session$language
}

if(!is.null(wikibase_session$data_curator)) {
data_curator <- wikibase_session$data_curator
# overwrite session default if it does not exist
if( is.null(data_curator)) data_curator <- wikibase_session$data_curator
}

if(!is.null(wikibase_session$wikibase_api_url)) {
Expand Down
10 changes: 6 additions & 4 deletions R/create_property.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#' @title Create a property
#' @description Creates a property entity on a Wikibase instance with a single
#' language labelling and description. New labels and descriptions can be added
#' in further languages later. This is a wrapper for
#' in further language later. This is a wrapper for
#' \href{https://www.wikidata.org/w/api.php?action=help&modules=wbeditentity}{MediaWiki
#' action=wbeditentity}
#' @details Optionally, the function adds an equivalent property to this newly
Expand Down Expand Up @@ -84,11 +84,13 @@ create_property <- function(label,
if (!is.null(wikibase_session)) {
# For repeated queries you can add your variables directly or in a list

if(!is.null(wikibase_session$languages)) {
languages <- wikibase_session$languages
if(!is.null(wikibase_session$language)) {
# overwrite session default if it does not exist
if (is.null(language)) language <- wikibase_session$language
}
if(!is.null(wikibase_session$data_curator)) {
data_curator <- wikibase_session$data_curator
# overwrite session default if it does not exist
if( is.null(data_curator)) data_curator <- wikibase_session$data_curator
}

if(!is.null(wikibase_session$wikibase_api_url)) {
Expand Down
6 changes: 1 addition & 5 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ knitr::opts_chunk$set(
<!-- badges: start -->
[![Lifecycle: experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://lifecycle.r-lib.org/articles/stages.html#experimental)
[![CRAN status](https://www.r-pkg.org/badges/version/wbdataset)](https://CRAN.R-project.org/package=wbdataset)
[![devel-version](https://img.shields.io/badge/devel%20version-0.1.1016-blue.svg)](https://github.com/dataobservatory-eu/wbdataset)
[![devel-version](https://img.shields.io/badge/devel%20version-0.1.1017-blue.svg)](https://github.com/dataobservatory-eu/wbdataset)
[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.13972192.svg)
[![Codecov test coverage](https://codecov.io/gh/dataobservatory-eu/wbdataset/graph/badge.svg)](https://app.codecov.io/gh/dataobservatory-eu/wbdataset)
<!-- badges: end -->
Expand All @@ -35,10 +35,6 @@ devtools::install_github("antaldaniel/dataset")
devtools::install_github("dataobservatory-eu/wbdataset")
```

```{r}
library(wbdataset)
```

## Example

This is a basic example which shows you how to solve a common problem:
Expand Down
6 changes: 1 addition & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://lifecycle.r-lib.org/articles/stages.html#experimental)
[![CRAN
status](https://www.r-pkg.org/badges/version/wbdataset)](https://CRAN.R-project.org/package=wbdataset)
[![devel-version](https://img.shields.io/badge/devel%20version-0.1.1016-blue.svg)](https://github.com/dataobservatory-eu/wbdataset)
[![devel-version](https://img.shields.io/badge/devel%20version-0.1.1017-blue.svg)](https://github.com/dataobservatory-eu/wbdataset)
\[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.13972192.svg)
[![Codecov test
coverage](https://codecov.io/gh/dataobservatory-eu/wbdataset/graph/badge.svg)](https://app.codecov.io/gh/dataobservatory-eu/wbdataset)
Expand All @@ -33,10 +33,6 @@ devtools::install_github("antaldaniel/dataset")
devtools::install_github("dataobservatory-eu/wbdataset")
```

``` r
library(wbdataset)
```

## Example

This is a basic example which shows you how to solve a common problem:
Expand Down
2 changes: 1 addition & 1 deletion man/create_item.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion man/create_property.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions vignettes/start.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ There are two ways to create items:
paris_item <- copy_wikidata_item(
qid_on_wikidata = "Q90", # check https://www.wikidata.org/wiki/Q90
qid_equivalence_property = NULL, # we will get back to this later
languages = c("en", "fr", "nl"), # select languages with 2-letter codes
language = c("en", "fr", "nl"), # select language with 2-letter codes
wikibase_api_url = "https://reprexbase.eu/jekyll/api.php", # Wikibase address
data_curator = person("Jane", "Doe"), # Your name should go in here !
log_path = tempdir(), # You can add a location where you save log file
Expand Down Expand Up @@ -141,7 +141,7 @@ it is saved in `e20`. If the action was successul, which you can check with `e20
capital_cities <- copy_wikidata_property(
qid_on_wikidata = c("Q2807", "Q3114", "Q1490"),
qid_equivalence_property = "P35", # use your Wikibase instance's number
languages = c("en", "nl", "hu", "es" ),
language = c("en", "nl", "hu", "es" ),
wikibase_api_url = "https://reprexbase.eu/jekyll/api.php",
data_curator = person("Joe", "Doe"),
log_path = tempdir(),
Expand All @@ -168,7 +168,7 @@ Properties connect new information to your items (nodes.) Such properties need t
p21 <- copy_wikidata_property(
pid_on_wikidata = "P21",
pid_equivalence_property = "P2", # You need to change this to your numbering
languages = c("en", "hu"),
language = c("en", "hu"),
wikibase_api_url = "https://reprexbase.eu/jekyll/api.php",
data_curator = person("Jane", "Doe"), # Replace it with your name
csrf = my_csrf
Expand Down Expand Up @@ -257,7 +257,7 @@ You can copy many properties at once, too, but only with the same language, cura
spotify_id_properties <- copy_wikidata_property(
pid_on_wikidata = c("P2207", "P2205", "P8704"),
pid_equivalence_property = "P2", # use the P number on your Wikibase instance
languages = c("en", "nl", "hu" ),
language = c("en", "nl", "hu" ),
wikibase_api_url = "https://reprexbase.eu/jekyll/api.php",
data_curator = person("Jane", "Doe"),
log_path = tempdir(),
Expand Down

0 comments on commit 0cce548

Please sign in to comment.