GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Edit Task
  • Edit Related Tasks...
  • Create Subtask
  • Edit Parent Tasks
  • Edit Subtasks
  • Merge Duplicates In
  • Close As Duplicate
  • Edit Commits
  • Edit Mocks
  • Mute Notifications
  • Protect as security issue
  • Pywikibot-Wikidata
  • (Backlog)
  • Pywikibot

This view

  • Original page
  • New address

GeezerVison is showing phabricator.wikimedia.org — T200399 Make Pywikibot remove disambiguation bracket in labels to created new items for articles in Wikidata

Page MenuHomePhabricator
Log In
Create Task
Maniphest T200399

Make Pywikibot remove disambiguation bracket in labels to created new items for articles in Wikidata
Closed, ResolvedPublic
Actions

  • Edit Task
  • Edit Related Tasks...
  • Create Subtask
  • Edit Parent Tasks
  • Edit Subtasks
  • Merge Duplicates In
  • Close As Duplicate
  • Edit Related Objects...
  • Edit Commits
  • Edit Mocks
  • Mute Notifications
  • Protect as security issue
Assigned To
Shreyasminocha
Authored By
Bugreporter
Jul 26 2018, 5:33 AM2018-07-26 05:33:40 (UTC+0)
Project Tags
  • Pywikibot-Wikidata (Backlog)
  • Pywikibot (Needs Review)
  • Google-Code-in-2018 (Imported in GCI Site)
  • good first task
  • Patch-For-Review
Referenced Files
None
Subscribers
Aklapper
Bugreporter
Framawiki
gerritbot
JAnD
jayvdb
pywikibot-bugs-list
View All 10 Subscribers

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:
SubjectAuthorRepoBranchLines +/-
[IMPR] Strip disambiguation parens from articlesShreyasminochapywikibot/coremaster+19 -2
Customize query in gerrit

Event Timeline

Bugreporter created this task.Jul 26 2018, 5:33 AM2018-07-26 05:33:40 (UTC+0)
Restricted 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 Actions

Also for other scripts that can create items.

Dvorapa added a project: Pywikibot.Jul 29 2018, 8:42 AM2018-07-29 08:42:10 (UTC+0)
Xqt subscribed.Jul 29 2018, 9:38 AM2018-07-29 09:38:27 (UTC+0)
Comment Actions

Could you explain a bit please.

matej_suchanek subscribed.Edited · Jul 29 2018, 10:19 AM2018-07-29 10:19:51 (UTC+0)
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.

Xqt triaged this task as Medium priority.Jul 29 2018, 11:26 AM2018-07-29 11:26:24 (UTC+0)
deryckchan subscribed.Jul 30 2018, 10:07 AM2018-07-30 10:07:18 (UTC+0)
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.

Framawiki subscribed.Aug 4 2018, 7:21 PM2018-08-04 19:21:01 (UTC+0)
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 ?

deryckchan added a comment.Aug 5 2018, 11:41 AM2018-08-05 11:41:50 (UTC+0)
Comment Actions

Most wikis have retained the built-in MediaWiki feature where trailing
brackets are stripped when a page is saved:

Wikitext before saving: [[Foo (bar)|]]
Wikitext after saving: [[Foo (bar)|Foo]].

wikidatabot should strip the bracket when importing links from wikis which
have this feature turned on.

JAnD subscribed.Aug 6 2018, 9:07 PM2018-08-06 21:07:37 (UTC+0)
Comment Actions

On de.wiktionary there are many categories like
[[Category:Substantiv (Deutsch)]] or [[Category:Substantiv (Englisch)]]. These dismabiguations shoudl not be stripped

deryckchan unsubscribed.Aug 21 2018, 4:30 PM2018-08-21 16:30:34 (UTC+0)
JAnD added a comment.Aug 25 2018, 9:17 AM2018-08-25 09:17:38 (UTC+0)
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
In T200399#4482820, @JAnD wrote:

On de.wiktionary there are many categories like
[[Category:Substantiv (Deutsch)]] or [[Category:Substantiv (Englisch)]]. These dismabiguations shoudl not be stripped

I have already said "Only do it when handling articles (ns0)"

deryckchan unsubscribed.Aug 26 2018, 4:43 PM2018-08-26 16:43:46 (UTC+0)
Framawiki updated the task description. (Show Details)Sep 1 2018, 7:20 PM2018-09-01 19:20:12 (UTC+0)
Framawiki added projects: Google-Code-in-2018, good first task.
Comment Actions

Will mentor this task for Google-Code-in-2018 with whoever wishes.

jayvdb subscribed.Sep 2 2018, 3:04 AM2018-09-02 03:04:17 (UTC+0)
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.

Framawiki added a comment.Edited · Sep 2 2018, 7:36 PM2018-09-02 19:36:44 (UTC+0)
Comment Actions
In T200399#4551339, @jayvdb wrote:

Wont this cause errors due to duplicate label?

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 awarded a token.Sep 21 2018, 3:53 PM2018-09-21 15:53:04 (UTC+0)
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 updated the task description. (Show Details)
Aklapper moved this task from Proposed tasks to Imported in GCI Site on the Google-Code-in-2018 board.
Comment Actions

https://codein.withgoogle.com/tasks/5448776681521152/

xSavitar 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)
Liuxinyu970226 subscribed.Oct 21 2018, 2:13 AM2018-10-21 02:13:10 (UTC+0)
Shreyasminocha claimed this task.Oct 30 2018, 11:22 AM2018-10-30 11:22:52 (UTC+0)
Framawiki added a subscriber: xSavitar.Oct 30 2018, 6:03 PM2018-10-30 18:03:55 (UTC+0)
Comment Actions

@D3r1ck01 @Xqt and others:
Do you prefer a regex or an index approach here ? The second looks cleaner to me.
What about implementing this as a param like withoutDisambiguation in page.title() method? That would allow to easily reuse it elsewhere.
I also think that this param use can be directly added in [[ https://github.com/wikimedia/pywikibot/blob/master/pywikibot/bot.py#L2144 | create_item_for_page() ]], and in this case scripts/newitem.py would not be modified.

xSavitar added a comment.Oct 30 2018, 6:29 PM2018-10-30 18:29:01 (UTC+0)
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 :)

Xqt added a comment.Oct 31 2018, 3:33 AM2018-10-31 03:33:21 (UTC+0)
Comment Actions

@D3r1ck01 @Xqt and others:
Do you prefer a regex or an index approach here ? The second looks cleaner to me.

Sorry, I don’t have it. Could you show me the different approach?

What about implementing this as a param like withoutDisambiguation in page.title() method? That would allow to easily reuse it elsewhere.

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

I also think that this param use can be directly added in create_item_for_page() , and in this case scripts/newitem.py would not be modified.

Agree

Best
xqt

Shreyasminocha added a comment.Oct 31 2018, 4:18 AM2018-10-31 04:18:51 (UTC+0)
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).

Shreyasminocha added a comment.Edited · Oct 31 2018, 6:30 AM2018-10-31 06:30:27 (UTC+0)
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)?

Xqt added a comment.Oct 31 2018, 6:56 AM2018-10-31 06:56:46 (UTC+0)
Comment Actions

Since all of you recommend doing it the index way

Oh, I am fine with regex which might be less complex than index search implementation here.

gerritbot subscribed.Oct 31 2018, 3:33 PM2018-10-31 15:33:24 (UTC+0)
Comment Actions

Change 470627 had a related patch set uploaded (by Shreyasminocha; owner: Shreyasminocha):
[pywikibot/core@master] Strip disambiguation parens from articles

https://gerrit.wikimedia.org/r/470627

gerritbot added a project: Patch-For-Review.Oct 31 2018, 3:33 PM2018-10-31 15:33:27 (UTC+0)
Framawiki added a comment.Oct 31 2018, 6:54 PM2018-10-31 18:54:38 (UTC+0)
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.

Xqt closed this task as Resolved.Nov 5 2018, 7:26 AM2018-11-05 07:26:36 (UTC+0)
gerritbot added a comment.Nov 5 2018, 7:28 AM2018-11-05 07:28:38 (UTC+0)
Comment Actions

Change 470627 merged by jenkins-bot:
[pywikibot/core@master] [IMPR] Strip disambiguation parens from articles

https://gerrit.wikimedia.org/r/470627

Shreyasminocha added a comment.Nov 5 2018, 9:55 AM2018-11-05 09:55:07 (UTC+0)
Comment Actions

@Xqt Thank you so much for your patience with me.

Liuxinyu970226 unsubscribed.Nov 6 2018, 12:30 PM2018-11-06 12:30:43 (UTC+0)
matej_suchanek unsubscribed.Nov 24 2018, 1:21 PM2018-11-24 13:21:38 (UTC+0)
Log In to Comment
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.