from fastapi import APIRouter

from app.models.nlp import (
    BatchAnalyzeRequest,
    BatchAnalyzeResponse,
    NLPAnalyzeRequest,
    NLPAnalyzeResponse,
)
from app.services.nlp_service import nlp_service

router = APIRouter(prefix="/nlp", tags=["NLP"])


@router.post("/analyze", response_model=NLPAnalyzeResponse)
def analyze(req: NLPAnalyzeRequest) -> NLPAnalyzeResponse:
    """Analyze Vietnamese property description: auto-tag, quality score, tokenize."""
    return nlp_service.analyze(req)


@router.post("/batch-analyze", response_model=BatchAnalyzeResponse)
def batch_analyze(req: BatchAnalyzeRequest) -> BatchAnalyzeResponse:
    """Batch analyze multiple property descriptions."""
    results = [
        nlp_service.analyze(NLPAnalyzeRequest(text=t, include_moderation=req.include_moderation))
        for t in req.texts
    ]
    return BatchAnalyzeResponse(results=results)
