Add PocketBook SDIC (.dic) writer plugin#708
Merged
Merged
Conversation
Implement write support for PocketBook SDIC binary dictionary format Features: - Entries sorted by collated key (accent-folded, uppercased) - Duplicate headword merging with configurable separator - zlib-compressed data blocks with binary search for optimal packing - Block limits: max 100 entries, 65531 raw bytes, 4097 compressed target - Built-in English metadata defaults (collates, morphems, keyboard) - Configurable metadata via write options (metadata_dir, collates_path, etc.) - Skips binary resource entries with aggregated warning - Uses only primary term (alternates/synonyms ignored) Write options: - metadata_dir: directory with collates.txt, morphems.txt, keyboard.txt - collates_path, keyboard_path, morphems_path: individual overrides - merge_separator: separator for duplicate headword merging (default: <br>) Tests: 50 unit tests + 13 integration tests covering collation, body encoding, block packing, section building, header construction, sorting, merging, HTML preservation, and multi-block dictionaries. Co-authored-by: Copilot <[email protected]>
ilius
reviewed
Mar 24, 2026
ilius
reviewed
Mar 24, 2026
ilius
reviewed
Mar 24, 2026
entries are sorted by get_collated_key(...) which allocates: str.translate is cleaner and likely faster than hand-rolled loop
ilius
reviewed
Mar 24, 2026
ilius
reviewed
Mar 24, 2026
Owner
|
Thanks |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Background:
This PR ports the Go writer to Python. (I'm not aware of any need for the reader, but if anyone asks, it'd be rather easy to add later.)
There's an open question regarding the sorting order. PocketBook .dic files include a section which determines how keys are collated. Ideally it would be generated from PyICU automatically, or respect
--sort-encoding, but this would be quite an undertaking. So for now the sorting is done internally by the plugin. Any ideas of how to improve this are very welcome.LLM usage disclaimer: