beweinreich commited on
Commit
64007dc
1 Parent(s): 05bb441

only show the changes if they actually took

Browse files
Files changed (1) hide show
  1. chatgpt_audit.py +5 -4
chatgpt_audit.py CHANGED
@@ -115,16 +115,15 @@ for row in results:
115
  all_words = list(set(all_words)) # remove duplicates
116
  response = query_gpt(input_word, dictionary_word, all_words)
117
  if response:
118
- csv_data.append({
119
  'input_word': input_word,
120
  'original_dictionary_word': dictionary_word,
121
- 'new_dictionary_word': response,
122
- 'changed': dictionary_word != response
123
- })
124
  if response == dictionary_word and response in dictionary:
125
  print(f" - Mapping is correct")
126
  db_cursor.execute("UPDATE mappings SET reviewed = true WHERE input_word = %s", (input_word,))
127
  db_conn.commit()
 
128
  else:
129
  # We should update the mapping in the database
130
  # We should replace dictionary_word with response
@@ -134,9 +133,11 @@ for row in results:
134
  print(f" - Updating mapping with {response}")
135
  db_cursor.execute("UPDATE mappings SET dictionary_word = %s, reviewed = true WHERE input_word = %s", (response, input_word))
136
  db_conn.commit()
 
137
  else:
138
  print(f" - Response {response} is not in the dictionary")
139
 
 
140
  update_csv(csv_data)
141
 
142
  db_conn.close()
 
115
  all_words = list(set(all_words)) # remove duplicates
116
  response = query_gpt(input_word, dictionary_word, all_words)
117
  if response:
118
+ new_row = {
119
  'input_word': input_word,
120
  'original_dictionary_word': dictionary_word,
121
+ }
 
 
122
  if response == dictionary_word and response in dictionary:
123
  print(f" - Mapping is correct")
124
  db_cursor.execute("UPDATE mappings SET reviewed = true WHERE input_word = %s", (input_word,))
125
  db_conn.commit()
126
+ new_row['new_dictionary_word'] = response
127
  else:
128
  # We should update the mapping in the database
129
  # We should replace dictionary_word with response
 
133
  print(f" - Updating mapping with {response}")
134
  db_cursor.execute("UPDATE mappings SET dictionary_word = %s, reviewed = true WHERE input_word = %s", (response, input_word))
135
  db_conn.commit()
136
+ new_row['new_dictionary_word'] = response
137
  else:
138
  print(f" - Response {response} is not in the dictionary")
139
 
140
+ csv_data.append(new_row)
141
  update_csv(csv_data)
142
 
143
  db_conn.close()