kodokan.flashcards#
Technique-recognition learning game (app #6) — logic layer.
Help students learn to recognize/name throws. No throw-detection is needed (ground truth is known): we generate multiple-choice problems from the clip library — name -> pick the video or video -> pick the name — with confusable distractors, log every response (timestamped, with the exact problem) for adaptive learning, and score with confusion-aware weighting.
“Confusability” between techniques is a pose-shape similarity (closeness of their mean pooled descriptors) — an honest proxy for visual confusability that does NOT require a working recognizer (the cross-source recognizer is currently at chance). It can be swapped for the model’s confusion matrix once recognition generalizes.
This module is the (UI-agnostic) logic + storage; a web UI plugs into it later.
Functions
|
Build |
|
Technique×technique similarity (0..1) from mean pooled pose descriptors. |
|
Technique×technique confusability from the recognizer's own leave-one-out confusions. |
|
The web-app clip file for one demo segment, named by the segment's IDENTITY. |
|
Pick |
|
Record a response (datetime + exact problem + choice + correctness + score). |
|
Build a multiple-choice problem for |
|
Pick the next technique to quiz: unseen and often-missed (within |
|
Assemble a |
|
A dict-like JSON store of logged responses (per-user, timestamped). |
|
Confusion-weighted credit in [0, 1]. |
Classes
|
One multiple-choice flashcard problem. |
- class kodokan.flashcards.Problem(problem_id, mode, target_key, prompt, choices, correct_index)[source]#
Bases:
objectOne multiple-choice flashcard problem.
- kodokan.flashcards.build_catalog(*, min_two_person_frac=None, min_demo_s=1.0, max_demos=None, segments=None)[source]#
Build
{technique_key: {"name", "clips":[...]}}from the pose/segments stores.Aggregates all sources: each clip contributes its demo intervals (for looping media), so a technique present in several sources offers varied multiple-choice media.
max_demoscaps the demos kept per source video (None, the default, keeps every demo that passes the quality gate — #37: the store has 6–8 reps per video and all of them are worth showing).segmentsis the{video_id: record}mapping to read (default:kodokan.store.segments_store()).
- kodokan.flashcards.build_confusability(catalog=None, *, feature='tori_angles_pos')[source]#
Technique×technique similarity (0..1) from mean pooled pose descriptors.
similarity[a][b]high ⇒ techniques a, b look alike in pose-space (likely confusable for a learner). An honest, recognizer-free proxy; swap for the model’s confusion matrix once cross-source recognition works.- Return type:
- kodokan.flashcards.build_model_confusability(catalog=None, *, feature='tori_angles_pos', method='lda_knn', cross_source=True)[source]#
Technique×technique confusability from the recognizer’s own leave-one-out confusions.
Same shape as
build_confusability(). Predictions are leave-one-clip-out (cross_source) or leave-one-sample-out. Techniques the model never confuses get no row entries;learning.merge_similarity/ the strategies fall back as usual.- Return type:
- kodokan.flashcards.clip_filename(video_id, start_s, dur_s)[source]#
The web-app clip file for one demo segment, named by the segment’s IDENTITY.
{video_id}_{start_ms}_{dur_ms}.mp4: the name says which time span of which source it shows, so re-segmenting can never make an existing name show a different cut (#45) — a changed segment simply gets a new name. Positional names ({vid}_3.mp4) could.- Return type:
- kodokan.flashcards.confusable_distractors(target_key, keys, *, n, similarity=None, rng=None)[source]#
Pick
ndistractor keys, preferring those most confusable with the target.The choice is learny’s (
learny.distractors.pick_distractors()): weighted bysimilarity, uniform when it knows nothing of the target.- Return type:
- kodokan.flashcards.log_response(problem, chosen_index, *, user='default', store=None, similarity=None, timestamp=None)[source]#
Record a response (datetime + exact problem + choice + correctness + score).
- Return type:
- kodokan.flashcards.make_problem(catalog, target_key, *, mode='video_to_name', n_choices=4, similarity=None, rng=None, clip_for=None)[source]#
Build a multiple-choice problem for
target_keyfrom a techniquecatalog.catalogmapstechnique_key -> {"name": str, "clips": [clip dicts]}.clip_for(key)returns a looping clip for a key (default: first clip); forname_to_videothe choices are clips, forvideo_to_namethey are names.- Return type:
- kodokan.flashcards.next_target(keys, history, *, focus=None, rng=None)[source]#
Pick the next technique to quiz: unseen and often-missed (within
focus) first.Spaced-repetition-ish weight = (wrongs + 1) / (seen + 1): unseen -> 1, frequently wrong -> high, mastered -> low.
historyis a list of response dicts.- Return type:
- kodokan.flashcards.problem_from_keys(catalog, target_key, option_keys, *, mode='video_to_name', clip_for=None, problem_id)[source]#
Assemble a
Problemfrom an already-chosen, ordered option set.The seam between choosing (
make_problem, or alearning.Strategy) and presenting: whoever picks the options, the problem looks the same.- Return type:
- kodokan.flashcards.responses_store(directory=None)[source]#
A dict-like JSON store of logged responses (per-user, timestamped).
- kodokan.flashcards.score_response(correct_key, chosen_key, *, similarity=None, max_partial=0.5)[source]#
Confusion-weighted credit in [0, 1].
Correct = 1.0. A wrong answer earns partial credit proportional to how confusable the chosen technique is with the correct one (an honest mistake between look-alike throws is penalized less than confusing two obviously different throws).
- Return type: