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

Add command suggestions #6688

Merged
merged 14 commits into from May 13, 2022

Conversation

Descacharrado
Copy link
Contributor

Makes suggestions when a command is misspelled as seen below.

untitled
*works in mp chats too.

Explanation:

Other commands will be recommended when a third or less of the letters (of the shortest string, either player input or actual command) are wrong. Additions, deletions, swaps and changes all count as 1 error (1 wrong letter).

  • Writing 'hlep' recommends 'help' because there is only one error and the word is four letters (1/4 <= 1/3, one swap, string_utils.cpp Line 375)
  • Writing 'hel' recommends 'help' because there is only one error and the word is three letters (1/3 <= 1/3, one deletion)
  • Writing 'hello' does not recommend 'help' because there are two errors and the word is four letters (2/3 > 1/3, an addition and a change)
  • Writing 'aawhiteboard' does not recommend 'whiteboard', even if there are only two errors out of eleven letters (2/11 <= 1/3) because the implementation is approximated and gets "lost" after two consecutive (non-swap) errors (string_utils.hpp Line 139)

The change comes from #6421 (comment) which comes from #1018

Needless to say that the implementation and thresholds are not set in stone, I even pushed all the commits so anyone can follow along the development to better understand my decisions.

@github-actions github-actions bot added the WFL Issues involving the Wesnoth Formula Language engine and APIs. label May 6, 2022
Copy link
Member

@CelticMinstrel CelticMinstrel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great! I can't believe no-one has thought to do this before. I see a few small issues that need addressing, though (see specific comments below).

src/formula/string_utils.cpp Outdated Show resolved Hide resolved
src/formula/string_utils.cpp Outdated Show resolved Hide resolved
src/map_command_handler.hpp Outdated Show resolved Hide resolved
src/map_command_handler.hpp Outdated Show resolved Hide resolved
src/formula/string_utils.cpp Outdated Show resolved Hide resolved
src/map_command_handler.hpp Outdated Show resolved Hide resolved
src/map_command_handler.hpp Outdated Show resolved Hide resolved
src/map_command_handler.hpp Outdated Show resolved Hide resolved
@Wedge009 Wedge009 added the UI User interface issues, including both back-end and front-end issues. label May 9, 2022
@Descacharrado Descacharrado requested a review from Vultraz May 9, 2022 13:00
src/map_command_handler.hpp Outdated Show resolved Hide resolved
src/map_command_handler.hpp Outdated Show resolved Hide resolved
src/map_command_handler.hpp Outdated Show resolved Hide resolved
src/map_command_handler.hpp Outdated Show resolved Hide resolved
src/map_command_handler.hpp Outdated Show resolved Hide resolved
@Pentarctagon
Copy link
Member

It looks like this can be merged then?

@Vultraz Vultraz merged commit 87d5746 into wesnoth:master May 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
UI User interface issues, including both back-end and front-end issues. WFL Issues involving the Wesnoth Formula Language engine and APIs.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants