#!/usr/bin/env python3
"""Example usage of the semantic-comparer package."""

import asyncio
from semantic_comparer import SemanticAligner


async def main():
    """Demonstrate the semantic alignment functionality."""
    
    # Example texts
    text_a = """
    Machine learning is a subset of artificial intelligence.
    It involves training algorithms on data to make predictions.
    Deep learning uses neural networks with multiple layers.
    """
    
    text_b = """
    Machine learning is part of AI technology.
    Algorithms learn from data to predict outcomes.
    Neural networks with many layers are used in deep learning.
    Natural language processing is another AI field.
    """
    
    print("🔍 Semantic Text Alignment Example")
    print("=" * 50)
    
    # Create aligner
    aligner = SemanticAligner(
        model_name="all-MiniLM-L6-v2",
        gap_penalty=0.3,
        similarity_threshold=0.5
    )
    
    # Perform alignment
    print("📊 Performing semantic alignment...")
    result = await aligner.align_texts(text_a, text_b)
    
    # Display results
    print(f"\n📈 Results:")
    print(f"   Total paragraphs in A: {result.total_paragraphs_a}")
    print(f"   Total paragraphs in B: {result.total_paragraphs_b}")
    print(f"   Matched pairs: {result.matched_pairs}")
    print(f"   Gap pairs: {result.gap_pairs}")
    print(f"   Unaligned pairs: {result.unaligned_pairs}")
    print(f"   Containment score: {result.containment_score:.2%}")
    
    print(f"\n🔍 Detailed Alignment:")
    for i, pair in enumerate(result.pairs, 1):
        print(f"\n{i}. Type: {pair.type}")
        if pair.text_a:
            print(f"   Text A: {pair.text_a}")
        if pair.text_b:
            print(f"   Text B: {pair.text_b}")
        if pair.score is not None:
            print(f"   Score: {pair.score:.3f}")


if __name__ == "__main__":
    asyncio.run(main()) 