async def predict_review(reviews: List[str] = Query( ..., description='Reviews to process')): predictions = predict(reviews) print(predictions) return {'result': predictions}
async def predict_review(sentences: List[str] = Query( ..., description='Sentences to process')): predictions = predict(sentences) response = [{ 'id': idx + 1, 'sentence': sentence, 'prediction': sentiment } for idx, (sentence, sentiment) in enumerate(zip(sentences, predictions))] return response
async def predict_review(sentences: List[str] = Query( ..., description='Sentences to process')): DetectorFactory.seed = 0 sentences = [sent for sent in sentences if detect(sent) == 'en'] predictions = predict(sentences) response = [{ 'id': idx + 1, 'sentence': sentence, 'prediction': sentiment } for idx, (sentence, sentiment) in enumerate(zip(sentences, predictions))] return response
async def predict_review(reviews: List[str] = Query( ..., description='Reviews to process')): print(reviews) predictions = predict(reviews) response = [{ 'id': idx + 1, 'review': review, 'prediction': sentiment } for idx, (review, sentiment) in enumerate(zip(reviews, predictions))] return response
async def predict_sentences_topic(sentences: List[str] = Query(..., description='Sentences to process')): topics = predict(sentences) return {'Result': topics}