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.2.tar.gz (21.4 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.2-py3-none-any.whl (17.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: locsearch-0.1.2.tar.gz
  • Upload date:
  • Size: 21.4 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.2.tar.gz
Algorithm Hash digest
SHA256 bf5d9764ede0077b6f11e10d1a28668c3858c3db9166b126d0e0c497c76c3fce
MD5 4fa6ed02036575cdada789eb8920998b
BLAKE2b-256 0f409f16b2eb07578ec0b94d1e3bcfec882acff3e5ed2a0c5a0d5d9e52222044

See more details on using hashes here.

File details

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

File metadata

  • Download URL: locsearch-0.1.2-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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 1174a134825a8536cf46c89837eece1ab0e97d50bda2dfe37fe0dc7360a6eb83
MD5 0f663a39d08496ba7768a78b63635c22
BLAKE2b-256 8e5c3f3f0df3f63f09f12eae8e338be6533ac05f93d0ee082c22f36c08cda74b

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