Fraser-Greenlee commited on
Commit
0fc8b1d
1 Parent(s): 1126e74
Files changed (1) hide show
  1. make_variations.py +20 -3
make_variations.py CHANGED
@@ -9,6 +9,7 @@ import ast
9
 
10
 
11
  def write_rows(rows):
 
12
  with open('data.10_simple_variations.jsonl', 'a') as f:
13
  f.writelines(rows)
14
 
@@ -129,15 +130,26 @@ def make_alternative_rows(start, code):
129
  variations[alt_start] = alt_start_code_end
130
  n_tries += 1
131
 
 
132
  '''
133
- for each variations
134
- switch out variable names (maintain alphabetical order)
 
 
 
 
135
  '''
136
  return [
137
  json.dumps({'start': st, 'code': cd, 'end': en}) + '\n' for st, cd, en in variations.values()
138
  ]
139
 
140
 
 
 
 
 
 
 
141
  with open('new_all_states.txt', 'r') as f:
142
  rows = []
143
  prev_lines = []
@@ -159,7 +171,12 @@ with open('new_all_states.txt', 'r') as f:
159
  rows.append(json.dumps({
160
  'start': start, 'code': code, 'end': end
161
  }) + '\n')
162
- rows += make_alternative_rows(start, code)
 
 
 
 
 
163
  if len(rows) > 100_000:
164
  breakpoint()
165
  write_rows(rows)
 
9
 
10
 
11
  def write_rows(rows):
12
+ # TODO write this as a gzip for much better compression
13
  with open('data.10_simple_variations.jsonl', 'a') as f:
14
  f.writelines(rows)
15
 
 
130
  variations[alt_start] = alt_start_code_end
131
  n_tries += 1
132
 
133
+ # TODO change the names (keep alphabetical order)
134
  '''
135
+ get number of vals in start states (N)
136
+ get N random lowercase letters in alphabetical order
137
+ parse start state and shuffle the expr.body
138
+ make name map old->new using new characters
139
+ use visitor with name map to swap variable names using map
140
+ do this for start, code, end seperately
141
  '''
142
  return [
143
  json.dumps({'start': st, 'code': cd, 'end': en}) + '\n' for st, cd, en in variations.values()
144
  ]
145
 
146
 
147
+ STATS = {
148
+ 'alt_count': 0,
149
+ 'num_rows': 0
150
+ }
151
+
152
+
153
  with open('new_all_states.txt', 'r') as f:
154
  rows = []
155
  prev_lines = []
 
171
  rows.append(json.dumps({
172
  'start': start, 'code': code, 'end': end
173
  }) + '\n')
174
+ alt_rows = make_alternative_rows(start, code)
175
+ rows += alt_rows
176
+
177
+ STATS['alt_count'] += len(alt_rows)
178
+ STATS['num_rows'] += 1
179
+
180
  if len(rows) > 100_000:
181
  breakpoint()
182
  write_rows(rows)