Wikidata Bot

Python

This user account is a bot with a bot flag. The bot is operated by Aluxosm.
  • Block this bot if it is malfunctioning.
  • Check its work.
  • Contact the operator about mistakes.
  • See all Requests for Permissions related to this bot: 1
  • Source: on Github

Notes edit

The code used to run tests in the sandbox (like this) can be found on Github.

Daniel Mietchen has been working on a similar thing using manual queries and QuickStatements — See: github.com/WDscholia/scholia/issues/2152

Description edit

This bot infers number of pages (P1104) (type: page (Q1069725)) from page(s) (P304) statements on items where instance of (P31) is equal to scholarly article (Q13442814), it them adds a reference with based on heuristic (P887) equal to inferred from page(s) (Q110768064).

For example, a scholarly article that only has:

page(s)
  2-5
0 references
add reference


add value


Would have the following statement added:

number of pages
  4 page
1 reference


add value


Regular expression used edit

^([a-zA-Z]*)(\d+)\s*(-|‐|‑|‒|–|—|―|−)\s*([a-zA-Z]*)(\d+)$

This results in five groups:

  1. The first prepended character
  2. The first page
  3. The 'to' symbol (hyphen-minus, hyphen, non-breaking hyphen, figure dash, en dash, em dash, horizontal bar, or a minus sign)
  4. The last prepended character
  5. The last page

View on RegExr

Calculation used edit

last_page - first_page + 1