Shortcut: Help:QS

Ayuda:QuickStatements

From Wikidata
Jump to navigation Jump to search
This page is a translated version of the page Help:QuickStatements and the translation is 19% complete.

Outdated translations are marked like this.
Other languages:
Bahasa Indonesia • ‎Deutsch • ‎English • ‎dansk • ‎español • ‎français • ‎italiano • ‎magyar • ‎polski • ‎svenska • ‎русский • ‎українська • ‎العربية • ‎മലയാളം • ‎日本語

Icono utilizado en Commons para las plantillas que añaden datos a Wikidata usando QuickStatements

QuickStatements es una herramienta, desarrollada por Magnus Manske, que puede editar elementos de Wikidata, basándose en conjuntos simples de comandos de texto. La herramienta puede añadir y eliminar declaraciones, etiquetas, descripciones y alias; así como añadir declaraciones con calificadores opcionales y fuentes. La secuencia de comando puede ser escrita en la ventana de importación o creada en una hoja de cálculo o un editor de texto, y pegada en la ventana. También puede ser creada por un código externo, como Lua en una plantilla y pasado como URL.

Las herramientas

Sintaxis de la secuencia de comandos

Añadir una declaración sencilla

Puedes especificar las declaraciones que quieres añadir escribiendo o pegado una fila por declaración en el área de texto de la herramienta. Las diferentes partes de la declaración son separadas por un carácter TAB o, en la versión 2 de QuickStatements, también se puede separar con «|». Cada comando debe estar en una nueva línea o, en la versión 2, también puede estar separado por «||». Pista: también puede utilizar un programa de hojas de cálculo como Excel o LibreOffice Calc; al copiar y pegar las celdas deberían insertar automáticamente los caracteres TABs. También los editores de texto como Notepad++ permiten reemplazar cualquier símbolo por un carácter TAB.

Cada declaración debe constar de un elemento, una propiedad, y un valor. Un valor puede ser otro elemento, una cadena, un tiempo, una ubicación, o una cantidad, dependiendo del tipo de propiedad.

Formato de cada parte:

  • Elementos están siempre en la forma Qxx. En la versión 1 de la herramienta, si uno rellenó un valor xxwiki en la cuadro de entrada por encima del área de texto, también se podría usar el nombre de un artículo en lugar del código q; el número correcto del elemento se recuperará automáticamente si está disponible.
    Ejemplo: Q4115189 TAB P31 TAB Q1
    Significado: añadir a Wikidata Sandbox (Q4115189)instance of (P31)  Universe (Q1)
  • Las propiedades en la forma Pxx.
  • Las cadenas (incluyendo URLs y valores números de campos de texto, valores de propiedades de identificadores externos) deben estar entre "comillas dobles". Muchas declaraciones toman un valor en formato de cadena, incluyendo identificadores externos (como VIAF ID (P214)), nombres de archivos (como image (P18)) o nombres de otras páginas (como Commons category (P373)).
    Ejemplo: Q41576278 TAB P373 TAB "Antoni Ignacy Mietelski"
    Significado: añadir a Antoni Ignacy Mietelski (Q41576278)Commons category (P373)  Antoni Ignacy Mietelski
    Cuidado: algunos carácteres en la cadena pueden ser confusos para el analizador sintáctico. Estos incluyen: "_" (barra baja), " (comillas dobles), "=", y posiblemente más. Añadir URLs con estos carácteres, como this one or esta fallará.
  • El texto monolingüe debe ir con el prefijo del idioma, dos puntos y el texto entre comillas dobles, p. ej., es:"Algún texto"
    Ejemplo: Q1214098 TAB P1476 TAB pl:"Krzyżacy"
    Significado: añadir a The Knights of the Cross (Q1214098)title (P1476)  "Krzyżacy" (polaco)
  • Los valores de tiempo deben estar en el formato +1967-01-17T00:00:00Z/11, donde /11 designa la presición. La precisión es: 0 - billón de años, 1 - cientos de millones de años, ..., 6 - milenio, 7 - siglo, 8 - década, 9 - año (por defecto), 10 - mes, 11 - día, 12 - hora, 13 - minuto, y 14 - segundo.
    Ejemplo: Q41576483 TAB P569 TAB +1839-00-00T00:00:00Z/9.
    Significado: añade a Bronisław Podbielski (Q41576483)date of birth (P569)  +1839
    Utiliza "-" para fechas a. C.; y utiliza al menos 4 dígitos.
  • Las ubicaciones en coordinadas se escriben en el formato @LAT/LON, con LAT y LON números decimales.
    Ejemplo: Q3669835 TAB P625 TAB @043.26193/010.92708
    Significado: añadir ubicación a San Dalmazio (Q3669835)
  • La cantidad se escribe cantdidad[inferior,superior]Uxx, con número racionales para la cantidad, el inferior y el superior. Uxx corresponde con número del elemento de una unidad (Qxx).
    La unidad es opcional. En julio de 2017 parece que hubo algunos problemas con las unidades, véase aquí.
    inferior y superior son opcionales. inferior y superior deben estar ambos presentes o no presentes. Cuando están presentes, debería estar encerrados entre corchetes y separados por ,
    cantidad, inferior y superior deben usar el . como separador decimal, no deben usar ningún separador de miles y puede estar prefijado con + o -.
    No dejes ningún especio en la cantidad.
    10, 10U11573, -10[-12.5,-7.5], 0[-5,5]U11573 son cantidades válidades (donde U11573 se refiere a metre (Q11573))
    Las cantidades con tolerancia pueden ser introducidas como 1.2~0.3 (en la version 2 de la herramienta), que es lo mismo que 1.2[0.9,1.5] y significa 1.2±0.3.

Addtionally, you can use "somevalue" and "novalue" (without quotes) for concept of unknown value in Wikibase (Q19798648) and concept of no-value in Wikibase (Q19798647), respectively. (See Help:Statements#Unknown or no values.)

Añadir declaraciones con calificadores

Cada "tripleta" de declaración puede estar seguida de un número ilimitado de "pares de calificadores" de propiedad TAB valor.

Ejemplo: Q41577083 TAB P570 TAB +1586-00-00T00:00:00Z/7 TAB P1319 TAB +1586-00-00T00:00:00Z/9
Significa: añadir a Gian Federigo Bonzagna (Q41577083)date of death (P570)  16. siglo / earliest date (P1319)+1586

Añadir declaraciones con fuentes

Cada declaración puede estar seguida de un número ilimitado de "pares de fuentes" de propiedades de fuentes TAB valor. La propiedad de fuente es idéntica a la propiedad "normal", excepto porque utiliza la forma Sxx en lugar de Pxx.

Ejemplo: Q41577600 TAB P21 TAB Q6581097 TAB S143 TAB Q24731821 TAB S813 TAB +2017-10-04T00:00:00Z/11
Significado: añadir a no label (Q41577600)sex or gender (P21)  male (Q6581097) con la referencia imported from Wikimedia project (P143)  Commons Creator page (Q24731821) / retrieved (P813).

Notas

  • Las declaraciones existentes con una coincidencia exacta (propiedad y valor) no se añadirán de nuevo; sin embargo, las referencias adiciones pueden ser añadidas a la declaración.
  • En el pasado, cada declaración de fuente representaba una referencia individual, p. ej., no estaban agrupadas con una referencia; esto funciona correctamente con la versión 2.

Añadir etiquetas, alias, descripciones y enlaces de sitio

As with adding simple text statements, each command must consist of an item, a command, and a string in double quotes.

  • To add a label in a specific language to an item, use "Lxx" instead of the property, with "xx" as the language code.
    Example: Q340122 TAB Lpl TAB "Cyprian Kamil Norwid"
    Meaning: add Polish label "Cyprian Kamil Norwid" to Cyprian Norwid (Q340122)
  • To add an alias in a specific language to an item, use "Axx" instead of the property, with "xx" as the language code.
    Example: Q340122 TAB Aen TAB "Cyprjan Kamil Norwid"
    Meaning: add English alias "Cyprjan Kamil Norwid" to Cyprian Norwid (Q340122)
  • To add a description in a specific language to an item, use "Dxx" instead of the property, with "xx" as the language code.
    Example: Q340122 TAB Dde TAB "polnischer Dichter"
    Meaning: add German description "polnischer Dichter" to Cyprian Norwid (Q340122)
  • To add a sitelink to a specific page on a site to an item, use "Sxxx" instead of the property, with "xxx" as the site (e.g. enwiki, commonswiki).
    Example: Q340122 TAB Szhwiki TAB "塞浦路斯·諾爾維特"
    Meaning: add sitelink to Chinese Wikipedia (塞浦路斯·諾爾維特) to Cyprian Norwid (Q340122)

Item creation

You can create new items by inserting a line consisting only of the word "CREATE". To add statements to the newly created item, use the word "LAST" instead of the Q number, and the statement will be added to the last created item.

An example for creating a new item, adding a sitelink, and setting a label:

CREATE
LAST TAB Sfrwiki TAB "Le croissant magnifique!"
LAST TAB Lfr TAB "Le croissant magnifique!"
Meaning: create a new item with a link to French Wikipedia w:fr:Le croissant magnifique! and with French label "Le croissant magnifique!"

Item merging

You can merge two items. The first item will be merged and (if successful) redirected into the second item.

MERGE TAB Qsource TAB Qdestination

Removing statements

You can remove specific statements by prefixing a line with "-". (To remove labels or descriptions, set them to the empty string.)

Example: -Q4115189 TAB P31 TAB Q1
Meaning: remove from Wikidata Sandbox (Q4115189)instance of (P31)  Universe (Q1)

Comments

Every command can have a comment at its end, which will be inserted into the edit summary for the command. Use the /* ... */ syntax. Before this a TAB may be inserted. Spaces around the comment will be removed from the command before processing. The tool splits adding of a claim and its reference in two edits. When using the "version 1 format" import it seems not to be possible to add a comment for the edit adding the reference. The comment is added to the edit adding the claim (if the claim does not exist yet and is added at all).

Example: Q4115189 TAB P31 TAB Q1 /* This is a comment. There are many others like it, but this one is mine. */
Meaning: add to Wikidata Sandbox (Q4115189)instance of (P31)  Universe (Q1), with "This is a comment. There are many others like it, but this one is mine." in the edit summary.

CSV file syntax

Singapore Information-signs Warning-signs-02.jpg This page or section is in the process of an expansion or major restructuring. You are welcome to assist in its construction by editing it as well.

In version 2, one can also cut and paste a properly structured CSV file as an alternative to the syntax introduced in QuickStatements version 1. The CSV file will specify commands to execute. The first row is a header describing how the columns are interpreted.

The other columns may specify the following commands:

P1234
A property ID (uppercase) begins a new statement. The column value specifies the main value of the statement, in QuickStatements version 1 syntax.
qal1234
A lowercase "qal" followed by a property number (without "P") adds a qualifier to the current statement. The column value specifies the value of the qualifier, in QuickStatements version 1 syntax. There must be some "P" column before a "qal" column to specify which statement the qualifier is added to.
S1234
An uppercase "S" followed by a property number (without "P") begins a new source for the current statement. The column value specifies the value of the source, in QuickStatements version 1 syntax. There must be some "P" column before an "S" column to specify which statement the source is added to.
s1234
A lowercase "s" followed by a property number (without "P") adds another property-value pair to the current source. The column value specifies the value of the source, in QuickStatements version 1 syntax. There must be some "S" column before an "s" column to specify which source the property-value pair is added to.
Len
An uppercase "L" followed by a language code sets the label in that language.
Dfr
An uppercase "D" followed by a language code sets the description in that language.
Ade
An uppercase "A" followed by a language code adds an alias in that language.
Senwiki
An uppercase "S" followed by a site ID adds a sitelink to that site.
#
A number sign character sets the edit summary (comment) of the preceding command. The tool splits adding of a claim and its reference in two edits. A comment can be added to the edit summary of each of them. For the claim by putting a "#" column between the columns for the claim and its reference, for the reference by putting a "#" column behind its columns. For example:
qid,P21,#,S143,s813,#
Q22124656,Q6581097,comment to claim adding edit,Q24731821,+2017-10-04T00:00:00Z/11,comment to reference adding edit

Statement column headers may also begin with - to remove the statement. (Note that this is only valid in the header for the whole column, not in individual values.) Removing other column types is not yet supported and will result in an error when the command is run; however, sitelinks and labels can be removed by setting them to the empty string (without - in the column header).

For example
qid,Len,Den,Aen,P31,-P31,P21,P735,qal1545,S248,s214,S143,Senwiki
Q42,Douglas Adams,author,Douglas Noël Adams,Q5,Q36180,Q6581097,Q463035,1,Q54919,113230702,Q328,Douglas Adams

To create a new item, the first element of the row needs to be empty, so the line starts with a ,.

For example
qid,Len,Den,P31
,Regina Phalange,fictional character,Q5

The double quotes for string values seem to interfere with CSV syntax. Empirically four double quotes before and one after the string have been found to work.

For example
qid,P473
Q304652,""""62"
Q582223,""""34"

Running QuickStatements

Using QuickStatements version 2

Here is how to use QuickStatements (version 2) in basic mode:

  1. Go to https://tools.wmflabs.org/quickstatements/
  2. Make sure you are logged in OAuth and your name is visible in the upper right corner. If not then log in.
  3. Click "New batch".
  4. Cut and paste your commands. See the syntax in the section above.
  5. When you are done, click "Import V1 commands" or "Import CSV commands".
  6. The tool will convert your commands into human-readable form. Inspect them and click "Run" to execute.
  7. As your statements are being processed, double-check the results, and press "Stop" if you detect a problem.
  8. The user interface will tell you when all statements have been processed.

Using QuickStatements version 1

Screenshot of using QuickStatements version 1

QuickStatements version 1 is still available, but no longer maintained. It stopped working for some users, while still working fine for others. NIOSH's fork of the tool is also available.

  1. Go to https://tools.wmflabs.org/wikidata-todo/quick_statements.php
  2. Cut and paste your commands into the window
  3. Click "Do it!"
  4. The user interface will tell you when all statements have been processed.

Using QuickStatements version 2 in batch mode

When to use batch mode?

QuickStatements version 2 has "Run in the background" button

Batch mode (also known as running in the background) means your statements are executed from a Wikimedia server, rather than from your Web browser. This has several advantages:

  • Even if you close your browser or if your computer crashes, the statements will be executed until the last one.
  • You can launch several batches in parallel, without slowing down your computer.
  • You get a unique URL for your batch, to which you can refer later. This page shows some statistics about your run.
  • Anyone can stop your batch by going to this URL. For instance, if someone realizes that your batch is erroneous and you are sleeping, they can stop it immediately (by going to the individual batch page), rather than having to block you.

But there are also drawbacks:

  • You can only see the total number of errors, not the statements that produced an error. Actually, you can not see any statement.
  • It takes a few more clicks, so as a rule of thumb if you only have 10 or fewer statements, then better run them in normal mode.
  • Edits are made as User:QuickStatementsBot, which means you will not find them in your contributions.
  • Checking the edits while waiting is not easy, as you don't get a list of the items that have been processed so far.

Before running a batch, it can be a good idea to run a few statements directly in non-batch mode to get a good view of what is being done.

Using batch mode

  1. Prepare your statement normally as described in Using QuickStatements version 2 section above
  2. Instead of pressing "Run", press "Run in background" button.
  3. "Your last batches" will show a list of the most recent batches run by you, with statistics.

The following statistics values are available:

  • DONE: The number of statements that were successful run
  • ERROR: The number of statements that failed
  • INIT: The number of statements left to run?
  • RUN: The number of statements being run right now?

Running QuickStatements through URL

An alternative way of communicating with QuickStatements is to use URL instead of cutting and pasting commands into import window. For example, if we import Q37887397 TAB P214 TAB "96480189" TAB S143 TAB Q565 statement using cut-and-past method (image #1 below), it will show the parsed statement and in URL field QS will show https: //tools.wmflabs.org/quickstatements/#v1=Q37887397%09P214%09"96480189"%09S143%09Q565 or https://tools.wmflabs.org/quickstatements/#v1=Q37887397%09P214%09%2296480189%22%09S143%09Q565 (image #2 below)(Statement is to add to Emile Justin Merlot (Q37887397)VIAF ID (P214)  "96480189" with source imported from Wikimedia project (P143)  Wikimedia Commons (Q565)). Creating the URL through some other means can skip the initial step. Many templates on Commons, like c:template:Creator or c:template:Authority control use that technique to package information that can be imported to Wikidata into a clickable URL.

Hints:

  • URL cannot have any spaces. Replace TAB with "%09", double quote with "%22", space with "%20", and end-of-line with "%0A".
  • Statements with URL inputs that have "_" or " " can be added through regular interface but not through URL. For example this URL was produced by the tool and it works; however if you click or cut-and-paste it you will end up on a page with slightly different URL, which does not work.
  • [[File:Commons to Wikidata QuickStatements.svg|20px|link=https://tools.wmflabs.org/quickstatements/#v1=Q37887397%09P214%09%2296480189%22%09S143%09Q565]] will encode the URL within a handy clickable icon: Commons to Wikidata QuickStatements.svg (click it but do not click "run"; pressing it will not work since that item already has that property).
  • Pages with QuickStatements URLs may be located through Special:LinkSearch (see here) or through a database query calling externallinks table (see for example here).

Limitations

QuickStatements version 2 currently cannot:

  • set ranks for statements
  • specify calendar for a date statement
  • specify precision or globe for a location statement
  • add URLs with some characters like "_" or "="
  • add statements to redirected items

FAQ

Can QuickStatements add reference statements with more than one claim?
Yes, current QuickStatements can add references that have for example both imported from Wikimedia project (P143) and retrieved (P813) (see here) or both stated in (P248) and page(s) (P304).
How do I experiment with QuickStatements?
Use Wikidata Sandbox (Q4115189).
How do I report issues with the tool.
Check with other users at the talk page or at Wikidata:Project chat. Confirmed bugs should be reported at tool's Bitbucket page.
Where do I suggest new features?
You can ask at tool's Bitbucket page or at User:Magnus Manske/quick statements2, but be aware that we keep Magnus busy!
What is the maximum number of commands I can enter at once?
Not documented. It was already tested with over 11,000 commands. But note that such large batch runs will take several hours to complete.

Best practices

  • QuickStatements allows edits ranging from single statement to multi-thousand-item batch runs. Very large runs or potentially-controversial runs should go through approval process described in Wikidata:Bots.
  • Users should avoid creating duplicate items.
  • All statements should have references as per Help:Sources. That might be less important for identifiers, like VIAF ID (P214) or RKDartists ID (P650), etc.
  • Users doing the edits are responsible for fixing or undoing their changes if issues are found. See about statement removal.

See also