Skip to content

Validate text endpoint

Endpoint for validating a text for possible fair housing violations

Parameters:

Name Type Description Default
request ValidateSentencesRequest

request

required

Returns:

Name Type Description
response ValidateSentencesResponse

response

Source code in app/routers.py
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
@router.post('/validate_text', response_model=schemas.ValidateSentencesResponse, response_model_exclude_none=True)
async def validate_text(request: schemas.ValidateSentencesRequest) -> schemas.ValidateSentencesResponse:
    """
    Endpoint for validating a text for possible fair housing violations

    Parameters
    ----------
    request: schemas.ValidateSentencesResponse
        request
    Returns
    -------
    response: schemas.ValidateSentencesResponse
        response
    """

    home_id = request.home_id
    text, threshold, urduc = request.text, request.threshold, request.urduc

    sentences_prediction, is_all_valid, banned_words = services.validate_text(text=text, threshold=threshold,
                                                                              urduc=urduc)

    return schemas.ValidateSentencesResponse(home_id=home_id,
                                             sentences=sentences_prediction,
                                             is_all_valid=is_all_valid,
                                             banned_words=banned_words)