Wikipedia:Bots/Requests for approval/PotatoBot 4
- The following discussion is an archived debate. Please do not modify it. To request review of this BRFA, please start a new section at WT:BRFA. The result of the discussion was
Approved.
Operator: Anypodetos (talk · contribs)
Automatic or Manually assisted: Automatic, unsupervised
Programming language(s): Python, PyWikipedia
Source code available: Yes
Function overview: Stub sorting of Category:Pharmacology stubs and its subcategories.
Links to relevant discussions (where appropriate): About the creation of subtypes of {{pharma-stub}}: Wikipedia talk:WikiProject Stub sorting#Can I create stub templates that were approved way back?
Edit period(s): One-time run; additional runs if necessary
Estimated number of pages affected: Less than 3000
Exclusion compliant (Y/N): Yes
Already has a bot flag (Y/N): Yes
Function details: Iterates through Category:Pharmacology stubs and its subcategories: Tries to find the appropriate stub type, which is determined by the drug's ATC code – at first looks in the {{Drugbox}} or {{Chembox}}, if unsuccessful, tries to find an ATC-specific navbox. If nothing is found, or if ATC codes from several groups are found, the stub is sorted to {{pharma-stub}}.
The bot also moves the stub template down (just above the language links) if necessary.
Discussion
[edit]The function mysave.findATCs seems to be missing from the linked code. Also, it seems that if an ATC code not in stubtypes
is found, it will move the article to Category:Pharmacology stubs even if it is already categorized into a subcat; is that intentional? Same if an article happens to have multiple ATC codes with different letters, it will put it in Category:Pharmacology stubs rather than putting it in both subtype categories. Anomie⚔ 17:28, 25 July 2010 (UTC)[reply]
- Sorry, updated mysave now.
- The upwards sorting was intentional, but thinking again, it's safer to trust the manual categorisations and change stub types only from parent to child category. Will update the code today or tomorrow.
- I thought that more than one stub template is undesirable, but WP:Stub states "If an article overlaps several stub categories, more than one template may be used, but it is strongly recommended that only those relating to the subject's main notability be used. A limit of three or, if really necessary, four stub templates is advised." The bot cannot know which ATC code is the more important. I could change the code to add several templates, with a cut-off at three and not updating the page if more codes are found (unlikely for a stub anyway). What do you think of that logic? Or are there other ideas?
--ἀνυπόδητος (talk) 18:29, 25 July 2010 (UTC)[reply]
- Re #3, you could just WP:IAR if it actually comes up, or you could use multiple stubs if there are 4 or less and put it in Category:Pharmacology stubs if there are more. And/or you could have the bot flag it for human review in some manner. Anomie⚔ 19:32, 25 July 2010 (UTC)[reply]
- The bot now compiles a list of existing stub templates on the page, plus types extracted from ATC codes and templates, plus types extracted from categories (new, although it will need some work to compile a list of useful categories). It then removes the top-level {{pharma-stub}} unless it is the only one, and then lower-level types if higher-level ones are present (e. g. {{antihypertensive-stub}} if there is also {{cardiovascular-drug-stub}}). If there are more than three types left, the page is not modified but logged as you suggested. --ἀνυπόδητος (talk) 15:21, 26 July 2010 (UTC)[reply]
- Looks good. I'm not terribly familiar with python, but I guess the problem is that if you have wikitext like "
blah blah.{{a}}{{b}}{{c}}
" and you try to remove {{a}} then the saved offsets are all wrong for trying to remove {{b}} next? Would it allow you to support multiple stubtempls if you removed them as you find them (at around line 102) instead of saving them all up until the end? Or if you don't want to mess with it, that's fine too. Anomie⚔ 02:22, 27 July 2010 (UTC)[reply]
- Looks good. I'm not terribly familiar with python, but I guess the problem is that if you have wikitext like "
- The bot now compiles a list of existing stub templates on the page, plus types extracted from ATC codes and templates, plus types extracted from categories (new, although it will need some work to compile a list of useful categories). It then removes the top-level {{pharma-stub}} unless it is the only one, and then lower-level types if higher-level ones are present (e. g. {{antihypertensive-stub}} if there is also {{cardiovascular-drug-stub}}). If there are more than three types left, the page is not modified but logged as you suggested. --ἀνυπόδητος (talk) 15:21, 26 July 2010 (UTC)[reply]
- Re #3, you could just WP:IAR if it actually comes up, or you could use multiple stubs if there are 4 or less and put it in Category:Pharmacology stubs if there are more. And/or you could have the bot flag it for human review in some manner. Anomie⚔ 19:32, 25 July 2010 (UTC)[reply]
Approved for trial (30 edits). Please provide a link to the relevant contributions and/or diffs when the trial is complete. Let's give it a trial. Anomie⚔ 02:22, 27 July 2010 (UTC)[reply]
Trial complete. Special:Contributions/PotatoBot.
- Admittedly, I was too lazy to add support for several stubs. I did it now, following your suggestion (of which I could have thought myself...), and also added support for arbitrary stub templates (they are placed below the pharma stubs, and the page is logged).
- Notes on the trial:
- Acidifier was categorised as genito-urinary although it would also qualify as gastrointestinal. I think such cases are impossible to detect automatically, but are not really a problem since there is at least one valid pharmacology stub template present.
- Acetrizoic acid and Aceclidine: That's a bug I'll have to fix. Seems to happen with ATC codes S (sensory organs) and V (various) for which there are no stub categories.
- Bug should be fixed. Just re-ran the bot with saving disabled. This time, these two pages returned "No useful ATC code, navbox or category found", indicating that nothing would have been saved. --ἀνυπόδητος (talk) 18:37, 27 July 2010 (UTC)[reply]
- In ABT-418, the space between the navboxes and the stub template is too large. That's because the last item before the stub is a {{DEFAULTSORT}}, which in turn is separated from the category links by two newlines. That's a tricky one. Is it a problem just to leave it at that? --ἀνυπόδητος (talk) 18:17, 27 July 2010 (UTC)[reply]
- I haven't tried it, but would the python equivalent of
s/\n\n+{{DEFAULTSORT[:|]([^}]*)}}$/\n{{DEFAULTSORT:$1}}/
fix that? Otherwise, looks good. Anomie⚔ 01:46, 28 July 2010 (UTC)[reply]- The DEFAULTSORT in itself isn't a problem. What I meant is that there could be any kind of invisible things at the bottom of a page that would have the same effect. Category links is one example, another would be {{link GA}} if I hadn't already caught this for other reasons. I'll include fixes for catlinks and DEFAULTSORT, and hope that there won't be too many other cases turning up. Permission to run when I have done that? Or do you want another trial? --ἀνυπόδητος (talk) 08:13, 28 July 2010 (UTC)[reply]
- A category link that is the first thing on a line seems to eat any preceeding blank lines, so they should be ok. AFAIK, defaultsort should really be before the category links, but rearranging everything may not be worth the trouble. Anomie⚔ 15:00, 28 July 2010 (UTC)[reply]
- The DEFAULTSORT in itself isn't a problem. What I meant is that there could be any kind of invisible things at the bottom of a page that would have the same effect. Category links is one example, another would be {{link GA}} if I hadn't already caught this for other reasons. I'll include fixes for catlinks and DEFAULTSORT, and hope that there won't be too many other cases turning up. Permission to run when I have done that? Or do you want another trial? --ἀνυπόδητος (talk) 08:13, 28 July 2010 (UTC)[reply]
- I haven't tried it, but would the python equivalent of
Approved. Looks good. Anomie⚔ 15:00, 28 July 2010 (UTC)[reply]
- The above discussion is preserved as an archive of the debate. Please do not modify it. To request review of this BRFA, please start a new section at WT:BRFA.