реализация функции generate_summary_report
This commit is contained in:
parent
44af5bf3db
commit
5d8a4101c1
22
main.py
22
main.py
@ -106,8 +106,26 @@ def detect_anomalies(reviews: list, sentiment_threshold: float = 0.5):
|
|||||||
return anomalys
|
return anomalys
|
||||||
|
|
||||||
|
|
||||||
def generate_summary_report(valid_reviews: list, all_reviews_count: int, anomalies: list):
|
def generate_summary_report(valid_reviews: list, all_reviews: list, spam_indicators: list, anomalies: list):
|
||||||
return dict
|
spam_count = 0
|
||||||
|
for i in all_reviews:
|
||||||
|
if is_spam(i.get('text'), spam_indicators):
|
||||||
|
spam_count += 1
|
||||||
|
|
||||||
|
summ = 0
|
||||||
|
for i in valid_reviews:
|
||||||
|
summ += i.get('sentiment')
|
||||||
|
avg_sent = summ / len(valid_reviews)
|
||||||
|
|
||||||
|
summary_report = {
|
||||||
|
"total_processed": len(all_reviews),
|
||||||
|
"valid_count": len(valid_reviews),
|
||||||
|
"spam_count": spam_count,
|
||||||
|
"avg_sentiment": avg_sent,
|
||||||
|
"topic_ratings": calculate_average_rating_by_topic(valid_reviews),
|
||||||
|
"anomaly_ids": anomalies,
|
||||||
|
}
|
||||||
|
return summary_report
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user