A high-performance Python search library with intelligent relevance scoring, advanced indexing capabilities, and multilingual support for Persian and English.
Project description
LoSearch - Advanced Search Engine Library
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:
Performance Tips
- Enable optimization for better performance:
search = ls.LoSearch(enable_optimization=True)
- Use batch operations for multiple documents:
search.add_documents(all_documents) # Preferred over individual adds
- 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
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 losearch-0.1.1.tar.gz.
File metadata
- Download URL: losearch-0.1.1.tar.gz
- Upload date:
- Size: 23.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1609bec33f97df9a9321aa4f6abc2e81b51311d1607ab7ad0aa080812338a29c
|
|
| MD5 |
e3a38c886efbc301acc64e5094bed31c
|
|
| BLAKE2b-256 |
2de86f072e924fd4493c773e5fb92661cae60291ed697d0f33688e4adea346d8
|
File details
Details for the file losearch-0.1.1-py3-none-any.whl.
File metadata
- Download URL: losearch-0.1.1-py3-none-any.whl
- Upload date:
- Size: 18.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f3646bbc1fc95b858ea1540cce7a7b36f161aff6e1bd722b7725587db07384ea
|
|
| MD5 |
b10b9bb473762a85681bd5249fd020d7
|
|
| BLAKE2b-256 |
0fc91cc10c2688de8cdbc13a788fd568d687e2c502533fbd0dde02bc3969afdf
|