Spaces:
Sleeping
Sleeping
File size: 684 Bytes
5262393 03eec87 5262393 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
from fastapi import APIRouter, HTTPException
import logging
from commafixer.src.baseline import BaselineCommaFixer
logger = logging.Logger(__name__)
logging.basicConfig(level=logging.INFO)
router = APIRouter()
logger.info('Loading the baseline model...')
router.model = BaselineCommaFixer()
@router.post('/fix-commas/')
async def fix_commas_with_baseline(data: dict):
json_field_name = 's'
if json_field_name in data:
logger.debug('Fixing commas.')
return {json_field_name: router.model.fix_commas(data['s'])}
else:
msg = f"Text '{json_field_name}' missing"
logger.debug(msg)
raise HTTPException(status_code=400, detail=msg)
|