Skip to main content

Advanced Bible Search Library with fuzzy and semantic search capabilities

Project description

Advanced Bible Search Library

Python Version License: MIT GitHub Issues

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

  1. Clone/download the repository
  2. 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 library
  • database.py: SQLite database operations with FTS5
  • fuzzy_search.py: Fuzzy text matching with RapidFuzz
  • semantic_search.py: Semantic similarity search with sentence-transformers
  • search_cli.py: Command-line interface

Initial Setup

When first running the library, it will:

  1. Create an SQLite database
  2. Import Bible data from JSON files
  3. Create necessary database tables and indexes
  4. 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

  1. Exact Search: Finds exact text matches using SQLite's FTS5 extension
  2. Fuzzy Search: Finds approximate matches, helpful for typos or spelling variations
  3. Semantic Search: Finds verses with similar meaning regardless of specific wording
  4. 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

adv_bible_search-0.1.1.tar.gz (13.5 kB view details)

Uploaded Source

Built Distribution

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

adv_bible_search-0.1.1-py3-none-any.whl (16.0 kB view details)

Uploaded Python 3

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

Hashes for adv_bible_search-0.1.1.tar.gz
Algorithm Hash digest
SHA256 b16b69b1066ce6abdf1b3c272bbb7ef10a52279efaa45cf90ac585198286f404
MD5 cfeaffb176b376afe8c1b14f88f84b20
BLAKE2b-256 9168409c620c4297b551159152620757fb0cc304e5f144400ee7f9b0a6c54297

See more details on using hashes here.

File details

Details for the file adv_bible_search-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for adv_bible_search-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 6703f9771e0bc10f9ca68af31b2bdab93478360d85e6dbe198fe5d335e12c5ec
MD5 7bfa341edef801e9fa1ff9af5b8b6bdb
BLAKE2b-256 21bf1be4a24f9a73f3cae8f89bc33f73ffe5d0b45c8550fba8637828c02b6fdc

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