Skip to content

Restructure package layout and optimize SQLite lookups - #4

Merged
moikdev merged 5 commits into
mainfrom
cursor/package-restructure-db-optimize
Jul 12, 2026
Merged

moikdev merged 5 commits into
mainfrom
cursor/package-restructure-db-optimize

Conversation

@moikdev

@moikdev moikdev commented Jul 12, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • Reorganize the library into clearer packages (grammar/, lookup/, scoring/, output/, types.py) while keeping the public API and shim modules stable.
  • Slim the SQLite dictionary and speed up lookups (covering indexes, batched conjugations, persisted trie mmap) without changing segmentation/scoring quality.
  • Add CI, expand score-equivalence locks (~40 sentences), and fix trie prefix-pruning that had dropped suffix compounds.

Validation

  • Score equivalence vs main: 200/200 LLM-eval sentences identical on top-path splits, readings, and scores (scripts/ab_split_equivalence.py).
  • Warm analyze ~12–20% faster; warm_up() ~96% faster (persisted trie); cold first-call without warm_up ~19% slower — prefer warming at process start.
  • Local pytest suite green with DB; CI mocks fixed for environments without the dictionary DB.

Test plan

  • CI passes on this PR
  • pytest tests/ -x --tb=short with HIMOTOKI_DB_PATH set
  • Spot-check: python -c "import himotoki; himotoki.warm_up(); print(himotoki.analyze('学校で勉強しています')[0][0])"
  • Optional: python3 scripts/ab_split_equivalence.py -n 200 against a main worktree

moikdev and others added 5 commits July 12, 2026 17:36
Split mega-modules into types/scoring/lookup/grammar/output packages, add covering indexes and query batching while preserving scoring equivalence, and document the system under .cursor.

Co-authored-by: Cursor <cursoragent@cursor.com>
Prefix prune used break, so forms like 食べたい never reached suffix lookup; keep collecting substrings for suffixes and only skip DB IN-lists.

Co-authored-by: Cursor <cursoragent@cursor.com>
Keep only the original trie membership filter for DB lookups; suffix compounds stay on the same path as before the restructure.

Co-authored-by: Cursor <cursoragent@cursor.com>
Grow the equivalence snapshot to 40 sentences, run pytest on PRs, clear scoring caches on shutdown, and remove leftover restructure dead code.

Co-authored-by: Cursor <cursoragent@cursor.com>
Mocked CLI tests now pass a real temp --database path so setup prompts are skipped; upgrade checkout/setup-python to v6.

Co-authored-by: Cursor <cursoragent@cursor.com>
@moikdev
moikdev merged commit b1bb5eb into main Jul 12, 2026
2 checks passed
@moikdev
moikdev deleted the cursor/package-restructure-db-optimize branch July 12, 2026 09:35
@moikdev
moikdev restored the cursor/package-restructure-db-optimize branch July 12, 2026 09:59
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.

1 participant