Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide dictionary-based suggestions for common misspellings #4392

Merged
merged 1 commit into from Oct 5, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
25 changes: 25 additions & 0 deletions php/utils.php
Expand Up @@ -1070,6 +1070,31 @@ function glob_brace( $pattern, $dummy_flags = null ) {
* @return string
*/
function get_suggestion( $target, array $options, $threshold = 2 ) {

$suggestion_map = array(
'check' => 'check-update',
'clear' => 'flush',
'decrement' => 'decr',
'del' => 'delete',
'directory' => 'dir',
'exec' => 'eval',
'exec-file' => 'eval-file',
'increment' => 'incr',
'language' => 'locale',
'lang' => 'locale',
'new' => 'create',
'number' => 'count',
'remove' => 'delete',
'regen' => 'regenerate',
'rep' => 'replace',
'repl' => 'replace',
'v' => 'version',
);

if ( array_key_exists( $target, $suggestion_map ) ) {
return $suggestion_map[ $target ];
}

if ( empty( $options ) ) {
return '';
}
Expand Down