Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -104,6 +104,9 @@ cross_encoder = CrossEncoder('cross-encoder/ms-marco-MiniLM-L-6-v2') # Pre-trai
|
|
| 104 |
|
| 105 |
# Define preprocessing functions for classification
|
| 106 |
def preprocess_text(text):
|
|
|
|
|
|
|
|
|
|
| 107 |
# Step 1: Lowercase the text
|
| 108 |
text = text.lower()
|
| 109 |
|
|
@@ -161,6 +164,7 @@ with col1:
|
|
| 161 |
|
| 162 |
# Preprocess the content column and predict categories
|
| 163 |
if 'content' in df.columns:
|
|
|
|
| 164 |
df['preprocessed_content'] = df['content'].apply(preprocess_text)
|
| 165 |
df['class'] = df['preprocessed_content'].apply(predict_category)
|
| 166 |
|
|
|
|
| 104 |
|
| 105 |
# Define preprocessing functions for classification
|
| 106 |
def preprocess_text(text):
|
| 107 |
+
if not isinstance(text, str):
|
| 108 |
+
text = ""
|
| 109 |
+
|
| 110 |
# Step 1: Lowercase the text
|
| 111 |
text = text.lower()
|
| 112 |
|
|
|
|
| 164 |
|
| 165 |
# Preprocess the content column and predict categories
|
| 166 |
if 'content' in df.columns:
|
| 167 |
+
df['content'] = df['content'].fillna("").astype(str)
|
| 168 |
df['preprocessed_content'] = df['content'].apply(preprocess_text)
|
| 169 |
df['class'] = df['preprocessed_content'].apply(predict_category)
|
| 170 |
|