Metadata-Version: 2.4
Name: smartchunkllm
Version: 0.1.5
Summary: Advanced Legal Document Semantic Chunking System
Home-page: https://github.com/smartchunkllm/smartchunkllm
Download-URL: https://github.com/smartchunkllm/smartchunkllm/archive/v1.0.0.tar.gz
Author: SmartChunkLLM Team
Author-email: SmartChunkLLM Team <info@smartchunkllm.com>
Maintainer: SmartChunkLLM Team
Maintainer-email: SmartChunkLLM Team <info@smartchunkllm.com>
License: MIT
Project-URL: Homepage, https://github.com/smartchunkllm/smartchunkllm
Project-URL: Repository, https://github.com/smartchunkllm/smartchunkllm
Project-URL: Documentation, https://smartchunkllm.readthedocs.io/
Project-URL: Bug Reports, https://github.com/smartchunkllm/smartchunkllm/issues
Project-URL: Changelog, https://github.com/smartchunkllm/smartchunkllm/blob/main/CHANGELOG.md
Keywords: legal,documents,semantic,chunking,nlp,ai,llm,pdf,turkish,law,embedding,clustering,transformers,ollama,openai,anthropic
Platform: any
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Legal Industry
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Text Processing :: Linguistic
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Topic :: Office/Business
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: numpy>=1.21.0
Requires-Dist: scipy>=1.7.0
Requires-Dist: pandas>=1.3.0
Requires-Dist: PyPDF2>=3.0.0
Requires-Dist: pdfplumber>=0.7.0
Requires-Dist: pymupdf>=1.23.0
Requires-Dist: pdfminer.six>=20220524
Requires-Dist: pytesseract>=0.3.10
Requires-Dist: Pillow>=9.0.0
Requires-Dist: opencv-python>=4.5.0
Requires-Dist: transformers>=4.20.0
Requires-Dist: sentence-transformers>=2.2.0
Requires-Dist: scikit-learn>=1.1.0
Requires-Dist: hdbscan>=0.8.28
Requires-Dist: umap-learn>=0.5.6
Requires-Dist: openai>=1.0.0
Requires-Dist: anthropic>=0.7.0
Requires-Dist: ollama>=0.1.7
Requires-Dist: pydantic>=2.0.0
Requires-Dist: tqdm>=4.64.0
Requires-Dist: click>=8.0.0
Requires-Dist: rich>=12.0.0
Requires-Dist: loguru>=0.6.0
Requires-Dist: pyyaml>=6.0
Requires-Dist: joblib>=1.1.0
Requires-Dist: requests>=2.28.0
Requires-Dist: httpx>=0.24.0
Requires-Dist: typing-extensions>=4.0.0
Provides-Extra: turkish
Requires-Dist: zeyrek>=0.1.2; extra == "turkish"
Requires-Dist: turkish-stemmer>=1.0.0; extra == "turkish"
Provides-Extra: layout
Requires-Dist: layoutparser>=0.3.4; extra == "layout"
Requires-Dist: detectron2>=0.6; python_version < "3.11" and extra == "layout"
Requires-Dist: torch>=1.12.0; extra == "layout"
Requires-Dist: torchvision>=0.13.0; extra == "layout"
Provides-Extra: performance
Requires-Dist: numba>=0.59.0; extra == "performance"
Requires-Dist: llvmlite>=0.40.0; extra == "performance"
Requires-Dist: faiss-cpu>=1.7.0; extra == "performance"
Provides-Extra: visualization
Requires-Dist: matplotlib>=3.5.0; extra == "visualization"
Requires-Dist: seaborn>=0.11.0; extra == "visualization"
Requires-Dist: plotly>=5.0.0; extra == "visualization"
Provides-Extra: web
Requires-Dist: streamlit>=1.20.0; extra == "web"
Requires-Dist: fastapi>=0.95.0; extra == "web"
Requires-Dist: uvicorn>=0.20.0; extra == "web"
Provides-Extra: database
Requires-Dist: sqlalchemy>=1.4.0; extra == "database"
Requires-Dist: psycopg2-binary>=2.9.0; extra == "database"
Provides-Extra: cloud
Requires-Dist: boto3>=1.26.0; extra == "cloud"
Requires-Dist: azure-storage-blob>=12.14.0; extra == "cloud"
Requires-Dist: google-cloud-storage>=2.7.0; extra == "cloud"
Provides-Extra: dev
Requires-Dist: pytest>=7.0.0; extra == "dev"
Requires-Dist: pytest-cov>=4.0.0; extra == "dev"
Requires-Dist: pytest-asyncio>=0.20.0; extra == "dev"
Requires-Dist: black>=22.0.0; extra == "dev"
Requires-Dist: flake8>=5.0.0; extra == "dev"
Requires-Dist: mypy>=0.991; extra == "dev"
Requires-Dist: isort>=5.10.0; extra == "dev"
Provides-Extra: docs
Requires-Dist: sphinx>=5.0.0; extra == "docs"
Requires-Dist: sphinx-rtd-theme>=1.0.0; extra == "docs"
Provides-Extra: all
Requires-Dist: zeyrek>=0.1.2; extra == "all"
Requires-Dist: turkish-stemmer>=1.0.0; extra == "all"
Requires-Dist: layoutparser>=0.3.4; extra == "all"
Requires-Dist: detectron2>=0.6; python_version < "3.11" and extra == "all"
Requires-Dist: torch>=1.12.0; extra == "all"
Requires-Dist: torchvision>=0.13.0; extra == "all"
Requires-Dist: numba>=0.59.0; extra == "all"
Requires-Dist: llvmlite>=0.40.0; extra == "all"
Requires-Dist: faiss-cpu>=1.7.0; extra == "all"
Requires-Dist: matplotlib>=3.5.0; extra == "all"
Requires-Dist: seaborn>=0.11.0; extra == "all"
Requires-Dist: plotly>=5.0.0; extra == "all"
Requires-Dist: streamlit>=1.20.0; extra == "all"
Requires-Dist: fastapi>=0.95.0; extra == "all"
Requires-Dist: uvicorn>=0.20.0; extra == "all"
Requires-Dist: sqlalchemy>=1.4.0; extra == "all"
Requires-Dist: psycopg2-binary>=2.9.0; extra == "all"
Requires-Dist: boto3>=1.26.0; extra == "all"
Requires-Dist: azure-storage-blob>=12.14.0; extra == "all"
Requires-Dist: google-cloud-storage>=2.7.0; extra == "all"
Requires-Dist: pytest>=7.0.0; extra == "all"
Requires-Dist: pytest-cov>=4.0.0; extra == "all"
Requires-Dist: pytest-asyncio>=0.20.0; extra == "all"
Requires-Dist: black>=22.0.0; extra == "all"
Requires-Dist: flake8>=5.0.0; extra == "all"
Requires-Dist: mypy>=0.991; extra == "all"
Requires-Dist: isort>=5.10.0; extra == "all"
Requires-Dist: sphinx>=5.0.0; extra == "all"
Requires-Dist: sphinx-rtd-theme>=1.0.0; extra == "all"
Dynamic: author
Dynamic: download-url
Dynamic: home-page
Dynamic: license-file
Dynamic: maintainer
Dynamic: platform
Dynamic: requires-python

# 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

```bash
# 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

```bash
# 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

```bash
# 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

```bash
# 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

```bash
# Sistem durumunu kontrol etme
smartchunk info

# Kullanım örneklerini görme
smartchunk examples
```

### Python API

#### Temel Kullanım

```python
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

```python
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

```python
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

```bash
# 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ı

```yaml
# 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ı
```json
{
  "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ı
```markdown
# 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
```bash
# 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
```bash
# 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 🚀
