Spaces:
Sleeping
Sleeping
Update pages/1_Classification.py
Browse files
pages/1_Classification.py
CHANGED
|
@@ -5,6 +5,7 @@ import pandas as pd
|
|
| 5 |
from transformers import pipeline
|
| 6 |
#for the pre-processing of uploaded data
|
| 7 |
import string
|
|
|
|
| 8 |
from utils.styles import load_css
|
| 9 |
load_css()
|
| 10 |
|
|
@@ -16,7 +17,7 @@ def load_classifier():
|
|
| 16 |
model="SuchithTissera/text_analytics_model",
|
| 17 |
truncation=True
|
| 18 |
)
|
| 19 |
-
|
| 20 |
stop_words = {'most', "i've", 't', "we'll", 'mustn', 'we', 'into', 'they', 'on', "they'll",
|
| 21 |
'haven', 'after', 'had', 'myself', 'she', 'too', 'won', 'over', 'any', "you've",
|
| 22 |
'not', 'me', "they're", "wouldn't", 'other', 'have', 'once', 'yourselves', 'doing',
|
|
@@ -35,6 +36,7 @@ stop_words = {'most', "i've", 't', "we'll", 'mustn', 'we', 'into', 'they', 'on',
|
|
| 35 |
'a', 'same', 'which', 'being', 'himself', 'under', 'through', 'when', "mightn't", 'ours', 'above', 'were',
|
| 36 |
'd', 'does', 'such', 'doesn', 'itself', 'this', 'i', 'their', 'with', 'him'}
|
| 37 |
|
|
|
|
| 38 |
def remove_stopwords(text):
|
| 39 |
return " ".join([word for word in str(text).lower().split() if word not in stop_words])
|
| 40 |
|
|
@@ -58,6 +60,7 @@ st.markdown("""
|
|
| 58 |
</div>
|
| 59 |
""", unsafe_allow_html=True)
|
| 60 |
|
|
|
|
| 61 |
st.divider()
|
| 62 |
|
| 63 |
#uploading the file
|
|
@@ -66,6 +69,7 @@ st.markdown(
|
|
| 66 |
unsafe_allow_html=True
|
| 67 |
)
|
| 68 |
|
|
|
|
| 69 |
uploaded_file = st.file_uploader("", type=["csv"])
|
| 70 |
|
| 71 |
#loop to carry out the transformation
|
|
@@ -113,6 +117,7 @@ if uploaded_file is not None:
|
|
| 113 |
file_name="output.csv",
|
| 114 |
mime="text/csv"
|
| 115 |
)
|
| 116 |
-
|
| 117 |
except Exception as e:
|
| 118 |
-
st.error(f"Error reading or processing file: {e}")
|
|
|
|
|
|
| 5 |
from transformers import pipeline
|
| 6 |
#for the pre-processing of uploaded data
|
| 7 |
import string
|
| 8 |
+
#adding the css presentation from the styles file in utils
|
| 9 |
from utils.styles import load_css
|
| 10 |
load_css()
|
| 11 |
|
|
|
|
| 17 |
model="SuchithTissera/text_analytics_model",
|
| 18 |
truncation=True
|
| 19 |
)
|
| 20 |
+
#adding stop word based on nlk library - look at limitations for the reason
|
| 21 |
stop_words = {'most', "i've", 't', "we'll", 'mustn', 'we', 'into', 'they', 'on', "they'll",
|
| 22 |
'haven', 'after', 'had', 'myself', 'she', 'too', 'won', 'over', 'any', "you've",
|
| 23 |
'not', 'me', "they're", "wouldn't", 'other', 'have', 'once', 'yourselves', 'doing',
|
|
|
|
| 36 |
'a', 'same', 'which', 'being', 'himself', 'under', 'through', 'when', "mightn't", 'ours', 'above', 'were',
|
| 37 |
'd', 'does', 'such', 'doesn', 'itself', 'this', 'i', 'their', 'with', 'him'}
|
| 38 |
|
| 39 |
+
#constructing the stopwork function
|
| 40 |
def remove_stopwords(text):
|
| 41 |
return " ".join([word for word in str(text).lower().split() if word not in stop_words])
|
| 42 |
|
|
|
|
| 60 |
</div>
|
| 61 |
""", unsafe_allow_html=True)
|
| 62 |
|
| 63 |
+
#dividing the page
|
| 64 |
st.divider()
|
| 65 |
|
| 66 |
#uploading the file
|
|
|
|
| 69 |
unsafe_allow_html=True
|
| 70 |
)
|
| 71 |
|
| 72 |
+
#saving the csv file in a variable
|
| 73 |
uploaded_file = st.file_uploader("", type=["csv"])
|
| 74 |
|
| 75 |
#loop to carry out the transformation
|
|
|
|
| 117 |
file_name="output.csv",
|
| 118 |
mime="text/csv"
|
| 119 |
)
|
| 120 |
+
#exception handling if errors happpen
|
| 121 |
except Exception as e:
|
| 122 |
+
st.error(f"Error reading or processing file: {e}")
|
| 123 |
+
|