Skip to main content

A high-performance Python search library with intelligent relevance scoring

Project description

LoSearch - Advanced Search Engine Library

Python Version Version License

A high-performance Python search library with intelligent relevance scoring, advanced indexing capabilities, and multilingual support for Persian and English.

Features

  • Fast Document Search - Optimized indexing and retrieval
  • Smart Query Correction - Automatic typo detection and correction
  • Contextual Search - Extract relevant sentences with context
  • Multilingual Support - Persian and English language processing
  • Performance Optimization - Intelligent caching and speed enhancements
  • Accuracy Enhancement - Advanced relevance scoring algorithms
  • Text Analysis - Comprehensive text processing utilities
  • Flexible API - Simple yet powerful interface

Installation

pip install losearch

Quick Start

import losearch as ls

# Initialize search engine
search = ls.LoSearch(enable_optimization=True)

# Add documents
documents = [
    {"id": "1", "title": "MacBook Pro", "content": "High-performance laptop with M2 chip"},
    {"id": "2", "title": "iPhone 15", "content": "Latest smartphone with advanced camera"}
]

search.add_documents(documents)

# Search with automatic optimization
results = search.search("laptop performance")
for result in results:
    print(f"{result['title']} - Score: {result['score']}")

Core Components

Main Classes

  • LoSearch - Primary interface for all search operations
  • LoSearchEngine - Advanced search engine with optimization
  • TextProcessor - Text normalization and language processing
  • ContextExtractor - Intelligent context and sentence extraction
  • SpeedOptimizer - Performance optimization and caching
  • AccuracyEnhancer - Result quality improvement

Search Methods

Basic Search

results = search.search("machine learning", limit=10)

Smart Search with Auto-Correction

result = search.smart_search("machne lerning")  # Automatically corrects typos

Contextual Search

result = search.contextual_search("AI algorithms", mode='advanced')

Contextual Search with Scoring

result = search.contextual_search_with_scores("deep learning", top_sentences=3)

Advanced Usage

Text Analysis

analysis = search.analyze_text("Machine learning and artificial intelligence")
print(f"Language: {analysis['language']}")
print(f"Terms: {analysis['terms']}")

Query Correction

correction = search.fix_query("machne lerning")
print(f"Corrected: {correction['corrected_query']}")
print(f"Confidence: {correction['confidence']}")

Performance Monitoring

stats = search.get_performance_stats()
print(f"Documents indexed: {stats['documents_indexed']}")
print(f"Cache hit rate: {stats['speed_optimizer']['hit_rate']}")

Multilingual Support

LoSearch provides seamless support for both Persian and English with automatic language detection:

# English search
english_results = search.search("machine learning algorithms")

# Persian search  
persian_results = search.search("یادگیری ماشین")

# Mixed language documents
mixed_docs = [
    {"id": "1", "title": "AI Research", "content": "تحقیقات هوش مصنوعی"},
    {"id": "2", "title": "Python Programming", "content": "برنامه نویسی پایتون"}
]

Architecture

src/losearch/
├── core/                    # Core search functionality
│   ├── engine.py           # Main LoSearchEngine class
│   ├── search_engine.py    # Base search engine
│   ├── speed_optimizer.py  # Caching and optimization
│   └── accuracy_enhancer.py # Result accuracy improvement
├── utils/                   # Utility modules
│   ├── text_processor.py   # Text processing and normalization
│   └── context_extractor.py # Context and sentence extraction
└── __init__.py             # Library interface

Performance Features

Speed Optimization

  • Intelligent query caching
  • Index optimization
  • Memory-efficient processing

Accuracy Enhancement

  • Advanced relevance scoring
  • Context-aware ranking
  • Language-specific processing

Use Cases

  • E-commerce product search
  • Document management systems
  • Knowledge base applications
  • Content discovery platforms
  • Research and academic tools
  • Multilingual applications

Documentation

For comprehensive documentation, examples, and advanced usage:

Complete Tutorial

Performance Tips

  1. Enable optimization for better performance:
search = ls.LoSearch(enable_optimization=True)
  1. Use batch operations for multiple documents:
search.add_documents(all_documents)  # Preferred over individual adds
  1. Use advanced mode for better contextual results:
result = search.contextual_search(query, mode='advanced')

Version 1.0.0

What's New

  • Complete rewrite with modular architecture
  • Multi-language support (Persian/English)
  • Smart query correction and auto-completion
  • Contextual search with sentence extraction
  • Performance optimization with intelligent caching
  • Comprehensive text analysis capabilities
  • Enhanced accuracy scoring algorithms

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Support

  • Create an issue on GitHub for bug reports
  • Check the Complete Tutorial for documentation
  • Review examples in the documentation

LoSearch - Making search intelligent and fast

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

locsearch-0.1.0.tar.gz (21.3 kB view details)

Uploaded Source

Built Distribution

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

locsearch-0.1.0-py3-none-any.whl (17.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: locsearch-0.1.0.tar.gz
  • Upload date:
  • Size: 21.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.5

File hashes

Hashes for locsearch-0.1.0.tar.gz
Algorithm Hash digest
SHA256 6174fd1be96d11038ec727ed8317a358a0a5b499737106b9f0def53e65e44d37
MD5 4cc42047e573cda37bac34f5b2077502
BLAKE2b-256 945747653f286a4e33ba4ceea7769ee4ecc748526fb891cd75017519cbc86da4

See more details on using hashes here.

File details

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

File metadata

  • Download URL: locsearch-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 17.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.5

File hashes

Hashes for locsearch-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b701b1e400490347626e5e734d3a48a5cd552f979f5375adc1a5efe433bdce7b
MD5 4d137fa18ea0a4c94b523faa73b4b0f3
BLAKE2b-256 e5764bccc0a59c990a2454e5c74fcc43daf96452295c4bed668adeae55747eb9

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