# mdict-query **Repository Path**: elephantsoft/mdict-query ## Basic Information - **Project Name**: mdict-query - **Description**: 查字典, 美化界面, 自用 - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 2 - **Created**: 2024-11-19 - **Last Updated**: 2024-11-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README This is a python module for looking up `mdict` dictionary files (`.mdx` and `.mdd`). >>Based on [readmdict](https://bitbucket.org/xwang/mdict-analysis) by [Xiaoqiang Wang](http://bitbucket.org/xwang/). While this project is a trivial extension of the [original module](https://bitbucket.org/xwang/mdict-analysis), it adds the features of looking up a single entry in `.mdx` or resource file in `.mdd` without extracting all content, which may be helpful in other projects that requires dictionaries. ## Usage Constructs the `IndexBuilder` object, which builds the sqlite index for `.mdx` file and the corresponding `.mdd` file (if exists). from mdict_query import IndexBuilder builder = IndexBuilder('ode.mdx') Get all mdx keys: builder.get_mdx_keys() # ==> ['key1', 'key2', 'key3', ...] Filter mdx keys by wildcard: builder.get_mdx_keys('dedicat*') # ==> ['dedicate', 'dedication', ...] Looks up mdx with a key: result_text = builder.mdx_lookup('dedication') There is an option to ignore cases: result_text = builder.mdx_lookup('Dedication', ignorecase = True) Get all mdd keys: builder.get_mdd_keys() # ==> ['key1', 'key2', 'key3', ...] Filter mdd keys by wildcard: builder.get_mdd_keys('*.css') # ==> ['/style.css', ...] Looks up mdd with a key: bytes_list = builder.mdd_lookup('/style.css') #bytes_list is the bytes list of the file stored in mdd