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 {{type:nc:…}} – ignores combining characters when comparing #680

Closed
wants to merge 5 commits into from

Conversation

twwn
Copy link
Contributor

@twwn twwn commented Jul 7, 2020

This allows to add :nc to type fields, causing Anki to ignore all combining characters so as to not fault their absence in the user input as errors.

It improves one's learning experience with languages such as Hebrew whose use of diacritics (nikud) is almost entirely limited to reading them (in class/references), with nobody writing them (very cumbersome anyway) in everyday use for ordinary words.

Example before / after:

wo-nc
with-nc

The approach basically consists of:

  • Strip given & correct of their combining characters
  • Use that for tokenizeComparison
  • "Map" the stripped correct to its original
  • Restore the combining characters in the correction line with that "mapping"

It's either-or, meaning any combining characters in the input/given are discarded as well (so no partial comparison).

Notable otherwise: one functional change affecting the non-:nc path and two clean-ups

  • If no user input (given) was entered, simply return the field/correct straight away with minimal formatting.
  • Removed an unused correct() parameter.
  • Skip the redundant tokenizeComparison for the non-:nc path when given already matches correct.

twwn added 5 commits July 7, 2020 20:57
effect is used throughout the function anyway

also no point doing it in the type:nc path
no change other than type:nc will show the original field content (ie. with combining characters)
no point in processing a deliberate non-answer, it's cleaner anyway
@dae
Copy link
Member

dae commented Jul 8, 2020

Hi rathsky,

No objections to the idea itself, but the type-in-the-answer code is likely going to move into TypeScript in the future, so this would probably be better done after that change is made - will leave this open until then.

Regarding the specifics of this implementation, perhaps simply stripping all combining characters if the user has used nc: would suffice? It would make for a simpler implementation if you don't need to preserve the original text verbatim.

@twwn
Copy link
Contributor Author

twwn commented Jul 8, 2020

It would make it simpler, but while the diacritics are an obstacle to typing the words, they are still essential to their learning. So removing them entirely would require duplicating the field, which is unsightly and a waste of space.

Base automatically changed from master to main January 29, 2021 01:09
@dae
Copy link
Member

dae commented Mar 20, 2024

Cleaning up old PRs - please open a new one if you'd like to continue this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants