import gradio as gr import pandas as pd import nltk nltk.download('punkt_tab') from lowerated.rate.entity import Entity def rate_movies(reviews_text, review_file, column_name): reviews = [] if reviews_text: reviews = reviews_text.split("\n") elif review_file is not None: try: for file in review_file: if file.name.endswith('.csv'): df = pd.read_csv(file) elif file.name.endswith('.xlsx'): df = pd.read_excel(file) if column_name in df.columns: reviews.extend(df[column_name].tolist()) except Exception as e: return f"Error processing file: {str(e)}" if not reviews: return "No reviews provided." entity = Entity(name="Movie") ratings = entity.rate(reviews=reviews) ratings_df = pd.DataFrame([ratings]) # Extract LM6 score and format it for display lm6_score = ratings.get('LM6', 0) formatted_lm6 = f"