oyounis19/Smart-Search

Extract filters from search queries using NER and regex techniques.

Jupyter Notebook

0

8 commits

updated Oct 9, 2025

See the code

README

๐Ÿ” Smart Search - OLX Products

A bilingual (Arabic/English) intelligent search application for OLX products using Named Entity Recognition (NER) and natural language processing.

Live Demo

Access the live demo of the application here.

Usecases

Every search system can benefit from this approach, where a user searches in natural language (English or Arabic) and gets relevant results applying the constraints/filters in the query.

Examples

  • ๐Ÿ” Food Delivery & Restaurant Discovery User says: "I'm looking for a spicy chicken pizza without olives" โ€‹System understands: Dish: Pizza Protein: Chicken Profile: Spicy Exclude: Olives
  • โ€‹๐Ÿ›๏ธ E-commerce: โ€‹User says: "Show me 15-inch laptops with at least 16GB RAM for under 25,000 EGP" โ€‹System understands: Category: Laptop Screen Size: 15-inch RAM: >= 16GB Price: < 25000 EGP
  • โ€‹๐Ÿ  Real Estate: โ€‹User says: "I need a 3-bedroom apartment for rent in Zamalek with a balcony" โ€‹System understands: Property Type: Apartment Listing Type: Rent Location: Zamalek Bedrooms: 3 Feature: Balcony
  • โ€‹โœˆ๏ธ Travel & Flight Booking: โ€‹User says: "Find me a non-stop flight from Cairo to London next Friday for two adults" โ€‹System understands: Type: Flight Origin: Cairo Destination: London Date: Next Friday Stops: 0 Passengers: 2

๐ŸŒŸ Features

  • Bilingual Search: Supports both Arabic and English queries
  • Smart Entity Extraction: Automatically extracts brands, models, storage, RAM, colors, prices, and battery information
  • Advanced Filtering: Filter products by multiple criteria simultaneously
  • Natural Language Processing: Uses GLiNER Arabic NER model for intelligent query parsing
  • Interactive Web Interface: Built with Streamlit for an intuitive user experience
  • Real Product Data: Works with scraped OLX Egypt product data

๐Ÿš€ Quick Start

Prerequisites

  • Python 3.8+
  • pip package manager

Installation

  1. Clone the repository

    git clone <repository-url>
    cd Smart-Search
    
  2. Install dependencies

    pip install -r requirements.txt
    
  3. Run the application

    streamlit run main.py
    
  4. Open your browser and navigate to http://localhost:8501

๐Ÿ“Š Dataset

The project uses OLX Egypt product data with the following structure:

  • Products: 9,292 mobile phone listings
  • Features: Title, price, location, brand, description, seller info, images
  • Sources: Data scraped from OLX Egypt marketplace

Data Files

  • data/olx_products_cleaned.csv - Cleaned dataset used by the application
  • data/olx_products.csv - Raw scraped data
  • data/olx_scrapper.py - Web scraping utility for OLX data collection

๐Ÿ”ง Technical Architecture

Core Components

  1. main.py - Streamlit web application interface
  2. utils.py - NER processing and search logic
  3. data/olx_scrapper.py - Data collection utilities
  4. notebooks/eda.ipynb - Exploratory data analysis

NER Model

  • Model: NAMAA-Space/gliner_arabic-v2.1
  • Capabilities: Extracts entities from Arabic and English text
  • Extracted Entities: BRAND, MODEL, STORAGE, RAM, BATTERY, PRICE, COLOR, CONDITION

Search Algorithm

  1. Query Parsing: Extract entities using GLiNER NER model
  2. Entity Normalization: Map Arabic brands to English equivalents
  3. Multi-criteria Filtering: Apply filters based on extracted entities
  4. Regex Enhancement: Additional pattern matching for prices and battery percentages
  5. Result Ranking: Sort by price and relevance

๐Ÿ“ Usage Examples

English Queries

"iPhone 13 Pro 256GB under 70000"
"Samsung A54 less than 15k"
"iPhone 11 128GB white 80% battery"

Arabic Queries

"ุงูŠููˆู† 14 ุจุฑูˆ ุจุทุงุฑูŠู‡ 80%"
"ู‡ูˆุงูˆูŠ P50 ุงู‚ู„ ู…ู† 8 ุงู„ู"
"ุดุงูˆู…ูŠ ุฑูŠุฏู…ูŠ ู†ูˆุช12"

Supported Search Parameters

  • Brand: Apple, Samsung, Huawei, Xiaomi, OPPO, OnePlus, etc.
  • Model: iPhone 13, Galaxy S23, Redmi Note, etc.
  • Storage: 64GB, 128GB, 256GB, 512GB
  • RAM: 4GB, 6GB, 8GB, 12GB
  • Price Limits: "under 50k", "less than 20000", "ุงู‚ู„ ู…ู†"
  • Battery: Minimum battery percentage
  • Colors: White, Black, Blue, etc.
  • Condition: New, Used, Sealed

๐Ÿ› ๏ธ Project Structure

Smart Search/
โ”œโ”€โ”€ main.py                     # Streamlit web application
โ”œโ”€โ”€ utils.py                    # NER processing and search utilities
โ”œโ”€โ”€ requirements.txt            # Python dependencies
โ”œโ”€โ”€ README.md                   # Project documentation
โ”œโ”€โ”€ data/
โ”‚   โ”œโ”€โ”€ olx_products_cleaned.csv # Cleaned product dataset
โ”‚   โ”œโ”€โ”€ olx_products.csv        # Raw scraped data
โ”‚   โ””โ”€โ”€ olx_scrapper.py         # Web scraping utility
โ””โ”€โ”€ notebooks/
    โ””โ”€โ”€ eda.ipynb              # Exploratory data analysis

๐Ÿ” How It Works

  1. Input Processing: User enters search query in Arabic or English
  2. Entity Extraction: GLiNER model identifies relevant entities (brand, model, price, etc.)
  3. Query Enhancement: Regex patterns extract additional information like price limits and battery percentages
  4. Filtering: Multiple filters applied to the dataset based on extracted entities
  5. Results Display: Matched products displayed with images, prices, and details

๐Ÿ“ˆ Performance & Accuracy

  • Search Speed: Instant results through cached model loading
  • Entity Recognition: High accuracy for mobile phone-specific entities
  • Multi-language Support: Seamless Arabic-English processing
  • Scalability: Handles 9K+ product dataset efficiently

๐Ÿ”ฎ Future Improvements

  • Model Fine-tuning: Domain-specific training for improved accuracy
  • Expanded Categories: Support for laptops, tablets, and other electronics
  • Advanced Filters: Location-based search, seller ratings
  • Real-time Data: Live OLX integration
  • Voice Search: Arabic/English voice input support

๐Ÿค Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

๐Ÿ“‹ Dependencies

pandas>=1.5.0          # Data manipulation
streamlit>=1.28.0      # Web interface
regex>=2023.10.0       # Pattern matching
gliner>=0.2.0          # NER model
torch>=2.0.0           # Deep learning framework
transformers>=4.30.0   # Hugging Face transformers

๐Ÿ“„ License

This project is open source and available under the MIT License.

๐Ÿ”— Resources

๐Ÿ“ง Contact

For questions or suggestions, please open an issue in the repository.


Note: For production use, consider fine-tuning the NER model on domain-specific data to improve accuracy for specialized queries.

oyounis19/Smart-Search

Extract filters from search queries using NER and regex techniques.

Jupyter Notebook

0

8 commits

updated Oct 9, 2025

See the code

README

๐Ÿ” Smart Search - OLX Products

A bilingual (Arabic/English) intelligent search application for OLX products using Named Entity Recognition (NER) and natural language processing.

Live Demo

Access the live demo of the application here.

Usecases

Every search system can benefit from this approach, where a user searches in natural language (English or Arabic) and gets relevant results applying the constraints/filters in the query.

Examples

  • ๐Ÿ” Food Delivery & Restaurant Discovery User says: "I'm looking for a spicy chicken pizza without olives" โ€‹System understands: Dish: Pizza Protein: Chicken Profile: Spicy Exclude: Olives
  • โ€‹๐Ÿ›๏ธ E-commerce: โ€‹User says: "Show me 15-inch laptops with at least 16GB RAM for under 25,000 EGP" โ€‹System understands: Category: Laptop Screen Size: 15-inch RAM: >= 16GB Price: < 25000 EGP
  • โ€‹๐Ÿ  Real Estate: โ€‹User says: "I need a 3-bedroom apartment for rent in Zamalek with a balcony" โ€‹System understands: Property Type: Apartment Listing Type: Rent Location: Zamalek Bedrooms: 3 Feature: Balcony
  • โ€‹โœˆ๏ธ Travel & Flight Booking: โ€‹User says: "Find me a non-stop flight from Cairo to London next Friday for two adults" โ€‹System understands: Type: Flight Origin: Cairo Destination: London Date: Next Friday Stops: 0 Passengers: 2

๐ŸŒŸ Features

  • Bilingual Search: Supports both Arabic and English queries
  • Smart Entity Extraction: Automatically extracts brands, models, storage, RAM, colors, prices, and battery information
  • Advanced Filtering: Filter products by multiple criteria simultaneously
  • Natural Language Processing: Uses GLiNER Arabic NER model for intelligent query parsing
  • Interactive Web Interface: Built with Streamlit for an intuitive user experience
  • Real Product Data: Works with scraped OLX Egypt product data

๐Ÿš€ Quick Start

Prerequisites

  • Python 3.8+
  • pip package manager

Installation

  1. Clone the repository

    git clone <repository-url>
    cd Smart-Search
    
  2. Install dependencies

    pip install -r requirements.txt
    
  3. Run the application

    streamlit run main.py
    
  4. Open your browser and navigate to http://localhost:8501

๐Ÿ“Š Dataset

The project uses OLX Egypt product data with the following structure:

  • Products: 9,292 mobile phone listings
  • Features: Title, price, location, brand, description, seller info, images
  • Sources: Data scraped from OLX Egypt marketplace

Data Files

  • data/olx_products_cleaned.csv - Cleaned dataset used by the application
  • data/olx_products.csv - Raw scraped data
  • data/olx_scrapper.py - Web scraping utility for OLX data collection

๐Ÿ”ง Technical Architecture

Core Components

  1. main.py - Streamlit web application interface
  2. utils.py - NER processing and search logic
  3. data/olx_scrapper.py - Data collection utilities
  4. notebooks/eda.ipynb - Exploratory data analysis

NER Model

  • Model: NAMAA-Space/gliner_arabic-v2.1
  • Capabilities: Extracts entities from Arabic and English text
  • Extracted Entities: BRAND, MODEL, STORAGE, RAM, BATTERY, PRICE, COLOR, CONDITION

Search Algorithm

  1. Query Parsing: Extract entities using GLiNER NER model
  2. Entity Normalization: Map Arabic brands to English equivalents
  3. Multi-criteria Filtering: Apply filters based on extracted entities
  4. Regex Enhancement: Additional pattern matching for prices and battery percentages
  5. Result Ranking: Sort by price and relevance

๐Ÿ“ Usage Examples

English Queries

"iPhone 13 Pro 256GB under 70000"
"Samsung A54 less than 15k"
"iPhone 11 128GB white 80% battery"

Arabic Queries

"ุงูŠููˆู† 14 ุจุฑูˆ ุจุทุงุฑูŠู‡ 80%"
"ู‡ูˆุงูˆูŠ P50 ุงู‚ู„ ู…ู† 8 ุงู„ู"
"ุดุงูˆู…ูŠ ุฑูŠุฏู…ูŠ ู†ูˆุช12"

Supported Search Parameters

  • Brand: Apple, Samsung, Huawei, Xiaomi, OPPO, OnePlus, etc.
  • Model: iPhone 13, Galaxy S23, Redmi Note, etc.
  • Storage: 64GB, 128GB, 256GB, 512GB
  • RAM: 4GB, 6GB, 8GB, 12GB
  • Price Limits: "under 50k", "less than 20000", "ุงู‚ู„ ู…ู†"
  • Battery: Minimum battery percentage
  • Colors: White, Black, Blue, etc.
  • Condition: New, Used, Sealed

๐Ÿ› ๏ธ Project Structure

Smart Search/
โ”œโ”€โ”€ main.py                     # Streamlit web application
โ”œโ”€โ”€ utils.py                    # NER processing and search utilities
โ”œโ”€โ”€ requirements.txt            # Python dependencies
โ”œโ”€โ”€ README.md                   # Project documentation
โ”œโ”€โ”€ data/
โ”‚   โ”œโ”€โ”€ olx_products_cleaned.csv # Cleaned product dataset
โ”‚   โ”œโ”€โ”€ olx_products.csv        # Raw scraped data
โ”‚   โ””โ”€โ”€ olx_scrapper.py         # Web scraping utility
โ””โ”€โ”€ notebooks/
    โ””โ”€โ”€ eda.ipynb              # Exploratory data analysis

๐Ÿ” How It Works

  1. Input Processing: User enters search query in Arabic or English
  2. Entity Extraction: GLiNER model identifies relevant entities (brand, model, price, etc.)
  3. Query Enhancement: Regex patterns extract additional information like price limits and battery percentages
  4. Filtering: Multiple filters applied to the dataset based on extracted entities
  5. Results Display: Matched products displayed with images, prices, and details

๐Ÿ“ˆ Performance & Accuracy

  • Search Speed: Instant results through cached model loading
  • Entity Recognition: High accuracy for mobile phone-specific entities
  • Multi-language Support: Seamless Arabic-English processing
  • Scalability: Handles 9K+ product dataset efficiently

๐Ÿ”ฎ Future Improvements

  • Model Fine-tuning: Domain-specific training for improved accuracy
  • Expanded Categories: Support for laptops, tablets, and other electronics
  • Advanced Filters: Location-based search, seller ratings
  • Real-time Data: Live OLX integration
  • Voice Search: Arabic/English voice input support

๐Ÿค Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

๐Ÿ“‹ Dependencies

pandas>=1.5.0          # Data manipulation
streamlit>=1.28.0      # Web interface
regex>=2023.10.0       # Pattern matching
gliner>=0.2.0          # NER model
torch>=2.0.0           # Deep learning framework
transformers>=4.30.0   # Hugging Face transformers

๐Ÿ“„ License

This project is open source and available under the MIT License.

๐Ÿ”— Resources

๐Ÿ“ง Contact

For questions or suggestions, please open an issue in the repository.


Note: For production use, consider fine-tuning the NER model on domain-specific data to improve accuracy for specialized queries.