Skip to main content

Search tool for Japanese text in EPUB and Mokuro files

Project description

imajin.py

imajin.py is a search tool for .epub, .mokuro, .srt and .ass files, designed to help you find example sentences in your Japanese media.


Index


Features

  • Search across unencrypted .epub (ebooks), .mokuro (manga), and .srt and .ass (subtitled) files
  • Supports smart matching for Japanese conjugations (optional)
  • Supports searching individual words or phrases
  • Structured output: text, markdown, or JSON
  • Recursively search directories of books, manga, and subtitles
  • Clean highlighted snippets showing surrounding context

Installation

Install with pip (preferred method)

Recommended because it will be easier to update going forward, especially if you prefer to have the script installed.

  1. Install Python 3.9+ if not allready installed

  2. Install imajin using pip:

    pip install imajin
    

    You should be all set up to use imajin directly from the command line.

Download and install script

Not recommended, because it's harder to update.

  1. Install Python 3.9+ if not already installed.

  2. Download the source folder, either by downloading the Source code from the Latest Release or using git clone https://github.com/YonKuma/imajin.py.git

  3. Install dependencies:

    pip install -r requirements.txt
    

    You can now use imajin.py as a python script. For example, if you're in the source directory, you can use python imajin.py -r 蹴散らす ~/Documents/Manga, but you'll need to use a qualified path to the files you want to search

  4. (Optional) You can install imajin by copying the script to somewhere in your PATH and making it executable

    sudo cp imajin.py /usr/local/bin/imajin
    sudo chmod +x /usr/local/bin/imajin
    

Dependencies

Dependencies:

  • beautifulsoup4
  • lxml
  • mecab-python3 (optional; smart matching will be disabled if MeCab is not available)
  • unidic-lite (optional; used for smart matching. Other dictionaries should work but are harder to install)

Usage

Installed:

imajin [options] <search_word> <file_or_directory>

As a script:

python imajin.py [options] <search_word> <file_or_directory>

Positional Arguments

Argument Description
<search_word> The word or phrase you want to find.
<file_or_directory> A single .epub or .mokuro file, or a directory containing them.

Options

Option Description
--match {exact, smart, both} Choose whether to use exact match only search (faster), smart search only (slower, less false positives, matches different conjucations), or the union of both (default: both).
-r, --recursive Recursively search subdirectories if a directory is specified.
--format {text,markdown,md,json} Choose output format (default: text).
-h, --help Show help message and exit.

Examples

Installed

Search for the word "慌ただしい" inside your book collection:

imajin 慌ただしい ./books/

Find exact matches only, searching all subdirectories:

imajin --match=exact -r 慌ただしい ./novel-library/

Get markdown-formatted results:

imajin 慌ただしい ./books/ --format md

Save the results in a JSON file for further processing:

imajin 慌ただしい ./manga-collection/ --format json > results.json

As a script

Search for the word "慌ただしい" inside your book collection:

python imajin.py 慌ただしい ./books/

Find smart matches only, searching all subdirectories:

python imajin.py --match=smart -r 慌ただしい ./novel-library/

Get markdown-formatted results:

python imajin.py 慌ただしい ./books/ --format markdown

Save the results in a JSON file for further processing:

python imajin.py 慌ただしい ./manga-collection/ --format json > results.json

Saving Results

To save your search results to a file, redirect the output:

imajin 慌ただしい ./books/ --format md > examples.md

This method works for all output formats (text, markdown/md, or JSON).


Notes

  • If MeCab is not installed, smart matching will be automatically disabled.

License

This project is released under the CC0 1.0 Universal Public Domain Dedication.

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

imajin-1.4.0b1.tar.gz (19.9 kB view details)

Uploaded Source

Built Distribution

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

imajin-1.4.0b1-py3-none-any.whl (17.7 kB view details)

Uploaded Python 3

File details

Details for the file imajin-1.4.0b1.tar.gz.

File metadata

  • Download URL: imajin-1.4.0b1.tar.gz
  • Upload date:
  • Size: 19.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for imajin-1.4.0b1.tar.gz
Algorithm Hash digest
SHA256 8e9f94db60cc45f2804baae7abefbecda1e0c1749f21017077b9e04067ddbc51
MD5 0d2f44951989ee3acb14021fa8b2a362
BLAKE2b-256 f0b2abb67616f11ab67717baa52585ea66345ed8df70020e3d42987a3a7c38eb

See more details on using hashes here.

Provenance

The following attestation bundles were made for imajin-1.4.0b1.tar.gz:

Publisher: publish-to-pypi-and-test-pypi.yml on YonKuma/imajin.py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file imajin-1.4.0b1-py3-none-any.whl.

File metadata

  • Download URL: imajin-1.4.0b1-py3-none-any.whl
  • Upload date:
  • Size: 17.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for imajin-1.4.0b1-py3-none-any.whl
Algorithm Hash digest
SHA256 497358b885f2a23eb1a8cb56529f1d606697ec57f4ceccedfdfd05d520e0218c
MD5 137c227f60c664d8d4e5a1306c520833
BLAKE2b-256 258b9ca0ca0030919cd2e62f4fe996608cd64101a7d43374c3b575cb39a9e3f1

See more details on using hashes here.

Provenance

The following attestation bundles were made for imajin-1.4.0b1-py3-none-any.whl:

Publisher: publish-to-pypi-and-test-pypi.yml on YonKuma/imajin.py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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