jfataphd commited on
Commit
87b11d0
·
1 Parent(s): 1b73f21

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -6
app.py CHANGED
@@ -940,17 +940,14 @@ if query:
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')
 
940
  dataset = Dataset.from_dict({'id': [], 'text': []})
941
 
942
  def save_comment(comment):
943
+ # Check if the dataset exists
944
  if os.path.exists('comments'):
 
945
  dataset = Dataset.load_from_disk('comments')
946
  else:
 
947
  dataset = Dataset.from_dict({'id': [], 'text': []})
948
 
949
+ # Append the new comment to the dataset
950
+ dataset = dataset.append({'id': len(dataset), 'text': comment})
 
951
 
952
  # Save the dataset to disk
953
  dataset.save_to_disk('comments')