Code Monkey home page Code Monkey logo

mdict-query's Introduction

This is a python module for looking up mdict dictionary files (.mdx and .mdd). Function converting mdx to sqlite is added.

Based on readmdict by Xiaoqiang Wang.

While this project is a trivial extension of the original module, 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')

Convert mdx to sqlite:

builder.make_sqlite()
# Check the output file `ode.mdx.sqlite.db` near your `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

mdict-query's People

Contributors

mmjang avatar cryptogun avatar lujun9972 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.