Spaces:
Sleeping
Sleeping
Commit ·
354524a
1
Parent(s): 40359c2
Update app.py
Browse files
app.py
CHANGED
|
@@ -9,16 +9,13 @@ def load_data(csv_file):
|
|
| 9 |
|
| 10 |
|
| 11 |
def convert_to_rating(sentiment):
|
| 12 |
-
if sentiment >
|
| 13 |
-
return
|
| 14 |
-
elif sentiment
|
| 15 |
-
return 2
|
| 16 |
-
elif sentiment >= -0.2 and sentiment < 0.2:
|
| 17 |
return 3
|
| 18 |
-
elif sentiment >= 0.2 and sentiment < 0.6:
|
| 19 |
-
return 4
|
| 20 |
else:
|
| 21 |
-
return
|
|
|
|
| 22 |
|
| 23 |
def main():
|
| 24 |
st.title("Review to Rating Converter")
|
|
@@ -36,16 +33,16 @@ def main():
|
|
| 36 |
|
| 37 |
# Display the converted ratings
|
| 38 |
st.subheader("Converted Ratings:")
|
| 39 |
-
st.dataframe(df['Rating'])
|
| 40 |
|
| 41 |
# Download the converted ratings as CSV
|
| 42 |
st.download_button(
|
| 43 |
label="Download Converted Ratings",
|
| 44 |
-
data=df['Rating'].to_csv(index=False),
|
| 45 |
file_name="converted_ratings.csv",
|
| 46 |
mime="text/csv"
|
| 47 |
)
|
| 48 |
|
| 49 |
|
| 50 |
if __name__ == '__main__':
|
| 51 |
-
main()
|
|
|
|
| 9 |
|
| 10 |
|
| 11 |
def convert_to_rating(sentiment):
|
| 12 |
+
if sentiment > 0:
|
| 13 |
+
return 5
|
| 14 |
+
elif sentiment == 0:
|
|
|
|
|
|
|
| 15 |
return 3
|
|
|
|
|
|
|
| 16 |
else:
|
| 17 |
+
return 1
|
| 18 |
+
|
| 19 |
|
| 20 |
def main():
|
| 21 |
st.title("Review to Rating Converter")
|
|
|
|
| 33 |
|
| 34 |
# Display the converted ratings
|
| 35 |
st.subheader("Converted Ratings:")
|
| 36 |
+
st.dataframe(df[['Reviews', 'Rating']])
|
| 37 |
|
| 38 |
# Download the converted ratings as CSV
|
| 39 |
st.download_button(
|
| 40 |
label="Download Converted Ratings",
|
| 41 |
+
data=df[['Reviews', 'Rating']].to_csv(index=False),
|
| 42 |
file_name="converted_ratings.csv",
|
| 43 |
mime="text/csv"
|
| 44 |
)
|
| 45 |
|
| 46 |
|
| 47 |
if __name__ == '__main__':
|
| 48 |
+
main()
|