Metadata-Version: 2.4
Name: smartlex-search
Version: 2.1.0
Summary: A hybrid C++20 + Python desktop search engine with BM25F ranking and multimodal extraction
Author: Daksh Goel
License-Expression: LicenseRef-Proprietary
Project-URL: Homepage, https://github.com/dakshgoel2008/SmartLex
Project-URL: Issues, https://github.com/dakshgoel2008/SmartLex/issues
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Programming Language :: C++
Classifier: Operating System :: Microsoft :: Windows
Classifier: Operating System :: MacOS
Classifier: Operating System :: POSIX :: Linux
Classifier: Environment :: X11 Applications :: Qt
Classifier: Topic :: Desktop Environment :: File Managers
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: PyQt5>=5.15.9
Requires-Dist: Pillow>=10.0.0
Requires-Dist: PyMuPDF>=1.23.8
Requires-Dist: watchdog>=3.0.0
Requires-Dist: rapidocr>=3.0.0
Requires-Dist: onnxruntime>=1.17.0
Dynamic: license-file

# Smart Lexical Search Engine

## A powerful desktop search application that searches **inside** PDF and Word documents based on content keywords given by the user.

##  Features

### Core Features

-    **Content-based search**: Find documents by keywords inside them
-    **Multi-format support**: PDF and DOCX files
-    **Fast search**: ~0.02 seconds after initial indexing
-    **Smart ranking**: Results sorted by relevance
-    **Auto-complete**: Suggests keywords dynamically as you type

### Enhanced Features (New)

-    **Standalone Executable**: No Python needed! Run straight from your desktop.
-    **Cross-Platform Package**: Install via `pip install smartlex-search`
-    **Modern UI**: Clean, beautifully designed Qt interface with dynamic status indicators.
-    **Parallel processing**: Uses multithreading for blazingly fast background indexing.
-    **Automated Setup**: Completely self-contained, handles NLTK and indexing without scripts!

---

##  Installation

### Method 1: The Standalone App (No Python Required!)

1. Go to the **Releases** page of this GitHub repository.
2. Download `SmartLex.exe`.
3. Double-click it! The app will automatically handle indexing and open right up.

### Method 2: Terminal Package (For Developers)

Requires Python 3.10–3.14 on Windows (x64), macOS (Intel or Apple Silicon) or Linux (x64). Prebuilt wheels mean no compiler is needed.

1. **Install with [pipx](https://pipx.pypa.io)** (recommended: isolated, and the command works from anywhere)
```bash
pipx install smartlex-search
```
   or with plain pip: `pip install smartlex-search`

2. **Run it**
```bash
smartlex            # desktop app
smartlex-cli -d ~/Documents    # terminal mode
```

3. **Update later**
```bash
pipx upgrade smartlex-search
```

*(To work on the source, clone the repo and run `pip install -e .`)*

---

##  Usage

### First Run (Indexing)

Whether you use the `.exe` or the `smartlex` terminal command, the application will automatically detect if it is your first time running it. It will launch a background scanner that sweeps your drives for PDFs and Word documents, extracts their keywords using advanced NLP, and builds your local index.

**First run**: Depends on the number of files (usually a few minutes)
**Subsequent runs**: Instant! The UI will pop open in less than a second.

### Regular Usage

1. Type keywords in the modern search bar (e.g., "machine learning").
2. The dynamic auto-complete will suggest words based specifically on the contents of your own files!
3. Press Enter or click Search.
4. Click or double-click any beautifully formatted result to instantly open the document.

### Keyboard Shortcuts

-   `Enter`: Search / Open selected document
-   `Tab`: Switch between search bar and results
-   `↑/↓`: Navigate through results
-   `Ctrl+F`: Focus the search bar
-   `Esc`: Clear search / Close application

---

### Searching Images

Screenshots, photos and scans are searchable by the text visible inside them.

- **Instant metadata.** Size, format, PNG text chunks, EXIF, XMP and a sidecar `photo.txt` or `photo.caption` are indexed immediately.
- **OCR in the background.** Text inside images is read by [RapidOCR](https://github.com/RapidAI/RapidOCR) after all documents are indexed. The progress bar shows "Reading text in images". You can search while it runs.
- **Once per image.** Each picture is read only once. It is read again only when the file changes or a different OCR engine is installed. Moved files and identical copies are not read again.
- **Unusual images.** Rotated phone photos, transparent logos, 16-bit images, multi-page TIFF scans and long scrolling screenshots are handled. Blank, tiny or extremely large images are skipped.

RapidOCR is installed with the package. Without it, SmartLex falls back to the `tesseract` command if it is on your `PATH`, and otherwise indexes image metadata only.

##  How It Works

### Architecture

```
User Query → RAKE Extraction → Keyword Matching → Ranking → Results
                                       ↑
                Document Index ← Multithreading ← Automated File Scanner
```

### Step-by-Step Process

#### 1. **File Collection** (First Run Only)
-   The internal Python scanner recursively sweeps all connected system drives.
-   It strictly filters out system folders (`Windows`, `Program Files`, `.git`) for maximum speed.
-   It collects all PDF and DOCX file paths.

#### 2. **Parallel Indexing** (First Run Only)
-   Multiple background threads parse the documents simultaneously to maximize CPU efficiency.

#### 3. **Keyword Extraction** (RAKE Algorithm)
```text
Input: "Machine learning algorithms use neural networks"
        ↓
Remove stopwords: "Machine learning algorithms use neural networks"
        ↓
Extract phrases: ["machine learning algorithms", "neural networks"]
        ↓
Split to words: ["machine", "learning", "algorithms", "neural", "networks"]
```

#### 4. **Index Storage**
The system builds an ultra-fast lookup dictionary (`output.json`):
```json
{
    "C:/docs/paper1.pdf": ["machine", "learning", "neural", "network"],
    "C:/docs/paper2.pdf": ["algorithm", "optimization", "training"]
}
```

#### 5. **Search Process**
```text
User types: "neural network training"
        ↓
Extract keywords: ["neural", "network", "training"]
        ↓
Find matching documents:
  paper1.pdf: 2 matches (neural, network)
  paper2.pdf: 1 match (training)
        ↓
Rank by relevance:
  1. paper1.pdf (score: 2)
  2. paper2.pdf (score: 1)
```

---

##  Project Structure

```text
SmartLex/
│
├── pyproject.toml         # Package configuration
├── run.py                 # PyInstaller entry point
│
├── src/smartlex/
│   ├── main.py            # Core application entry
│   ├── core/              # NLP, parsing, and indexing logic
│   └── gui/               # PyQt5 interface and background threads
│
├── requirements.txt
├── config.json
└── README.md
```

---

## Releasing

Every push runs the tests on Windows, macOS and Linux (`.github/workflows/ci.yml`).
To publish a new version to PyPI:

1. Bump `version` in `pyproject.toml` (e.g. `2.1.1`) and commit it.
2. Tag and push:
```bash
git tag v2.1.1
git push origin main --tags
```

The release workflow checks the tag matches the version, runs all tests, builds and tests wheels for every supported platform, and publishes only if everything passes. It then creates a GitHub Release with the same files. To try a release without publishing, run the "Release" workflow manually from the Actions tab.

## Reference

-   [Base Paper / Reference PDF](https://drive.google.com/file/d/10f3bUmaTRzAZ2jOq6oWFu0ilP6Q6dyJx/view?usp=sharing)

---

## Sample Screenshots
- ### Initial Window
![Initial Window](images/Initial_Window.png)

### Output Window

![Output Window](images/Output_Window.png)

### Future enhancement
- Working on adding support for additional file types such as TXT, CSV, XLSX, PPTX, HTML, etc.
- Currently working on similar functionality for images, audios etc.
