Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -940,22 +940,22 @@ if query:
|
|
940 |
dataset = Dataset.from_dict({'id': [], 'text': []})
|
941 |
|
942 |
def save_comment(comment):
|
943 |
-
|
944 |
-
|
945 |
-
|
946 |
-
|
947 |
-
|
948 |
-
|
949 |
-
|
950 |
|
951 |
-
|
952 |
-
|
953 |
-
|
954 |
|
955 |
-
|
956 |
-
|
957 |
|
958 |
-
|
959 |
|
960 |
|
961 |
st.title("Abstractalytics Web App")
|
|
|
940 |
dataset = Dataset.from_dict({'id': [], 'text': []})
|
941 |
|
942 |
def save_comment(comment):
|
943 |
+
# Check if the comments directory exists
|
944 |
+
if os.path.exists('comments'):
|
945 |
+
# Load the dataset from disk
|
946 |
+
dataset = Dataset.load_from_disk('comments')
|
947 |
+
else:
|
948 |
+
# Create a new dataset
|
949 |
+
dataset = Dataset.from_dict({'id': [], 'text': []})
|
950 |
|
951 |
+
# Add the comment to the dataset
|
952 |
+
dataset['id'].append(len(dataset))
|
953 |
+
dataset['text'].append(comment)
|
954 |
|
955 |
+
# Save the dataset to disk
|
956 |
+
dataset.save_to_disk('comments')
|
957 |
|
958 |
+
print('Comment saved to dataset.')
|
959 |
|
960 |
|
961 |
st.title("Abstractalytics Web App")
|