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 git+https://github.com/yourusername/bible-search.git

# Or clone and install locally
git clone https://github.com/yourusername/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.0.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.0-py3-none-any.whl (16.0 kB view details)

Uploaded Python 3

File details

Details for the file adv_bible_search-0.1.0.tar.gz.

File metadata

  • Download URL: adv_bible_search-0.1.0.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.0.tar.gz
Algorithm Hash digest
SHA256 f91ea27c889f00de85d97ff7378b0cbc620e7bbb2cb12a9b3d50649148596527
MD5 2904a2a125bd2f3a08cddf541dacdf55
BLAKE2b-256 532b7b3cc03f8e4076ac67e44c9cc89a3792856cc339d64abd6c60d6ceeddead

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for adv_bible_search-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b38fd37a7f800762bc75a117b487c64961f530facd340750d9ef46d6a6f9c8b4
MD5 6f373f13b16a1a35a93e14109891a6be
BLAKE2b-256 efd0723b08e6d277617bd5b61e5c7770d2df60e45e032cbddc80b32f0fd041d5

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