GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||
GeezerVison is showing phabricator.wikimedia.org — T200399 Make Pywikibot remove disambiguation bracket in labels to created new items for articles in Wikidata
Assigned To Authored By
Project Tags Referenced Files None
Description Wikidata is a common database used by Wikimedia projects. Pywikibot has a script named scripts/newitem.py that creates items in this database for newly created pages. However page titles can have brackets in it. This task is to remove these brackets from the name of the newly created items, only if the page is in the principal namespace (that means ns: 0 as 0 is used for articles). Example: Georgia (country) → Georgia
Details Related Changes in Gerrit:
Event TimelineRestricted Application added subscribers: pywikibot-bugs-list, Aklapper. · View Herald TranscriptJul 26 2018, 5:33 AM2018-07-26 05:33:40 (UTC+0) Bugreporter renamed this task from newitem.py: Remove disambiguation bracket in labels to Remove disambiguation bracket in labels when creating new items for articles.Jul 26 2018, 5:41 AM2018-07-26 05:41:59 (UTC+0) Comment ActionsAlso for other scripts that can create items. Comment Actions Could you explain a bit please. Comment Actions When a page like "Georgia (country)" gets imported to Wikidata, the new item has label "Georgia (country)", instead of "Georgia". It should be changed to strip the disambiguator if appropriate. Comment Actions The issue seems to be in pywikibot class wikidatabot.create_item_for_page , which takes a page (from a pagegenerator) and auto-creates an item for it. Comment Actions Can we assume that all brackets at the end of the string can be safely removed ? All wikipedias are using this only for disambiguation ? Comment Actions Most wikis have retained the built-in MediaWiki feature where trailing Wikitext before saving: [[Foo (bar)|]] wikidatabot should strip the bracket when importing links from wikis which Comment Actions On de.wiktionary there are many categories like Comment Actions alternativelly script should add whole name (with bracket) as alias Bugreporter added a subscriber: deryckchan.Edited · Aug 26 2018, 10:18 AM2018-08-26 10:18:27 (UTC+0) Comment Actions
I have already said "Only do it when handling articles (ns0)" Framawiki updated the task description. (Show Details)Sep 1 2018, 7:20 PM2018-09-01 19:20:12 (UTC+0) Comment ActionsWill mentor this task for Google-Code-in-2018 with whoever wishes. Comment Actions Wont this cause errors due to duplicate label? Still it is a good idea, but new item needs to be able to resolve those errors. Comment Actions
Wikidata pages are indexed by a unique qID. So multiple pages with the same label (like a title) will not be problematic at all, they will just be homonyms. Actually the job is done by specialized bots, that have to remove the content in bracket after the item creation by newitem.py. revi subscribed. Aklapper renamed this task from Remove disambiguation bracket in labels when creating new items for articles to Make Pywikibot remove disambiguation bracket in labels to created new items for articles in Wikidata.Oct 7 2018, 1:56 AM2018-10-07 01:56:34 (UTC+0) Aklapper moved this task from Proposed tasks to Imported in GCI Site on the Google-Code-in-2018 board. Comment ActionsxSavitar moved this task from Backlog to Needs Review on the Pywikibot board.Oct 14 2018, 3:39 PM2018-10-14 15:39:00 (UTC+0) Comment Actions @D3r1ck01 @Xqt and others: Comment Actions @Framawiki, if it's per this, https://gerrit.wikimedia.org/r/c/pywikibot/core/+/470627, then I'll say regex solutions become really confusing if they're trying to solve a complex problem hence making it difficult for one to understand a code base if we have many of them. Regex are good for solving parsing problems and somewhat fast as well but indexing seems generally easier to understand no matter how complex the problem is compared to regex and fast too. But in this case that we're just checking for brackets (pretty straight forward), it's a pretty simpler problem and I think any solution here (regex or indexing) can work well and will not cause so much trouble. But honestly, for future proofing of code and scalability, I'll go for the index approach but let's hear what others have to say :) Comment Actions
Sorry, I don’t have it. Could you show me the different approach?
Sounds good but there is a general problem with it which isn’t taken into account: There may be real titles which has these bracket tail included. Therefore sth. without_brackets would be more neutral but doesn’t solve that underlying problem
Agree Best Comment Actions @Xyt To clarify, I haven't implemented the second approach. We have two options—the regex-based approach I illustrated or an index-based approach (looping over the characters in the string, looking for an open parenthesis and trimming everything after that or a more advanced version of the same to handle edge cases such as nested parens, unmatched parens, multiple parens). Comment Actions @Framawiki @D3r1ck01 Since all of you recommend doing it the index way, I'll do that instead. Would it suffice if I handle only: 1. Georgia (Country) 2. Georgia (Something) (Country) // here it would remove both with the index approach? The following will break stuff: 3. Georgia ((Country)) 4. Georgia (Country 5. Georgia Country) Are any of the last few probable (and thus worth implementing)? Should I just look for the last open paren and remove everything after it (in 2. for example)? Comment Actions
Oh, I am fine with regex which might be less complex than index search implementation here. Comment Actions Change 470627 had a related patch set uploaded (by Shreyasminocha; owner: Shreyasminocha): Comment Actions Ok, although preferring the index option I chose the regex version for its simplicity. We can always create a task for change later on to have a cleaner code, even if it already seems very good to me. Patch is ready for review. Comment Actions Change 470627 merged by jenkins-bot: Comment Actions @Xqt Thank you so much for your patience with me. Content licensed under Creative Commons Attribution-ShareAlike (CC BY-SA) 4.0 unless otherwise noted; code licensed under GNU General Public License (GPL) 2.0 or later and other open source licenses. By using this site, you agree to the Terms of Use, Privacy Policy, and Code of Conduct. · Wikimedia Foundation · Privacy Policy · Code of Conduct · Terms of Use · Disclaimer · CC-BY-SA · GPL · Credits | |||||||||||||||
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |