dev(narugo1992): add targeted enhance command#24
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #24 +/- ##
==========================================
Coverage 100.00% 100.00%
==========================================
Files 118 122 +4
Lines 9235 9604 +369
==========================================
+ Hits 9235 9604 +369 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Replace the romkan runtime dependency with a conservative built-in romaji-to-katakana converter because the romkan sdist fails metadata generation on Windows CI.
Remove unreachable defensive checks from the built-in romaji converter so patch coverage reflects the executable enhance path after replacing the external romkan dependency.
| def fail_opencc(conversion, value): | ||
| raise RuntimeError(f"{conversion}:{value}") | ||
|
|
||
| monkeypatch.setattr(_heuristics, "_opencc_convert", fail_opencc) |
There was a problem hiding this comment.
This patches an internal animedex helper, which bypasses project code inside the unit under test. The repo test policy keeps mocks at the wire or OS-boundary level; monkeypatching _opencc_convert can let the behavior under review drift while the test still passes. Please exercise this through real build_variants() behavior, or remove the defensive branch/coverage expectation if the OpenCC failure path is not worth carrying.
| out.append((f"enhance_{suggestion.variant_id}", q)) | ||
| seen.add(q) | ||
|
|
||
| if runtime_only: |
There was a problem hiding this comment.
--runtime-only currently has no effect: variant_queries() always builds variants from suggest(), and both branches return the same out. If this flag is meant to distinguish current CLI output from exploratory variants, either put the non-runtime candidate set behind the false branch or remove the flag and update the PR verification command. As written, the option name promises a restriction that the code never applies.
| all_cells = _read_cells(cells_path) | ||
| if all_cells and all(cell.variant in {"raw"} or cell.variant.startswith("enhance_") for cell in all_cells): | ||
| current_values = _current_variant_values() | ||
| cells = [ |
There was a problem hiding this comment.
This filters stale/non-current variants only for the generated summaries, but the committed cells.jsonl remains unfiltered. In the current PR artifact there are still 415 enhance_first_token cells even though current anime animedex enhance no longer emits first_token; summary.md then reports 4,137 cells while the JSONL has 4,560 lines. Please either rewrite/prune cells.jsonl when producing a runtime-only report, or commit a separate raw exploratory file and make the runtime artifact internally consistent.
ba1c686 to
2bdac71
Compare
Summary
Implements Scope A of #23 as a local
animedex enhance QUERYhelper that emits the query strings a user should actually try per backend, instead of dumping every possible rewrite.animedex.enhance.suggest()plus structuredEnhanceResult/EnhanceTarget/EnhanceSuggestionmodels.animedex enhancewith--type,--source,--limit-per-source,--json, and--jq.tools/generate_spec.py; the frozen spec only explicitly collects transliterator/OpenCC runtime data.tools/search_eval/: 100 MAL/Jikan top-popularity samples with real source-backed Mainland Chinese, Hong Kong/Macau Chinese, Taiwan Chinese, Korean, Japanese, and English names, plus a runtime-only live search run of the actual enhancement output.Demo
The committed source tape is
docs/source/_static/gifs/enhance.tape.CLI Examples And Measured Rescue
These are intentionally short CLI examples. The expected output is the TTY renderer output; the rescue note is from the committed live matrix in
tools/search_eval/runs/mal_cjk100_runtime/summary.mdandcells.jsonl.python -m animedex enhance '進擊的巨人' --type anime --source anilistExpected output:
Measured result: AniList raw
進擊的巨人returned 0 rows; enhanced进击的巨人hitAttack on Titan/Shingeki no Kyojinat position 0.python -m animedex enhance '鏈鋸人' --type anime --source anilistExpected output:
Measured result: AniList raw
鏈鋸人returned 0 rows; enhanced链锯人hitChainsaw Manat position 0.python -m animedex enhance '东京喰种√A' --type anime --source kitsuExpected output:
Measured result: Kitsu raw
东京喰种√Areturned 0 rows; enhanced東京喰種√AhitTokyo Ghoul √Aat position 0.python -m animedex enhance 'One-Punch Man' --type anime --source annExpected output:
Measured result: ANN raw
One-Punch Manreturned 0 rows; enhancedone punch manhitOne Punch Manat position 0.Japanese native input is deliberately not over-expanded when raw search is already strong.
python -m animedex enhance '葬送のフリーレン' --type anime --source jikanExpected output:
Measured result: Jikan raw
葬送のフリーレンalready hitSousou no Frierenat position 0, so the helper emits no noisy romanization or Chinese decode fallback.Measured Runtime Impact
The committed runtime-only matrix measures 100 MAL/Jikan popular anime samples across five anime search backends and six input-language buckets. The primary metric is strict rescue: raw missed, then raw plus the current runtime
animedex enhanceoutput found the target by backend ID or exact known-title/alias match. Substring-only matches are excluded.Overall, across 2,615 input-language/sample/backend groups, raw search hit 1,185 targets and raw plus enhance hit 1,278 targets. That is +93 strict raw-miss rescues, moving overall strict hit rate from 45.3% to 48.9% (+3.6 percentage points). The raw-miss rescue rate is 93/1,430 = 6.5%.
The improvement is concentrated rather than uniform: English benefits from punctuation/case cleanup, while Chinese benefits from directional Simplified/Traditional folds. Japanese native input is already strong on AniList/Jikan/Kitsu/Shikimori and produced no strict runtime rescue, and Korean remains weak without real cross-language alias knowledge.
Language Summary
lowercase_strip_punct.Backend Summary
Language By Backend Matrix
Practical Conclusions
lowercase_strip_punctrescues real raw misses on all five anime backends.zh_traditional, while Traditional/HK/MO/TW input mainly benefits fromzh_simplified.Empirical Notes
tools/search_eval/samples/mal_multilingual_anime100_enriched.jsoncontains 100 real MAL/Jikan anime samples. Input coverage:en=100,ja=100,ko=100,zh_cn=89,zh_hk_mo=54,zh_tw=80.tools/search_eval/runs/mal_cjk100_runtime/summary.mdis the live runtime-only matrix: 4,137 current-runtime cells overja,zh_cn,zh_hk_mo,zh_tw,ko, anden, measured separately instead of merging CJK.enhanceoutput found the intended target.Verification
make formatpytest test/enhance/test_suggest.py test/entry/test_enhance.py -q -m unittest(34 passed)make test(2934 passed, 84 skipped, 100% coverage)make rst_autopython -m animedex.policy.lintpython animedex_cli.py enhance --helppython animedex_cli.py --helpmake build && make test_cli(4 binary smoke probes passed)python -m tools.search_eval.eval_mal_cjk100 --out tools/search_eval/runs/mal_cjk100_runtime --runtime-only --report-onlypython /home/zhangshaoang/terminal-capture-workflow/scripts/terminal_capture.py probe-media docs/source/_static/gifs/enhance.gifpython /home/zhangshaoang/terminal-capture-workflow/scripts/terminal_capture.py extract-frames docs/source/_static/gifs/enhance.gif --times 6.5,19.8,26.02,31.5PP_AO3with--runtime-onlyand committed intools/search_eval/runs/mal_cjk100_runtime/.git diff --checkRefs #23 (Scope A only;
agg merge-animeremains separate).