Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -15,7 +15,7 @@ st.markdown("""
|
|
15 |
font-family: 'Arial', sans-serif;
|
16 |
}
|
17 |
.stApp {
|
18 |
-
background-color:
|
19 |
padding: 20px;
|
20 |
border-radius: 10px;
|
21 |
box-shadow: 2px 2px 10px rgba(0, 0, 0, 0.1);
|
@@ -82,12 +82,15 @@ if uploaded_file is not None:
|
|
82 |
|
83 |
# Preprocessing function
|
84 |
def preprocess_text(text):
|
85 |
-
text = text.lower()
|
86 |
-
text = re.sub(r'\s+', ' ', text)
|
87 |
-
text = re.sub(r'[^a-z\s]', '', text)
|
88 |
return text
|
89 |
|
|
|
90 |
df['processed_content'] = df['content'].apply(preprocess_text)
|
|
|
|
|
91 |
df['class'] = df['processed_content'].apply(lambda x: text_classification_pipeline(x)[0]['label'] if x.strip() else "Unknown")
|
92 |
|
93 |
# Show results
|
|
|
15 |
font-family: 'Arial', sans-serif;
|
16 |
}
|
17 |
.stApp {
|
18 |
+
background-color: black;
|
19 |
padding: 20px;
|
20 |
border-radius: 10px;
|
21 |
box-shadow: 2px 2px 10px rgba(0, 0, 0, 0.1);
|
|
|
82 |
|
83 |
# Preprocessing function
|
84 |
def preprocess_text(text):
|
85 |
+
text = text.lower() # Convert to lowercase
|
86 |
+
text = re.sub(r'\s+', ' ', text) # Remove extra spaces
|
87 |
+
text = re.sub(r'[^a-z\s]', '', text) # Remove special characters & numbers
|
88 |
return text
|
89 |
|
90 |
+
# Apply preprocessing and classification
|
91 |
df['processed_content'] = df['content'].apply(preprocess_text)
|
92 |
+
|
93 |
+
# Classify each record into one of the five classes
|
94 |
df['class'] = df['processed_content'].apply(lambda x: text_classification_pipeline(x)[0]['label'] if x.strip() else "Unknown")
|
95 |
|
96 |
# Show results
|