Spaces:
Sleeping
Sleeping
Vela
commited on
Commit
·
9bb7299
1
Parent(s):
726f5db
modified files
Browse files
models.py
CHANGED
@@ -6,13 +6,12 @@ def load_model():
|
|
6 |
def analyze_sentiments(df, text_column, classifier):
|
7 |
if text_column not in df.columns:
|
8 |
raise ValueError(f"Column '{text_column}' not found in DataFrame.")
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
df['sentiment'] = sentiments
|
18 |
return df
|
|
|
6 |
def analyze_sentiments(df, text_column, classifier):
|
7 |
if text_column not in df.columns:
|
8 |
raise ValueError(f"Column '{text_column}' not found in DataFrame.")
|
9 |
+
|
10 |
+
texts = df[text_column].astype(str).tolist()
|
11 |
+
try:
|
12 |
+
sentiments = classifier(texts)
|
13 |
+
df['sentiment'] = [result['label'] for result in sentiments]
|
14 |
+
except Exception as e:
|
15 |
+
print(f"Error processing text. Error: {e}")
|
16 |
+
df['sentiment'] = 'UNKNOWN'
|
|
|
17 |
return df
|