User:Mzeinstra/sandbox/QS: Difference between revisions

From Beyond Notability
No edit summary
 
(9 intermediate revisions by one other user not shown)
Line 1: Line 1:
'''QuickStatements''' ('''QS''') is a tool that can edit Beyond Notability items, based on a simple set of text commands. The tool can add and remove statements, descriptions and aliases; as well as add statements with optional qualifiers and sources. The command sequence can be typed in the import window or created in a spreadsheet or text editor and pasted in.  
'''QuickStatements''' ('''QS''') is a tool that can edit Beyond Notability items, based on a simple set of text commands. The tool can add and remove statements, descriptions and aliases; as well as add statements with optional qualifiers and sources. The command sequence can be typed in the import window or created in a spreadsheet or text editor and pasted in.  
Accessing QuickStatements can be done by going to


A thorough explanation on how QuickStatements works can be found on [[wikidata:Help:QuickStatements|this help page on Wikidata]].
A thorough explanation on how QuickStatements works can be found on [[wikidata:Help:QuickStatements|this help page on Wikidata]].
Line 7: Line 5:
== Basic working ==
== Basic working ==


* Go to one of the links <link> to access QuickStatement. We strongly advise using the staging environment to get familiar with the tool.
* Go to one of the link in the Wikibase menu on the left to access QuickStatement, or click [https://beyond-notability.wikibase.cloud/tools/quickstatements/#/ here].  
* Click on 'Log in' to log in Quick Statements to your account. You can be prompted with an information box asking for authorisation:
* Click on 'Log in' to log in Quick Statements to your account. You can be prompted with an information box asking for authorisation:
* After allowing QuickStatements to make edits on your behalf (by clicking 'Allow') you can use the tool.
* After allowing QuickStatements to make edits on your behalf (by clicking 'Allow') you can use the tool.
* Click on 'New batch' to create a set of new commands.  
* Click on 'New batch' to create a set of new commands.  
Line 20: Line 17:
A new statement can be added to an existing item by:
A new statement can be added to an existing item by:


* fist referencing the Q number of the item in question (eg. [[Item:Q340|Q340]])
* fist referencing the Q number of the item in question (eg. [[Item:Q462|Q465]]), Edith Blake
* followed by the P number of the property (eg. gender [[Property:P23|P23]])  
* followed by the P number of the property (eg. instance of [[Property:P12|P12]])  
* and finally the value to be added,  
* and finally the value to be added,  
** which can reference another item by its Q number (eg. male [[Item:Q3|Q3]])  
** which can reference another item by its Q number (eg. human [[Item:Q2137|Q2137]])  
** or a string value, delimited by "" (eg. "2021-02-21" or "Lucius, Michel").  
** or a string value, delimited by "" (eg. "2021-02-21" or "Lucius, Michel").  


These 3 elements need to be separated by a TAB or "|" characters
These 3 elements need to be separated by a TAB or "|" characters
  Q340|P23|Q3
e.g. adding that Edith Blake is a woman, and adding that her birth day is 1876-12-09 (fictitious date).
  Q462|P12|QQ2137


  Q340 P19 "1876-12-09"
  Q462 P26 "1876-12-09"


==== QS commands to add qualifiers to statements ====
==== QS commands to add qualifiers to statements ====


When adding statements using QS, corresponding qualifiers can be added by appending the statement by the P number of the qualifier (eg. name format [[Property:P10|P10]]) and its value, Q number or string (eg. indirect order [[Item:Q16|Q16]]).
When adding statements using QS, corresponding qualifiers can be added by appending the statement by the P number of the qualifier, For example, adding a street address to a "resided at" statement.  
  Q340|P18|"Lucius, Michel"|P10|Q16
  Q462|P29|Q620|P31|"King's House, Jamaica (British English)"


Q340 P18 "Lucius, Michel" P10 Q16
  Q462 P29 Q620 P31 "King's House, Jamaica (British English)"


==== QS commands to add references to statements ====
==== QS commands to add references to statements ====
References can be added in the same way as qualifiers to statements, this by adding the property (P) number, but replacing the P by an S (eg. source of information - text [[Property:P13|P13]] becomes S13).
References can be added in the same way as qualifiers to statements, this by adding the property (P) number, but replacing the P by an S (eg. "specific reference information (free text)"[[Property:P88|P88]] becomes S88).
  Q340|P23|Q3|S13|"Autorenlexikon"
  Q462|P29|Q620|S88|"Annual Report of the Board of Regents of the Smithsonian Institution (British English)"


  Q340 P19 "1876-12-09" S13 "British Library"
  Q462 P29 Q620 S88 "Annual Report of the Board of Regents of the Smithsonian Institution (British English)"


==== QS commands to remove statements ====
==== QS commands to remove statements ====
QS can also be used to remove statements from your Wikibase, by adding a "-" in front of your command. For example:
QS can also be used to remove statements from your Wikibase, by adding a "-" in front of your command. For example removing the gender of a person:
  -Q340|P23|Q3
  -Q462|P3|Q3


  -Q172|P20|"St. Gallen"
Or remove all Wikidata links:
  -Q462|P117
Please note that the "-" command always removes the entire statement, so elements that you want to conserve need to be created again after a removal. This includes any qualifiers or references associated to the statement, thus they do not need to be explicitly mentioned in the removal command.
Please note that the "-" command always removes the entire statement, so elements that you want to conserve need to be created again after a removal. This includes any qualifiers or references associated to the statement, thus they do not need to be explicitly mentioned in the removal command.


'''Notes:'''
'''Notes:'''


* If an identical statement already exist (exact match of property and value to the QS statement), the existing statement will not be change and no new statement added.
* If an identical statement already exists (exact match of property and value to the QS statement), the existing statement will not be changed and no new statement added.
* However if the new statement includes new properties or references, these will be added to the matching existing statement.
* However if the new statement includes new properties or references, these will be added to the matching existing statement.
* Several qualifiers can follow a same statement in QS.
* Several qualifiers can follow the same statement in QS.
* Within one batch only TAB or "|" characters should be used, mixing both does not work.
* Within one batch only TAB or "|" characters should be used, mixing both does not work.
* Within one batch multiple statements can be included, each however in a new line.
* Within one batch multiple statements can be included, each however in a new line.
Line 61: Line 60:
==== QS commands to create new items ====
==== QS commands to create new items ====


It is also possible to create entirely new items using QS, this by using "CREATE", which used by itself, will create a new item without any statements. To add statements to this newly created item, "LAST" is used. Which replaces the Q number in a QS statement and will simply add statements to the last created item. Note that ,multiple "LAST" can follow a "CREATE" all adding statements to that newly create item.
It is also possible to create entirely new items using QS, this by using "CREATE", which used by itself, will create a new item without any statements. To add statements to this newly created item, "LAST" is used. Which replaces the Q number in a QS statement and will simply add statements to the last created item. Note that, multiple "LAST" can follow a "CREATE" all adding statements to that newly create item.


The example below will create two new persons (instance of [[Property:P1|P1]] = Person [[Item:Q17|Q17]]). Both have a name P9, and name order (P10) and a title P12 as qualifiers:
The example below will create two new persons (Gender [[Property:P3|P3]] = Woman [[Item:Q3|Q3]]).
  CREATE
  CREATE
  LAST|P1|Q17
  LAST|P3|Q3
LAST|P9|"First Test person for QS"|P10|Q15|P12|"director"


  CREATE
  CREATE
  LAST P1 Q17
  LAST P3 Q3
LAST P9 "Second Test person for QS" P10 Q15 P12 "Baron"
 
=== Executing QuickStatements commands via the batch interface ===
=== Executing QuickStatements commands via the batch interface ===
After opening a new QS batch, statements can be typed as needed directly into the box (typically using "|"), or copy/pasted from a spreadsheet (typically using the TAB sign).
After opening a new QS batch, statements can be typed as needed directly into the box (typically using "|"), or copy/pasted from a spreadsheet (typically using the TAB sign).
Line 85: Line 81:
* Button to your user page
* Button to your user page


Also, you will not be able to store batches for working on them later.  
Also, you will *not* be able to store batches for working on them later.
 
== Moving data from statement to statement ==
It is possible to move data from one field to another using quick statement. For example copying all 'en-gb' labels to 'en' labels:
 
Steps to reproduce
* Write a Sparql query to get all en-gb labels and descriptions of all items and properties.
* Download these as a TSV
* Manipulated the TSV so they become QuickStatements commands. For example use some text-edit magic and Regular Expressions, or manipulate the TSV using a spreadsheet editor.
*
e.g.
https://beyond-notability.wikibase.cloud/entity/Q1022 Transactions of the Historic Society of Lancashire and Cheshire journal of the Historic Society of Lancashire and Cheshire
(notice this is <link><tab><label><tab><description>)
becomes
Q1022 Len "Transactions of the Historic Society of Lancashire and Cheshire"
Q1022 Den "journal of the Historic Society of Lancashire and Cheshire"
 
* Test the commands and verify that the right labels and descriptions get ingested.
* Run the entire set commands
 
== Creating a spreadsheet based ingest==
Creating a QuickStatements CSV
For example we want to import this information for new records:
* Label (in english)
* Gender
* Resided at
With the qualifiers to the resided at statement
* Street address free text
* Start time
We would create a spreadsheet with the following header (row):
* qid
* Len
* P3
* P29
* qal1
* P29
* qal31


== Open Refine ==
Where qid remains an empty column (indicating a new record needs to be created. A good help section on how to create these spreadsheets can be found on quickstatements/#/batch under the ‘import CSV’ button. Fill in the spreadsheet, export it as a CSV and use QuickStatement to add multiple statements at once.
Data edited in OpenRefine can also be exported to the QuickStatements format. (to be described).


== More information ==
== More information ==
https://www.wikidata.org/wiki/Help:QuickStatements
https://www.wikidata.org/wiki/Help:QuickStatements

Latest revision as of 13:31, 1 July 2024

QuickStatements (QS) is a tool that can edit Beyond Notability items, based on a simple set of text commands. The tool can add and remove statements, descriptions and aliases; as well as add statements with optional qualifiers and sources. The command sequence can be typed in the import window or created in a spreadsheet or text editor and pasted in.

A thorough explanation on how QuickStatements works can be found on this help page on Wikidata.

Basic working

  • Go to one of the link in the Wikibase menu on the left to access QuickStatement, or click here.
  • Click on 'Log in' to log in Quick Statements to your account. You can be prompted with an information box asking for authorisation:
  • After allowing QuickStatements to make edits on your behalf (by clicking 'Allow') you can use the tool.
  • Click on 'New batch' to create a set of new commands.
  • Add your statements or CSV data here and click on import.

Each QS statement must consist of an entity, a property, and a value, each of is separated by a TAB or "|" characters.

Example of QuickStatements via commands

QS commands to add statements to existing items

A new statement can be added to an existing item by:

  • fist referencing the Q number of the item in question (eg. Q465), Edith Blake
  • followed by the P number of the property (eg. instance of P12)
  • and finally the value to be added,
    • which can reference another item by its Q number (eg. human Q2137)
    • or a string value, delimited by "" (eg. "2021-02-21" or "Lucius, Michel").

These 3 elements need to be separated by a TAB or "|" characters e.g. adding that Edith Blake is a woman, and adding that her birth day is 1876-12-09 (fictitious date).

Q462|P12|QQ2137
Q462	P26	"1876-12-09"

QS commands to add qualifiers to statements

When adding statements using QS, corresponding qualifiers can be added by appending the statement by the P number of the qualifier, For example, adding a street address to a "resided at" statement.

Q462|P29|Q620|P31|"King's House, Jamaica (British English)"
 Q462	P29	Q620	P31	"King's House, Jamaica (British English)"

QS commands to add references to statements

References can be added in the same way as qualifiers to statements, this by adding the property (P) number, but replacing the P by an S (eg. "specific reference information (free text)"P88 becomes S88).

Q462|P29|Q620|S88|"Annual Report of the Board of Regents of the Smithsonian Institution (British English)"
Q462	P29	Q620	S88	"Annual Report of the Board of Regents of the Smithsonian Institution (British English)"

QS commands to remove statements

QS can also be used to remove statements from your Wikibase, by adding a "-" in front of your command. For example removing the gender of a person:

-Q462|P3|Q3

Or remove all Wikidata links:

-Q462|P117

Please note that the "-" command always removes the entire statement, so elements that you want to conserve need to be created again after a removal. This includes any qualifiers or references associated to the statement, thus they do not need to be explicitly mentioned in the removal command.

Notes:

  • If an identical statement already exists (exact match of property and value to the QS statement), the existing statement will not be changed and no new statement added.
  • However if the new statement includes new properties or references, these will be added to the matching existing statement.
  • Several qualifiers can follow the same statement in QS.
  • Within one batch only TAB or "|" characters should be used, mixing both does not work.
  • Within one batch multiple statements can be included, each however in a new line.

QS commands to create new items

It is also possible to create entirely new items using QS, this by using "CREATE", which used by itself, will create a new item without any statements. To add statements to this newly created item, "LAST" is used. Which replaces the Q number in a QS statement and will simply add statements to the last created item. Note that, multiple "LAST" can follow a "CREATE" all adding statements to that newly create item.

The example below will create two new persons (Gender P3 = Woman Q3).

CREATE
LAST|P3|Q3
CREATE
LAST	P3	Q3

Executing QuickStatements commands via the batch interface

After opening a new QS batch, statements can be typed as needed directly into the box (typically using "|"), or copy/pasted from a spreadsheet (typically using the TAB sign). Click on 'Import V1 commands' to pre-process the commands. You can check if you correctly wrote the QS and see what edits are about to be executed in the overview. Clicking on Run will execute the commands on Beyond Notability, if the Status Bar returns green all statements were correctly executed. If it turns red an error occurred, most likely statements were not correctly written. If excecated correctly a summary of the edits done is shown and one can quickly navigate to the concerned items to check the work done. Notability.

Functionality that is not working

QuickStatements was specifically developed for Wikidata, and not Wikiibase. Therefore, some buttons in the tool will not be working. Amongst them are:

  • 'Last batches'
  • 'Your last batches'
  • Button to your user page

Also, you will *not* be able to store batches for working on them later.

Moving data from statement to statement

It is possible to move data from one field to another using quick statement. For example copying all 'en-gb' labels to 'en' labels:

Steps to reproduce

  • Write a Sparql query to get all en-gb labels and descriptions of all items and properties.
  • Download these as a TSV
  • Manipulated the TSV so they become QuickStatements commands. For example use some text-edit magic and Regular Expressions, or manipulate the TSV using a spreadsheet editor.

e.g. https://beyond-notability.wikibase.cloud/entity/Q1022 Transactions of the Historic Society of Lancashire and Cheshire journal of the Historic Society of Lancashire and Cheshire (notice this is <link><tab><label><tab><description>) becomes Q1022 Len "Transactions of the Historic Society of Lancashire and Cheshire" Q1022 Den "journal of the Historic Society of Lancashire and Cheshire"

  • Test the commands and verify that the right labels and descriptions get ingested.
  • Run the entire set commands

Creating a spreadsheet based ingest

Creating a QuickStatements CSV For example we want to import this information for new records:

  • Label (in english)
  • Gender
  • Resided at

With the qualifiers to the resided at statement

  • Street address free text
  • Start time

We would create a spreadsheet with the following header (row):

  • qid
  • Len
  • P3
  • P29
  • qal1
  • P29
  • qal31

Where qid remains an empty column (indicating a new record needs to be created. A good help section on how to create these spreadsheets can be found on quickstatements/#/batch under the ‘import CSV’ button. Fill in the spreadsheet, export it as a CSV and use QuickStatement to add multiple statements at once.

More information

https://www.wikidata.org/wiki/Help:QuickStatements