Skip to main content

A package to query mdict

Project description

MDict Query R

This project is based on mdict-query, mdict-analysis, writemdict.

You can use this library to query MDX and MDD files. The library will create SQLite files to save dictionary indexes when you initiate a querier or add new dictionaries.

You can also use the original library to query and write MDX and MDD files.

Install

pip install mdict_query_r

Usage

Basic Usage

from mdict_query_r.query import Querier, Dictionary

d = Dictionary('test', 'test.mdx')
querier = Querier([Dictionary('test', mdx_file_path)])
records = querier.query('doe')

# records = [
#     Record(
#         dictionary_name='test',
#         entry=Entry(
#             id=1,
#             key_text='doe',
#             data='a deer, a female deer.'
#         )
#     )
# ]


# query multi words
records = querier.query(keywords=['doe', 'ray'])

# query with case insensitive
records = querier.query('doe', ignore_case=True)

Use mdict lib

use readmdict to directly read mdx file.

from mdict_query_r.lib.readmdict import MDX

mdx = MDX('test.mdx')

use writemdict to directly create mdx file.

from mdict_query_r.lib.writemdict import MDictWriter

dictionary = {
    "doe": "a deer, a female deer.",
    "ray": "a drop of golden sun.",
    "me": "a name I call myself.",
    "far": "a long, long way to run."
}

writer = MDictWriter(
    dictionary,
    title="Example Dictionary",
    description="This is an example dictionary."
)

with open('test.mdx', 'wb') as f:
    writer.write(f)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mdict_query_r-0.3.0.tar.gz (28.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mdict_query_r-0.3.0-py3-none-any.whl (27.4 kB view details)

Uploaded Python 3

File details

Details for the file mdict_query_r-0.3.0.tar.gz.

File metadata

  • Download URL: mdict_query_r-0.3.0.tar.gz
  • Upload date:
  • Size: 28.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.1

File hashes

Hashes for mdict_query_r-0.3.0.tar.gz
Algorithm Hash digest
SHA256 edee58220a70818c9fc56f0be23c070acaa8ae7aa06815e4cb8deab237cb325b
MD5 5f29b212c08b105fa2447f6eddbcf562
BLAKE2b-256 2210d41af35a3eb3a5b6ef41030253316c8c14cc19b77fa2dc19af3772b0be66

See more details on using hashes here.

File details

Details for the file mdict_query_r-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: mdict_query_r-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 27.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.1

File hashes

Hashes for mdict_query_r-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e4c1f2c0fcc616e24475dfe7cb18488490f9eb8412266e76c1b76db98509cc45
MD5 3248aaa4f5a253fa5b7abedcbd3c6caf
BLAKE2b-256 5eb62a7859374e8847c1083774746c3e68cc642aab182c3f9d7a7fc2d8eb5b88

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page