Metadata-Version: 2.4
Name: son_logic_engine
Version: 0.2.5
Summary: High-performance Rust search engine for RAG systems
Author-email: Son <sonbuwin@gmail.com>
Requires-Python: >=3.7
Description-Content-Type: text/markdown; charset=UTF-8; variant=GFM

# son-logic-engine

High-performance search filter for RAG systems written in Rust, designed for speed and accuracy with Vietnamese text.

## 🚀 Features
- **Rust Core:** Blazing fast processing for large datasets.
- **Polymorphic Input:** Supports `List[str]`, `Dict`, or nested `List[Dict]`.
- **Field Filtering:** Optimize search speed by targeting specific columns.
- **Unicode Support:** Native handling of Vietnamese characters and custom character mappings.

## 🛠 Installation
```bash
pip install son-logic-engine
```

## 📖 API Reference

### 1. `load_mapping(path: str)`
Loads the character weight mapping from a JSON file. This is required for the search logic to compute character-based relevance.
```python
import son_logic_engine as slg
mapping = slg.load_mapping('path/to/mapping.json')
```

### 2. `loc(query: str, database: Any, mapping: dict, field_name: str = None)`
The core search function. Returns a list of records (as JSON strings) ranked by relevance to the query.
- `query`: The search term.
- `database`: Your data (List of strings or List of Dictionaries).
- `mapping`: The mapping object from `load_mapping`.
- `field_name`: (Optional) The specific key in your dictionary to search within.

### Python-side Utility: `slg.print(raw_results: list)`
This is a *notebook-defined helper function* designed to pretty-print the JSON results returned by `loc` in a readable format within a Python environment. It is not part of the core Rust library distributed via PyPI.

```python
# Example of how you might define and use a similar helper in Python
import json

def slg_print_helper(raw_results):
    if not raw_results:
        print("Không tìm thấy kết quả nào.")
        return
    for i, item_json in enumerate(raw_results):
        try:
            data_obj = json.loads(item_json)
            print(f"[Hạng {i+1}]")
            print(json.dumps(data_obj, indent=4, ensure_ascii=False))
            print("---" * 10)
        except Exception as e:
            print(f"Lỗi khi giải mã kết quả thứ {i+1}: {e}")

# Assuming `slg` is imported and `raw_results` are from `slg.loc`
# slg_print_helper(raw_results)
```

## 🔒 Security & Contact
The underlying search algorithm and character weight logic are proprietary. For access to standard mapping files or custom integration, please contact:

📩 **Email:** sonbuwin@gmail.com

