mortii / anki-morphs

A MorphMan fork rebuilt from the ground up with a focus on simplicity, performance, and a codebase with minimal technical debt.
https://mortii.github.io/anki-morphs/
Mozilla Public License 2.0
55 stars 8 forks source link

Error after recalce #17

Closed Vilhelm-Ian closed 11 months ago

Vilhelm-Ian commented 11 months ago

Debug info: Anki 23.10 (3394ab02) Python 3.9.15 Qt 6.5.0 PyQt 6.5.0 Platform: Linux-6.5.7-lqx1-1-lqx-x86_64-with-glibc2.38 Flags: frz=True ao=True sv=3 Add-ons, last update check: 2023-10-20 16:45:07 Add-ons possibly involved: ⁨ankimorphs-alpha⁩

Caught exception: Traceback (most recent call last): File "aqt.taskman", line 138, in _on_closures_pending File "aqt.taskman", line 82, in File "aqt.taskman", line 102, in wrapped_done File "aqt.operations", line 252, in wrapped_done File "/home/jovan/.local/share/Anki2/addons21/ankimorphs-alpha/recalc.py", line 588, in on_failure raise error File "concurrent.futures.thread", line 58, in run File "aqt.operations", line 242, in wrapped_op File "/home/jovan/.local/share/Anki2/addons21/ankimorphs-alpha/recalc.py", line 52, in recalc_background_op update_cards(am_config) File "/home/jovan/.local/share/Anki2/addons21/ankimorphs-alpha/recalc.py", line 281, in update_cards card_difficulty, unknowns = get_card_difficulty_and_unknowns( File "/home/jovan/.local/share/Anki2/addons21/ankimorphs-alpha/recalc.py", line 513, in get_card_difficulty_and_unknowns difficulty += morph_priority[morph["entire_morph"]] KeyError: 'richesriches'

Vilhelm-Ian commented 11 months ago

The number Knowns remains the same. And cards with morphs that have been tagged as Already_Known keep appearing

mortii commented 11 months ago

Are you using the "Language w/ Spaces" morphemizer?

Vilhelm-Ian commented 11 months ago

yes

mortii commented 11 months ago

I'm not able to reproduce this problem:

line 513, in get_card_difficulty_and_unknowns difficulty += morph_priority[morph["entire_morph"]] KeyError: 'richesriches'

Could you provide the following:

  1. go to Tools -> Add-ons -> select ankimorphs-alpha -> click Config button on the bottom right -> copy all the content, paste it here
  2. Could you find the card with the 'riches' word in it and copy paste the text of it here

Thanks!

Vilhelm-Ian commented 11 months ago
  1. This is for the first part
{
    "filters": [
        {
            "difficulty_field": "(none)",
            "difficulty_field_index": 0,
            "field": "Expression",
            "field_index": 0,
            "focus_morph_field": "MorphMan_FocusMorph",
            "focus_morph_field_index": 7,
            "highlighted_field": "(none)",
            "highlighted_field_index": 0,
            "modify": true,
            "morphemizer_description": "Language w/ Spaces",
            "morphemizer_name": "SpaceMorphemizer",
            "note_type": "german_morphman",
            "note_type_id": 1607909089576,
            "read": true,
            "tags": [
                ""
            ]
        }
    ],
    "parse_ignore_bracket_contents": true,
    "parse_ignore_proper_nouns": true,
    "parse_ignore_round_bracket_contents": true,
    "parse_ignore_slim_round_bracket_contents": true,
    "parse_ignore_suspended_cards_content": true,
    "recalc_before_sync": false,
    "recalc_interval_for_known": 21,
    "recalc_prioritize_collection": false,
    "recalc_prioritize_textfile": true,
    "shortcut_browse_all_same_unknown": "Shift+L",
    "shortcut_browse_ready_same_unknown": "L",
    "shortcut_learn_now": "Ctrl+Alt+N",
    "shortcut_recalc": "Ctrl+M",
    "shortcut_set_known_and_skip": "K",
    "shortcut_settings": "Ctrl+O",
    "shortcut_view_morphemes": "Ctrl+Alt+V",
    "skip_show_num_of_skipped_cards": true,
    "skip_stale_cards": true,
    "skip_unknown_morph_seen_today_cards": true,
    "tag_known": "am-known",
    "tag_learning": "am-learning",
    "tag_not_ready": "am-not-ready",
    "tag_ready": "am-ready"
}
  1. Now the error is a little different
An error occurred. Please start Anki while holding down the shift key, which will temporarily disable the add-ons you have installed.
If the issue only occurs when add-ons are enabled, please use the Tools > Add-ons menu item to disable some add-ons and restart Anki, repeating until you discover the add-on that is causing the problem.
When you've discovered the add-on that is causing the problem, please report the issue to the add-on author.
Debug info:
Anki 23.10 (3394ab02) Python 3.9.15 Qt 6.5.0 PyQt 6.5.0
Platform: Linux-6.5.7-lqx1-1-lqx-x86_64-with-glibc2.38
Flags: frz=True ao=True sv=3
Add-ons, last update check: 2023-10-22 09:32:35
Add-ons possibly involved: ⁨ankimorphs-alpha⁩

Caught exception:
Traceback (most recent call last):
  File "aqt.taskman", line 138, in _on_closures_pending
  File "aqt.taskman", line 82, in <lambda>
  File "aqt.taskman", line 102, in wrapped_done
  File "aqt.operations", line 252, in wrapped_done
  File "/home/jovan/.local/share/Anki2/addons21/ankimorphs-alpha/recalc.py", line 588, in on_failure
    raise error
  File "concurrent.futures.thread", line 58, in run
  File "aqt.operations", line 242, in wrapped_op
  File "/home/jovan/.local/share/Anki2/addons21/ankimorphs-alpha/recalc.py", line 52, in recalc_background_op
    update_cards(am_config)
  File "/home/jovan/.local/share/Anki2/addons21/ankimorphs-alpha/recalc.py", line 281, in update_cards
    card_difficulty, unknowns = get_card_difficulty_and_unknowns(
  File "/home/jovan/.local/share/Anki2/addons21/ankimorphs-alpha/recalc.py", line 513, in get_card_difficulty_and_unknowns
    difficulty += morph_priority[morph["entire_morph"]]
KeyError: 'isis'`

but I can't find a card that contains a word isis only words that have isis in them like und Gastroschisis (Fehlbildung der Hautwand)...

Vilhelm-Ian commented 11 months ago

language__German.apkg.zip

Here is my colleciton. The file is not really a zip I just added the extension because github wouldn't allow me to upload a file that ends with apkg just remove the .zip. The note type is german_morphman

mortii commented 11 months ago

You are a legend, thank you for helping me so much!

The bugs comes from selecting "prioritizing morphs based on frequency.txt", I have only implemented the "frequency in card collection"-option because I was planning on redoing the frequency.txt option later. For the time being I'll just add back the old logic for the frequenxy.txt option to make it work, shouldn't take long.

mortii commented 11 months ago

I found really bad problems with the morphman implementation of frequency.txt... It does not differentiate between between inflected morphs and base morphs, so it will almost certainly misinterpret morphs and give false-positives. An even worse problem is that it gives completely inconsistent priority values to the morphs for some reason... e.g:

{'の': 0, 'は': 1, 'に': 2, 'が': 3, 'を': 4, 'で': 5, 'と': 6, 'も': 7, 'だ': 8, 'から': 9, 'よ': 10, 'する': 28807, '為る': 41988, 'か': 13, ...

Adding this logic to ankimorphs would be a disaster, and I can't really fix those problems until I remake the readability analyzer...

I don't know how diverse the sources of your cards are but, with almost 50k cards you should hopefully get pretty decent results with the "frequency in card collection"-option.

Sorry for not being able to give a better solution :/

Vilhelm-Ian commented 11 months ago

no problem. The fact that you pointed out the problem was that I was using sort by frequency.txt made anki-morphs usuable for me again

mortii commented 11 months ago

I have removed the "frequency.txt"-option. After I push the update you might have to select the "frequency in card collection"-option and save the settings if you haven't already done so.

github-actions[bot] commented 6 months ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.