-
-
Notifications
You must be signed in to change notification settings - Fork 18
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
Check for uppercase at each position when adding keyboard edits #38
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change has the effect that only upper-case replacements are suggested to replace upper-case characters, and only lower-case replacements are suggested to replace lower-case characters. This solution keeps the current (confusing) behavior of main
by making replacements at the in-group position
instead of the in-word index
. See my other PR for a different solution.
@@ -78,7 +79,6 @@ function suggest(value) { | |||
while (++index < length) { | |||
character = value.charAt(index) | |||
insensitive = character.toLowerCase() | |||
upper = insensitive !== character |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't need to know the case of character
, as we will (confusingly) make our replacements at the in-group position
instead of the in-word index
. My other PR handles this differently.
@@ -91,6 +91,8 @@ function suggest(value) { | |||
} | |||
|
|||
before = value.slice(0, position) | |||
between = value[position] || value.slice(-1) | |||
upper = between !== between.toLowerCase() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here, we observe the upper-case status of between
, which is the character that will be replaced, or the last character in the word if position
happens to occur after the end of the word. This would occur when replacing the "z" in "Twinz" for keyboard group "qwertzuop", at position = 5
, which is beyond the last index in "Twinz".
The current approach of main
would erroneously make these replacements as TwinzQ
... TwinzP
. This solution would make the slightly more sensible replacements of Twinzq
... Twinzp
. See my other PR for a solution that would make the replacements of Twinq
... Twinp
.
This PR only fails #46, and it matches the expected value more closely for this test than the does the other PR. |
I'm closing this PR in favor of PR #39, which now passes the tests just as well as this PR does. |
This addresses a
retext-spell
issue I've discovered that is fundamentally annspell
issue.I'm including a concrete example of the problem for reference.
Differences from
main
are bolded:One Example I've tested
a
is "t" at index 0before
="Twin" andafter
= ""b
="e"This is how we (confusingly) arrive at the correct suggestion of "Twine".
Ignoring a bigger problem
In
main
, the notion of "Keyboard groups" doesn't really make sense as it replaces at a position (ofa
in group) that is unrelated to the original position (ofa
in word). This solution ignores that "root problem."For another solution, see my related PR.
Following the approach of
main
, this solution splits the word at the unrelated position of charactera
in the keyboard group. Working within that constraint, this solution uses the case of character that will be replaced to decide the case of the replacement character. See my review comments.