feat: 在输入未被识别的命令时查找用户最可能想输入的命令 #34
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Done, Request Code Review
Link Issue: #33
现在只有键入

/help才会打印帮助页 别的时候不会了在出现未被识别处理的命令的时候会去命令列表里搜索有没有可能的 有的话输出最相似的那个
但和我那个重构项目里处理逻辑不同的是 我没有改动”命令开头匹配“的机制【重构计划里改成强制匹配第一段了】也就是说会出现这种情况:
但我觉得这样没有什么不好 所以就没改【毕竟开头匹配都能匹配上那用户也应该知道自己打的啥】
同时这个算法我在Issue里也说了是把levenshtein和jaccard结合起来的 不用Sorensen Dice算法或者levenshtein或jaccard单用主要是因为每种算法都有一定局限性 举个例子
所以我最后选的就是levenshtein距离最短的且两者jaccard相似度大于75% 结果就是

当然这种算法也代表着在遇到错的离谱的命令会无法匹配 你可以考虑一下在这种情况下要不要输出help page