Search tool for Japanese text in EPUB and Mokuro files
Project description
imajin.py
imajin.py is a search tool for .epub and .mokuro files, designed to help you find example sentences in your Japanese books and manga.
Index
Features
- Search across unencrypted
.epub(ebooks) and.mokuro(manga) files - Supports fuzzy matching for Japanese conjugations (optional)
- Supports searching individual words or phrases
- Structured output: text, markdown, or JSON
- Recursively search directories of books and manga
- 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.
-
Install Python 3.9+ if not allready installed
-
Install imajin using pip:
pip install imajin
You should be all set up to use
imajindirectly from the command line.
Download and install script
Not recommended, because it's harder to update.
-
Install Python 3.9+ if not already installed.
-
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 -
Install dependencies:
pip install -r requirements.txt
You can now use
imajin.pyas a python script. For example, if you're in the source directory, you can usepython imajin.py -r 蹴散らす ~/Documents/Manga, but you'll need to use a qualified path to the files you want to search -
(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; fuzzy matching will be disabled if MeCab is not available)
- unidic-lite (optional; used for fuzzy 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 |
|---|---|
--no-fuzzy |
Disable fuzzy matching (only exact matches). |
-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 --no-fuzzy -r 慌ただしい ./novel-library/
Get markdown-formatted results:
imajin 慌ただしい ./books/ --format markdown
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 exact matches only, searching all subdirectories:
python imajin.py --no-fuzzy -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, fuzzy matching will be automatically disabled.
License
This project is released under the CC0 1.0 Universal Public Domain Dedication.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file imajin-1.2.0.tar.gz.
File metadata
- Download URL: imajin-1.2.0.tar.gz
- Upload date:
- Size: 15.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cb2a77db28bef1c9abe0e1b8e9b9452c26455f2037ff763da29f5363ede4a329
|
|
| MD5 |
6ccec39f252d241e56f77da32f3386c3
|
|
| BLAKE2b-256 |
668192f71d8b813052e8a515f62ed90c136756c806004a7819641ad3976f704e
|
File details
Details for the file imajin-1.2.0-py3-none-any.whl.
File metadata
- Download URL: imajin-1.2.0-py3-none-any.whl
- Upload date:
- Size: 15.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
62935592b527402f9301b49c94de55d0b63836b41737c1b0a034bbe80dad9cb6
|
|
| MD5 |
0ed2fee9b8b99b14c59dbbfd040c0a92
|
|
| BLAKE2b-256 |
757126bc9c62b561d06339efd4d1e57796b70e1591316bd1299867dbac87869a
|