Advanced Bible Search Library with fuzzy and semantic search capabilities
Project description
Advanced Bible Search Library
A comprehensive Bible text search library that combines multiple advanced search techniques to provide powerful, flexible searching of biblical texts.
Features
- Fast Text Search: Using SQLite with FTS5 for high-performance exact text matching
- Fuzzy Search: Powered by RapidFuzz for approximate string matching
- Semantic Search: Using sentence-transformers for meaning-based searches
- Topic Search: Find verses related to specific themes or concepts
- Multiple Translations: Support for different Bible translations (KJV, ASV included)
- Categorized Results: Results organized by book and chapter
- Scored Results: Relevance scoring for search results
Requirements
- Python 3.7+
- Libraries: SQLite, RapidFuzz, sentence-transformers, etc. (see requirements.txt)
Installation
From GitHub
# Install directly from GitHub
pip install adv-bible-search
# Or install directly from GitHub
pip install git+https://github.com/siroosab/bible-search.git
# Or clone and install locally
git clone https://github.com/siroosab/bible-search.git
cd bible-search
pip install -e .
From Source
- Clone/download the repository
- Install the required dependencies:
pip install -r requirements.txt
Data Structure
The library expects Bible data in JSON format with the following structure:
{
"books": [
{
"name": "Genesis",
"chapters": [
{
"chapter": 1,
"name": "Genesis 1",
"verses": [
{
"verse": 1,
"chapter": 1,
"name": "Genesis 1:1",
"text": "In the beginning God created the heaven and the earth."
},
// More verses...
]
},
// More chapters...
]
},
// More books...
]
}
Usage
Command Line Interface
The library includes a command-line interface for searching:
# Basic search (uses all search methods)
python search_cli.py "creation"
# Specify search type
python search_cli.py --type fuzzy "creation"
python search_cli.py --type semantic "love your neighbor"
python search_cli.py --type topic "forgiveness"
# Limit number of results
python search_cli.py --limit 10 "light"
# Show relevance scores
python search_cli.py --scores "faith"
# Output in JSON format
python search_cli.py --json "hope"
Python API
from bible_search import BibleSearcher, SearchType
# Initialize the searcher
searcher = BibleSearcher(data_dir="bible_data", db_path="bible_search.db")
searcher.initialize()
# Basic search (uses all search methods)
results = searcher.search("creation")
# Specify search type
results = searcher.search("creation", search_type=SearchType.FUZZY)
results = searcher.search("love your neighbor", search_type=SearchType.SEMANTIC)
results = searcher.search("forgiveness", search_type=SearchType.TOPIC)
# Control other parameters
results = searcher.search(
query="light",
search_type=SearchType.ALL,
limit=10,
categorize=True,
include_scores=True
)
# Available search types:
# - SearchType.EXACT: Exact text matching using SQLite FTS5
# - SearchType.FUZZY: Approximate string matching using RapidFuzz
# - SearchType.SEMANTIC: Meaning-based search using sentence-transformers
# - SearchType.TOPIC: Theme/concept search (specialized semantic search)
# - SearchType.ALL: Combine all search methods (default)
Module Structure
bible_search.py: Main interface for the search librarydatabase.py: SQLite database operations with FTS5fuzzy_search.py: Fuzzy text matching with RapidFuzzsemantic_search.py: Semantic similarity search with sentence-transformerssearch_cli.py: Command-line interface
Initial Setup
When first running the library, it will:
- Create an SQLite database
- Import Bible data from JSON files
- Create necessary database tables and indexes
- Generate semantic embeddings (this may take some time on first run)
The semantic embeddings are saved to disk for faster subsequent runs.
Search Types Explained
- Exact Search: Finds exact text matches using SQLite's FTS5 extension
- Fuzzy Search: Finds approximate matches, helpful for typos or spelling variations
- Semantic Search: Finds verses with similar meaning regardless of specific wording
- Topic Search: Specialized semantic search focused on themes and concepts
Performance Considerations
- Semantic search requires creating embeddings which can be time-consuming on first run
- The SQLite database provides efficient storage and fast exact searches
- For very large datasets, consider using a more robust search engine like Elasticsearch
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 adv_bible_search-0.1.1.tar.gz.
File metadata
- Download URL: adv_bible_search-0.1.1.tar.gz
- Upload date:
- Size: 13.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b16b69b1066ce6abdf1b3c272bbb7ef10a52279efaa45cf90ac585198286f404
|
|
| MD5 |
cfeaffb176b376afe8c1b14f88f84b20
|
|
| BLAKE2b-256 |
9168409c620c4297b551159152620757fb0cc304e5f144400ee7f9b0a6c54297
|
File details
Details for the file adv_bible_search-0.1.1-py3-none-any.whl.
File metadata
- Download URL: adv_bible_search-0.1.1-py3-none-any.whl
- Upload date:
- Size: 16.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6703f9771e0bc10f9ca68af31b2bdab93478360d85e6dbe198fe5d335e12c5ec
|
|
| MD5 |
7bfa341edef801e9fa1ff9af5b8b6bdb
|
|
| BLAKE2b-256 |
21bf1be4a24f9a73f3cae8f89bc33f73ffe5d0b45c8550fba8637828c02b6fdc
|