Skip to content

mergen-hukuk/search-engine

Repository files navigation

Legal Document Search Engine

A sophisticated search engine for legal documents using various NLP techniques including BERT embeddings, keyword extraction, and vector similarity search.

Project Structure

.
├── docs/                   # Documents to be processed (JSON format, has HTML)
├── md_docs/                # Markdown documents (converted from HTML)
├── embeddings/             # Embeddings generated by BERT and Ollama
├── bert_pipeline.py        # BERT embedding generation pipeline
├── keyword_pipeline.py     # Keyword extraction using YAKE
├── md_convert.py          # HTML to Markdown converter using markitdown
├── ollama_embed.py        # Document embedding using Ollama (snowflake-arctic-embed2)
├── ollama_kanun.py        # Law parsing utility using ollama (llama3.2:3b)
├── milvus_spark.ipynb     # Milvus vector database integration
├── Dockerfile             # Container configuration
├── Makefile              # Build automation
└── requirements.txt       # Python dependencies

Features

  • Document conversion from HTML to Markdown
  • BERT-based document embeddings
  • Keyword extraction using YAKE
  • Vector similarity search using Milvus
  • Law parsing and extraction
  • Spark integration for distributed processing

Prerequisites

  • Python 3.10+
  • Docker
  • Apache Spark
  • Ollama
  • Milvus

Installation

  1. Create a virtual environment:
make venv
  1. Install dependencies:
make install
  1. Build and run Docker container:
make dcr

Usage

Converting Documents

Convert HTML documents to Markdown format:

python md_convert.py

Generating Embeddings

Generate document embeddings using BERT (using sparknlp) or Ollama (locally using snowflake-arctic-embed2):

python bert_pipeline.py  # For BERT embeddings
python ollama_embed.py   # For Ollama embeddings

Keyword Extraction

Extract keywords from documents using YAKE (using sparknlp):

python keyword_pipeline.py

Law Parsing

Parse and extract law references using ollama (llama3.2:3b):

python ollama_kanun.py

Dependencies

  • markitdown
  • sparknlp
  • pyspark
  • numpy
  • milvus
  • pymilvus
  • ollama

License

MIT License

Copyright (c) 2025 Muhammed Rüşen Birben

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •