Page MenuHomePhabricator

Add script misspelling support to pwb.py
Closed, ResolvedPublicFeature

Description

When one letter in git command is misspelled (and you turned this awesome feature on), it will try to find a correct git command and suggests it, and run it if you agree.

Similar to T175451 it would be cool to have something git command has. And it is easy to achieve: https://stackoverflow.com/a/25216604

Just a similar issue like in T175451 occurs here, the set of all possible files must be collected before

Event Timeline

Dvorapa triaged this task as Lowest priority.Feb 26 2019, 8:27 PM

@Dvorapa Hi, this is Nikhil, I'm interested in taking up this task. But I'm a newcomer and haven't contributed to any Wikimedia project yet. Can you please guide me, about what steps do I have to follow to configure Pywikibot on my local system so that I can start contributing.

Hello, first you should visit the https://www.mediawiki.org/wiki/Manual:Pywikibot/Development basics page. Once ready, Look into the https://www.mediawiki.org/wiki/Manual:Pywikibot/Gerrit Gerrit manual. The detailed descriptions of the steps are also available in https://www.mediawiki.org/wiki/Gerrit/Tutorial

Just to be clear,
Pywikibot comes packaged with a large number of scripts in the scripts directory, which can be executed using

python pwb.py [script.py]

Currently, if the [script.py] is misspelled it displays

ERROR: [script.py] not found! Misspelling?

Instead of that, we have to implement the functionality of git command which will suggest correct [script.py] names.

Yes. Not only from the scripts directory, but also from the current command line directory, userscripts directory and directories set in user-config.py (I hope I haven't forgotten any).

Change 495457 had a related patch set uploaded (by Nikhil; owner: Nikhil):
[pywikibot/core@master] pwb.py: Add ability to display similar scripts when misspelled

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

Change 495465 had a related patch set uploaded (by Nikhil; owner: Nikhil):
[pywikibot/core@master] Corrected the styling issues.

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

Change 495465 abandoned by Xqt:
Corrected the styling issues.

Reason:
Take the other patch

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

Change 495457 merged by jenkins-bot:
[pywikibot/core@master] pwb.py: Add ability to display similar scripts when misspelled

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

Hmm. It suggests not really close mathches. I would expect something like this:

$ python pwb.py states_redirects
The most similar script is:
	states_redirect.py

or

$ python pwb.py states_redirects
The most similar script is:
	states_redirect.py
	surnames_redirects.py

But I got this:

$ python pwb.py states_redirects
The most similar script is:
	states_redirect.py
	surnames_redirects.py
	category_redirect.py
	capitalize_redirects.py
	redirect.py

The last one is completely wrong, the two before are not helpful.

Anyway better than before for sure, good job @Nikhil07prakash!

Hm, I am also wondering about the last entry because we have following indicator of the "Gestalt Pattern Matching":

script indicator function
states_redirect0.97
surnames_redirects0.82
category_redirect0.73
capitalize_redirects0.72
redirect0.67

and the minimum value is 0.7

Ah, the ".py" is included for the matching which enhances that value for redirect.py:

script indicator function
states_redirect0.97
surnames_redirects0.85
category_redirect0.77
capitalize_redirects0.76
redirect0.73

and the minimum value is 0.7.

We could:

  • remove the ending .py before use the string matching
  • increase the cutoff value e.g. to 0.74
  • use a config value (if the config.py is imported already at this state)
  • decrease the number of possibilities

What should we prefer?

btw I am just implementing to choose the right script from this list

  • remove the ending .py before use the string matching

It would be better, but also slower (?) Could be.

  • increase the cutoff value e.g. to 0.74

Yes!

  • use a config value (if the config.py is imported already at this state)

I don't like this one.

  • decrease the number of possibilities

I don't like this one either.

Change 496056 had a related patch set uploaded (by Xqt; owner: Xqt):
[pywikibot/core@master] [IMPR] Let the operator choose misspelled script

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

@Dvorapa Thanks for the appreciation. Hope to see the improved functionality soon @Xqt!

Change 496796 had a related patch set uploaded (by Xqt; owner: Xqt):
[pywikibot/core@master] [IMPR] Start the script if its name is similar to the given script name.

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

Change 496801 had a related patch set uploaded (by Xqt; owner: Xqt):
[pywikibot/core@master] [IMPR] Remove '.py' before matching the string

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

Change 496796 had a related patch set uploaded (by Xqt; owner: Xqt):
[pywikibot/core@master] [IMPR] Start the script if its name is similar to the given script name.

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

Change 496801 had a related patch set uploaded (by Xqt; owner: Xqt):
[pywikibot/core@master] [IMPR] Remove '.py' before matching the string

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

Sorry, I'm a little bit lost in the Depends-on chain. Could you write their order?

Sorry, I'm a little bit lost in the Depends-on chain. Could you write their order?

This is difficult because they really depend each on the other.

I mean where should I start with reviewing and where should I continue afterwards?

Xqt changed the subtype of this task from "Task" to "Feature Request".May 2 2019, 10:22 AM

Change 496801 merged by jenkins-bot:
[pywikibot/core@master] [IMPR] Remove '.py' before matching the string

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

Change 496056 had a related patch set uploaded (by Xqt; owner: Xqt):
[pywikibot/core@master] [IMPR] Let the operator choose misspelled script

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

Change 496056 merged by jenkins-bot:
[pywikibot/core@master] [IMPR] Let the operator choose misspelled script

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

Change 496796 merged by jenkins-bot:
[pywikibot/core@master] [IMPR] Start the script if its name is similar to the given script name.

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

Change 510497 had a related patch set uploaded (by Xqt; owner: Xqt):
[pywikibot/core@master] [IMPR] Add current directory for similar script search

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

Change 510497 merged by jenkins-bot:
[pywikibot/core@master] [IMPR] Add current directory for similar script search

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

Xqt claimed this task.