Copy a Wikidata item(s)
Source:R/copy_wikidata_item.R, R/copy_wikidata_property.R
copy_wikidata_item.RdThis code will copy (an) item label(s) and description(s) from Wikidata to a new instance. It should work between instances, but the authentication to copy from a password protected instance is not yet coded. The function is more specific than create_item, because this one creates items that exist in a similarly structured Wikibase instance, such as Wikidata.
Usage
copy_wikidata_item(
qid_on_wikidata = "Q4",
qid_equivalence_property = "P35",
language = c("en", "nl", "hu"),
classification_property = NA_character_,
classification_id = NA_character_,
wikibase_api_url = "https://reprexbase.eu/jekyll/api.php",
data_curator = NULL,
log_file_name = NULL,
csrf,
wikibase_session = NULL
)
copy_wikidata_items(
qid_on_wikidata,
qid_equivalence_property,
classification_property,
classification_id,
language,
wikibase_api_url,
data_curator,
csrf,
wikibase_session
)
copy_wikidata_properties(
pid_on_wikidata,
pid_equivalence_property,
language,
wikibase_api_url,
data_curator,
csrf,
wikibase_session = NULL
)Arguments
- qid_on_wikidata
The QID of the item to be copied to your Wikibase. A single valid QID or a vector of several QIDs.
- qid_equivalence_property
The QID in Wikibase that records the equivalent Wikidata QID as an external ID.
- language
Defaults to
c("en", "nl", "hu"). A character string of the languages in which the users wants to receive the labels and descriptions of the property. The vector of languages must use BCP 47-compliant language tags (e.g., "en" for English, "nl" for Dutch and "hu" for Hungarian.)- classification_property
The instance of, or subclass of, or superclass of property. Defaults to
NA_characterwhen not used.- classification_id
The QID of the class. Defaults to
NA_characterwhen not used.- wikibase_api_url
The full URL of the Wikibase API, which is the address that the
wbdatasetR client sends requests to when interacting with the knowledge base. For example,'https://reprexbase.eu/demowiki/api.php'. The URL must end with api.php.- data_curator
The name of the data curator who runs the function and creates the log file, created with person.
- log_file_name
An explicitly stated full path to a possible CSV log file, defaults to
NULL. If the value isNULL, no log file will be created.- csrf
The CSRF token of your session, received with
get_csrf.- wikibase_session
An optional list that contains any of the values of parameters
qid_equivalence_property,language,wikibase_api_url,data_curator,log_pathandcsrf(for repeated use in a session.)
Value
Returns a dataset_df object.
The columns are:
rowidA row identifier.
actioncopy_wikidata_itemid_on_targetThe new item identifier (QID) on the targeted Wikibase.
labelThe propery label
descriptionThe description label
languageThe language code of the label.
datatypeThe datatype of the property, for example,
stringwikibase_api_urlThe MediaWiki API URL where the new property is created.
equivalence_propertyThe PID that connects an equivalence ID to the property.
equivalence_idThe ID of an equivalent property defined elsewhere.
classification_propertyThe PID that connects the item to a superclass, or class.
classification_idThe QID of a class, subclass or superclass.
successTRUE if successfully created, FALSE if there was an error.
commentA summary of the error messages(s), if success is FALSE.
timeThe time when the action started.
logfileThe name of the CSV logfile.
The number of rows corresponds to the length of the qid_on_wikidata vector.
Details
This function is slightly different from create_item. That function
creates a new item that may not have an equivalent item on another Wikibase
instance, but it may well have an equivalent item in another database.
In this function, we use qid_equivalence_property for equivalence.
In the more general create function we use equivalence_item, because
we may use different identifiers. Similarly, the qid_on_wikidata
replaces the more general equivalence_id, because we must use QID
for identification in an other Wikibase instance.