Пример #1
0
async def predict_review(reviews: List[str] = Query(
    ..., description='Reviews to process')):

    predictions = predict(reviews)

    print(predictions)

    return {'result': predictions}
Пример #2
0
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
Пример #3
0
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
Пример #4
0
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
Пример #5
0
async def predict_sentences_topic(sentences: List[str] = Query(..., description='Sentences to process')):
	topics = predict(sentences)

	return {'Result': topics}