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.1.tar.gz (29.0 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.1-py3-none-any.whl (27.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: mdict_query_r-0.3.1.tar.gz
  • Upload date:
  • Size: 29.0 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.1.tar.gz
Algorithm Hash digest
SHA256 2acb1134e9765c979a8f500cb83f29a38c200ce101fb3b6ac897224e42825ace
MD5 62a289e51147568ccb8b880ff21ae765
BLAKE2b-256 dc3162b0ad4e11ced02edbb207b4972c90992fb736cbe4100f89de890c0d10be

See more details on using hashes here.

File details

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

File metadata

  • Download URL: mdict_query_r-0.3.1-py3-none-any.whl
  • Upload date:
  • Size: 27.5 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 5f059d27454ca417f8b398ce82e8a3c0f79d4ddb3e1931980cbc519c3ed298e9
MD5 8b6db759dbc5ff035c7f015ebe9c60db
BLAKE2b-256 b4e801745d3147d5eb3fbd7245ed585d0b0a155e36b73445a335247b92ef6855

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