Anki/pylib/anki
a.r e2124cd790
typeanswer: [type:nc] – ignores combining characters (#3422)
* typeanswer: fix cleanup

Fix: Add prepare_expected back in for the 'nothing typed' & 'correctly typed' cases. This also makes expected_original redundant again.

Style: %s/provided/typed/g

Style: rename one ch → c

Testcase: whitespace_is_trimmed: added a check for the "correctly typed" path and renamed it to tags_removed (there's no whitespace?)

Testcase: empty_input_shows_as_code: changed to also check that tags get trimmed

* [type:nc] – ignores combining characters

Adds a comparison variant to [type] which ignores when combining characters of the expected field are missing from the provided input. It still shows these characters in the 'expected' line for reference.

It's useful for languages with e.g. diacritics that are required for reference (such as in dictionaries), but rarely actually learned or used in everyday writing. Among these languages: Arabic, Hebrew, Persian, Urdu.

The bool 'combining' controls it as new final parameter of both relevant compare_answer functions. On the Python side, it's set to true by default.

Use on the note templates: [type:nc:field] (only the front needs to include :nc)

This also removes the need to have both variants of words/sentences present as separate fields, to show them redundantly, etc.

* typeanswer: simplify by using nfkd throughout

Requires adjusting two testcases, but both render exactly the same in Anki itself.

On NFC vs. NKFD: https://stackoverflow.com/a/77432079

* typeanswer: 'simplify' by removing normalize_typed (requiring a bool parameter)

I'd prefer to keep this extra method.

* typeanswer: micro-optimize vectors

Should get rid of most relocations, at the expense of over-allocating.

On Vec's (String's) behavior: https://stackoverflow.com/a/72787776

* Mark `combining` as private

typeCorrect is not marked as private either, but we can at least do
the right thing for newly-added code.

* Revert "typeanswer: micro-optimize vectors"

This reverts commit 9fbacbfd19.

* Revert "typeanswer: 'simplify' by removing normalize_typed (requiring a bool parameter)"

This reverts commit df2dd3394e.
2024-09-30 23:11:51 +10:00
..
_vendor Update Python deps 2023-03-31 14:04:05 +10:00
foreign_data Update type annotation syntax (#3283) 2024-07-21 14:00:52 +07:00
importing Improve exception handling (#3290) 2024-08-04 20:51:13 +07:00
scheduler Update type annotation syntax (#3283) 2024-07-21 14:00:52 +07:00
_backend.py Update type annotation syntax (#3283) 2024-07-21 14:00:52 +07:00
_legacy.py Update type annotations (#3322) 2024-07-26 17:57:25 +07:00
_rsbridge.pyi style: reformat with black (#3324) 2024-07-26 17:58:57 +07:00
browser.py Enable invalid-name globally in pylib (#1454) 2021-10-25 19:10:56 +10:00
cards.py fix: add proper imports (#3296) 2024-08-05 11:34:46 +07:00
collection.py typeanswer: [type:nc] – ignores combining characters (#3422) 2024-09-30 23:11:51 +10:00
config.py python: add missing type annotations for None values (#3364) 2024-08-22 16:03:44 +07:00
consts.py Strip out v1/v2 code 2023-09-24 14:27:40 +10:00
db.py Enable invalid-name globally in pylib (#1454) 2021-10-25 19:10:56 +10:00
dbproxy.py Update type annotations (#3322) 2024-07-26 17:57:25 +07:00
decks.py python: add missing type annotations for None values (#3364) 2024-08-22 16:03:44 +07:00
errors.py Remove v1/v2 support from the backend (#2727) 2023-10-14 10:50:59 +10:00
exporting.py Update type annotation syntax (#3283) 2024-07-21 14:00:52 +07:00
find.py Add py3.9 to hooks (#1542) 2021-12-09 09:11:22 +10:00
hooks.py Improve exception handling (#3290) 2024-08-04 20:51:13 +07:00
httpclient.py python: add missing type annotations for None values (#3364) 2024-08-22 16:03:44 +07:00
lang.py Improve exception handling (#3290) 2024-08-04 20:51:13 +07:00
latex.py Improve exception handling (#3290) 2024-08-04 20:51:13 +07:00
media.py Update type annotations (#3322) 2024-07-26 17:57:25 +07:00
models.py python: add missing type annotations for None values (#3364) 2024-08-22 16:03:44 +07:00
notes.py Refactor ephemeral_card of notes (#3307) 2024-07-21 15:25:48 +07:00
py.typed mark anki and aqt modules as having typing info 2020-01-13 13:03:37 +10:00
rsbackend.py PEP8 for rest of pylib (#1451) 2021-10-25 14:50:13 +10:00
sound.py Enable invalid-name globally in pylib (#1454) 2021-10-25 19:10:56 +10:00
stats.py refactor: use not in and is not as recommended (#3351) 2024-08-10 17:55:26 +07:00
statsbg.py Update licensing information (#2850) 2023-11-27 11:35:51 +10:00
stdmodels.py Update type annotations (#3322) 2024-07-26 17:57:25 +07:00
storage.py Enable invalid-name globally in pylib (#1454) 2021-10-25 19:10:56 +10:00
sync.py Enable invalid-name globally in pylib (#1454) 2021-10-25 19:10:56 +10:00
syncserver.py Update Rust and Python deps (#2567) 2023-07-01 18:26:43 +10:00
tags.py Update type annotation syntax (#3283) 2024-07-21 14:00:52 +07:00
template.py python: add missing type annotations for None values (#3364) 2024-08-22 16:03:44 +07:00
types.py Enable invalid-name globally in pylib (#1454) 2021-10-25 19:10:56 +10:00
utils.py Improve exception handling (#3290) 2024-08-04 20:51:13 +07:00