Skip to main content

Advanced Legal Document Semantic Chunking System

Project description

SmartChunkLLM

Türkçe hukuki belgeler için gelişmiş semantik metin parçalama ve analiz sistemi.

🚀 Kurulum

Gereksinimler

  • Python 3.8+
  • pip veya conda

Temel Kurulum

# Projeyi klonlayın
git clone <repository-url>
cd smartchunkllm

# Sanal ortam oluşturun (önerilen)
python -m venv venv
source venv/bin/activate  # Linux/Mac
# veya
venv\Scripts\activate     # Windows

# Bağımlılıkları yükleyin
pip install -r requirements.txt

# Paketi geliştirme modunda yükleyin
pip install -e .

İsteğe Bağlı Bağımlılıklar

# OCR desteği için
pip install "smartchunkllm[ocr]"

# Web arayüzü için
pip install "smartchunkllm[web]"

# Türkçe NLP desteği için
pip install "smartchunkllm[turkish]"

# Tüm özellikler için
pip install "smartchunkllm[all]"

📖 Kullanım

Komut Satırı Arayüzü (CLI)

PDF Belgelerini İşleme

# Temel PDF işleme
smartchunk process document.pdf

# OCR ile taranmış PDF işleme
smartchunk process document.pdf --ocr

# Düzen algılama ile
smartchunk process document.pdf --layout-detection

# Çıktıyı JSON formatında kaydetme
smartchunk process document.pdf --output results.json --format json

# Özel parça boyutu ile
smartchunk process document.pdf --chunk-size 1000 --overlap 200

Ham Metin İşleme

# Metin dosyasını parçalama
smartchunk chunk-text input.txt --output chunks.json

# Farklı strateji ile
smartchunk chunk-text input.txt --strategy semantic --quality high

Sistem Bilgileri

# Sistem durumunu kontrol etme
smartchunk info

# Kullanım örneklerini görme
smartchunk examples

Python API

Temel Kullanım

from smartchunkllm import SmartChunkLLM, ChunkingStrategy, QualityLevel

# SmartChunkLLM örneği oluşturma
chunker = SmartChunkLLM(
    strategy=ChunkingStrategy.SEMANTIC,
    quality_level=QualityLevel.HIGH,
    chunk_size=800,
    overlap=150
)

# PDF belgesi işleme
result = chunker.process_pdf("document.pdf")

# Sonuçları görüntüleme
for chunk in result.chunks:
    print(f"Chunk {chunk.id}: {chunk.text[:100]}...")
    print(f"Kalite Skoru: {chunk.quality_score}")
    print(f"Güven Düzeyi: {chunk.confidence}")
    print("---")

Gelişmiş Kullanım

from smartchunkllm import (
    SmartChunkLLM, 
    LLMProvider, 
    EmbeddingModel,
    ClusteringAlgorithm
)

# Gelişmiş yapılandırma
chunker = SmartChunkLLM(
    strategy=ChunkingStrategy.HYBRID,
    quality_level=QualityLevel.PREMIUM,
    llm_provider=LLMProvider.OPENAI,
    embedding_model=EmbeddingModel.OPENAI_ADA_002,
    clustering_algorithm=ClusteringAlgorithm.HIERARCHICAL,
    enable_ocr=True,
    enable_layout_detection=True,
    language="tr"
)

# Metin işleme
text = "Uzun hukuki metin..."
result = chunker.process_text(text)

# Kalite metrikleri
print(f"Ortalama Kalite: {result.metrics.average_quality}")
print(f"İşlem Süresi: {result.metrics.processing_time}s")
print(f"Bellek Kullanımı: {result.metrics.memory_usage}MB")

Hukuki Belge Analizi

from smartchunkllm.legal import LegalAnalyzer

# Hukuki analiz
analyzer = LegalAnalyzer()
analysis = analyzer.analyze_document("contract.pdf")

# Sonuçları görüntüleme
print(f"Belge Türü: {analysis.document_type}")
print(f"Tespit Edilen Maddeler: {len(analysis.articles)}")
print(f"Anahtar Terimler: {analysis.key_terms}")

Yapılandırma

Ortam Değişkenleri

# API anahtarları
export OPENAI_API_KEY="your-openai-key"
export ANTHROPIC_API_KEY="your-anthropic-key"
export COHERE_API_KEY="your-cohere-key"

# Ollama yapılandırması
export OLLAMA_HOST="http://localhost:11434"

# Loglama seviyesi
export SMARTCHUNK_LOG_LEVEL="INFO"

# Bellek limiti (MB)
export SMARTCHUNK_MEMORY_LIMIT="2048"

Yapılandırma Dosyası

# config.yaml
chunking:
  strategy: "semantic"
  chunk_size: 800
  overlap: 150
  quality_level: "high"

llm:
  provider: "openai"
  model: "gpt-4"
  temperature: 0.1
  max_tokens: 2000

embedding:
  model: "openai-ada-002"
  batch_size: 100

processing:
  enable_ocr: true
  enable_layout_detection: true
  language: "tr"
  max_workers: 4

logging:
  level: "INFO"
  format: "structured"
  file: "smartchunk.log"

🔧 Özellikler

✨ Temel Özellikler

  • Semantik Parçalama: İçerik anlamına göre akıllı metin bölme
  • Çoklu Strateji: Sabit boyut, semantik, hibrit parçalama
  • Kalite Değerlendirme: Otomatik parça kalitesi analizi
  • Türkçe Desteği: Özelleşmiş Türkçe NLP işlemleri

📄 PDF İşleme

  • OCR Desteği: Taranmış belgeleri metin çıkarma
  • Düzen Algılama: Sayfa düzenini koruyarak işleme
  • Font Analizi: Metin biçimlendirme bilgilerini koruma
  • Tablo Çıkarma: Yapılandırılmış veri tespiti

🤖 AI/ML Entegrasyonu

  • Çoklu LLM Desteği: OpenAI, Anthropic, Cohere, Ollama
  • Embedding Modelleri: Çeşitli gömme modeli seçenekleri
  • Kümeleme: Benzer içerikleri gruplandırma
  • Kalite Analizi: AI destekli kalite değerlendirme

⚖️ Hukuki Belge Desteği

  • Belge Türü Tespiti: Sözleşme, kanun, yönetmelik analizi
  • Madde Çıkarma: Hukuki maddeleri otomatik tespit
  • Anahtar Terim Analizi: Hukuki terim vurgulama
  • Referans Takibi: Çapraz referans analizi

🔍 Monitoring ve Profiling

  • Performans İzleme: Gerçek zamanlı performans metrikleri
  • Bellek Yönetimi: Otomatik bellek optimizasyonu
  • Loglama: Yapılandırılmış günlük kayıtları
  • Hata Yönetimi: Kapsamlı hata yakalama ve raporlama

📊 Çıktı Formatları

JSON Çıktısı

{
  "chunks": [
    {
      "id": "chunk_001",
      "text": "Metin içeriği...",
      "metadata": {
        "page_number": 1,
        "position": {"x": 100, "y": 200},
        "font_info": {"family": "Arial", "size": 12},
        "quality_score": 0.95,
        "confidence": 0.88
      }
    }
  ],
  "metrics": {
    "total_chunks": 25,
    "average_quality": 0.92,
    "processing_time": 15.3,
    "memory_usage": 256
  }
}

Markdown Çıktısı

# Belge Analiz Sonuçları

## Chunk 1
**Kalite Skoru**: 0.95  
**Sayfa**: 1  
**Pozisyon**: (100, 200)

Metin içeriği...

---

## Chunk 2
...

🛠️ Geliştirme

Test Çalıştırma

# Tüm testleri çalıştırma
python -m pytest tests/

# Belirli bir test dosyası
python -m pytest tests/test_chunking.py

# Kapsam raporu ile
python -m pytest --cov=smartchunkllm tests/

Kod Kalitesi

# Kod formatı kontrolü
black smartchunkllm/
flake8 smartchunkllm/

# Tip kontrolü
mypy smartchunkllm/

📝 Lisans

MIT License - Detaylar için LICENSE dosyasına bakınız.

🤝 Katkıda Bulunma

  1. Projeyi fork edin
  2. Feature branch oluşturun (git checkout -b feature/amazing-feature)
  3. Değişikliklerinizi commit edin (git commit -m 'Add amazing feature')
  4. Branch'inizi push edin (git push origin feature/amazing-feature)
  5. Pull Request oluşturun

📞 Destek

Sorularınız için:

  • GitHub Issues
  • Dokümantasyon: [Link]
  • E-posta: [E-posta adresi]

SmartChunkLLM - Türkçe hukuki belgeler için akıllı metin analizi 🚀

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

smartchunkllm-0.1.7.tar.gz (149.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

smartchunkllm-0.1.7-py3-none-any.whl (160.0 kB view details)

Uploaded Python 3

File details

Details for the file smartchunkllm-0.1.7.tar.gz.

File metadata

  • Download URL: smartchunkllm-0.1.7.tar.gz
  • Upload date:
  • Size: 149.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.7

File hashes

Hashes for smartchunkllm-0.1.7.tar.gz
Algorithm Hash digest
SHA256 cf917a524c26a029f507bb85ef87bde651981f17000dca4f7af6f43cbaba37b3
MD5 783a7d2c171dac9e0f66abd01c3ad847
BLAKE2b-256 6a4e40e8404d102e46c0265686c56a380601f73794df83236e058fdb05c9aa4d

See more details on using hashes here.

File details

Details for the file smartchunkllm-0.1.7-py3-none-any.whl.

File metadata

  • Download URL: smartchunkllm-0.1.7-py3-none-any.whl
  • Upload date:
  • Size: 160.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.7

File hashes

Hashes for smartchunkllm-0.1.7-py3-none-any.whl
Algorithm Hash digest
SHA256 cda4ccb875c987888750a7e45eaf00e7a76296c91d1df130f0741793f21f8757
MD5 b871b757c2257c5b791cb93de758e667
BLAKE2b-256 c7692bf070e4a6901283edeb98619b7c7e501bc961b433d35f5c574bc0858265

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page