core.utils.bible_parser
- File:
EuljiroWorship/core/utils/bible_parser.py
- Author:
Benjamin Jaedon Choi - https://github.com/saintbenjamin
- Affiliated Church:
The Eulji-ro Presbyterian Church [대한예수교장로회(통합) 을지로교회]
- Address:
The Eulji-ro Presbyterian Church, 24-10, Eulji-ro 20-gil, Jung-gu, Seoul 04549, South Korea
- Telephone:
+82-2-2266-3070
- E-mail:
euljirochurch [at] G.M.A.I.L. (replace [at] with @ and G.M.A.I.L as you understood.)
- License:
MIT License with Attribution Requirement (see LICENSE file for details); Copyright (c) 2025 The Eulji-ro Presbyterian Church.
Parses Bible reference strings and resolves book name aliases from user input.
This module provides lightweight parsing utilities for converting user-entered Bible reference strings into structured components (book ID, chapter, verse range).
Key responsibilities:
Resolve book name aliases into canonical internal IDs
Parse flexible reference formats such as:
“요 3”
“요한복음 3:16”
“John 3:14-16”
Support chapter-only references and full verse ranges
The parser is intentionally permissive and designed for use in both CLI and GUI contexts.
- core.utils.bible_parser.resolve_book_name(name, lang_map=None, lang_code='ko')[source]
Resolve a user-provided book name to a canonical internal book ID.
This function attempts resolution using multiple strategies:
Direct alias matching from
BOOK_ALIASESReverse matching against canonical IDs
Optional fallback using localized names from
core.config.paths.STANDARD_BOOK_FILE
All comparisons are performed using normalized strings (lowercased, whitespace and dot characters removed).
- Parameters:
name (str) – Raw book name from user input (e.g., “요삼”, “1Jn”, “Genesis”).
lang_map (dict, optional) – Mapping loaded from standard_book.json, structured as { book_id: { “ko”: …, “en”: … } }.
lang_code (str, optional) – Language key used when matching localized names. Defaults to “ko”.
- Returns:
Canonical internal book ID (e.g., “3John”), or None if no match is found.
- Return type:
str | None
- core.utils.bible_parser.parse_reference(text)[source]
Parse a Bible reference string into structured components.
- Supported input formats include:
“<book> <chapter>”
“<book> <chapter>:<verse>”
“<book> <chapter>:<start>-<end>”
Examples
“요 3”
“요한복음 3:16”
“John 3:14-16”
If only a chapter is provided, the verse range is interpreted as the full chapter.
- Parameters:
text (str) – Raw reference string entered by the user.
- Returns:
A tuple of
(book_id, chapter_number, verse_range), whereverse_rangeis(start, end)andend == -1indicates the full chapter.Returns None if parsing or resolution fails.
- Return type:
tuple[str, int, tuple[int, int]] | None