Skip to content

Commit c822bc1

Browse files
author
Edi Muškardin
authored
Merge pull request #91 from DES-Lab/alergia-typo
fix sequances
2 parents 177862f + fc768c4 commit c822bc1

File tree

9 files changed

+36
-36
lines changed

9 files changed

+36
-36
lines changed

Benchmarking/json_lbt.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -234,9 +234,9 @@ def corrupt_json(symbols):
234234
)
235235

236236

237-
def generate_dataset(num_sequances):
237+
def generate_dataset(num_sequences):
238238
dataset = set()
239-
while len(dataset) <= num_sequances:
239+
while len(dataset) <= num_sequences:
240240
ts, tt = generate_random_json(max_depth=2, max_elements=3)
241241
assert is_valid_json(ts), ts
242242
dataset.add((tuple(tt), True))
@@ -287,7 +287,7 @@ def validate_string_with_json_parser(json_str, json_parser):
287287

288288
model_learning_dataset = []
289289
if not use_learned_model:
290-
model_learning_dataset = generate_dataset(num_sequances=20000)
290+
model_learning_dataset = generate_dataset(num_sequences=20000)
291291

292292
learned_json_model = run_PAPNI(model_learning_dataset, vpa_alphabet)
293293
# learned_json_model.visualize()
@@ -307,10 +307,10 @@ def validate_string_with_json_parser(json_str, json_parser):
307307
for _ in range(num_learning_iterations):
308308
disagreements.clear()
309309

310-
test_dataset = generate_input_output_data_from_vpa(learned_json_model, num_sequances=10000, max_seq_len=16)
310+
test_dataset = generate_input_output_data_from_vpa(learned_json_model, num_sequences=10000, max_seq_len=16)
311311
print(f"Num well-matched tests: {len([x for x in test_dataset if learned_json_model.is_balanced(x[0])])}")
312312

313-
num_new_sequances = 0
313+
num_new_sequences = 0
314314

315315
for seq, label in test_dataset:
316316

@@ -330,9 +330,9 @@ def validate_string_with_json_parser(json_str, json_parser):
330330
if (seq, label) in model_learning_dataset:
331331
model_learning_dataset.remove((seq, label))
332332
model_learning_dataset.add((seq, not label))
333-
num_new_sequances += 1
333+
num_new_sequences += 1
334334

335-
print(f'Added {num_new_sequances} to learning set, total size {len(model_learning_dataset)}')
335+
print(f'Added {num_new_sequences} to learning set, total size {len(model_learning_dataset)}')
336336
learned_json_model = run_PAPNI(model_learning_dataset, vpa_alphabet, print_info=False)
337337
print(f'Current model size: {learned_json_model.size}')
338338

Benchmarking/passive_vpa_vs_rpni.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from statistics import mean, stdev
99

1010
all_data = dict()
11-
with open('papni_sequances.pickle', 'rb') as handle:
11+
with open('papni_sequences.pickle', 'rb') as handle:
1212
all_data = pickle.load(handle)
1313

1414

@@ -59,21 +59,21 @@ def evaluate_model(learned_model, test_data):
5959
return [rpni_model.size, papni_model.size, rpni_error, papni_error]
6060

6161

62-
def get_sequances_from_active_sevpa(model):
62+
def get_sequences_from_active_sevpa(model):
6363
from aalpy import SUL, run_KV, RandomWordEqOracle, SevpaAlphabet
6464

6565
class CustomSUL(SUL):
6666
def __init__(self, automatonSUL):
6767
super(CustomSUL, self).__init__()
6868
self.sul = automatonSUL
69-
self.sequances = []
69+
self.sequences = []
7070

7171
def pre(self):
7272
self.tc = []
7373
self.sul.pre()
7474

7575
def post(self):
76-
self.sequances.append(self.tc)
76+
self.sequences.append(self.tc)
7777
self.sul.post()
7878

7979
def step(self, letter):
@@ -91,7 +91,7 @@ def step(self, letter):
9191
# eq_oracle = BreadthFirstExplorationEqOracle(vpa_alphabet.get_merged_alphabet(), sul, 7)
9292
_ = run_KV(alphabet, sul, eq_oracle, automaton_type='vpa', print_level=3)
9393

94-
return convert_i_o_traces_for_RPNI(sul.sequances)
94+
return convert_i_o_traces_for_RPNI(sul.sequences)
9595

9696

9797
def split_data_to_learning_and_testing(data, learning_to_test_ratio=0.5):
@@ -104,20 +104,20 @@ def split_data_to_learning_and_testing(data, learning_to_test_ratio=0.5):
104104
# sorted(data, key=lambda x: len(x[0]))
105105
shuffle(data)
106106

107-
learning_sequances, test_sequances = [], []
107+
learning_sequences, test_sequences = [], []
108108

109109
l_pos, l_neg = 0, 0
110110
for seq, label in data:
111111
if label and l_pos <= num_learning_positive_seq:
112-
learning_sequances.append((seq, label))
112+
learning_sequences.append((seq, label))
113113
l_pos += 1
114114
elif not label and l_neg <= num_learning_negative_seq:
115-
learning_sequances.append((seq, label))
115+
learning_sequences.append((seq, label))
116116
l_neg += 1
117117
else:
118-
test_sequances.append((seq, label))
118+
test_sequences.append((seq, label))
119119

120-
return learning_sequances, test_sequances
120+
return learning_sequences, test_sequences
121121

122122

123123
def run_experiment(experiment_id,
@@ -128,7 +128,7 @@ def run_experiment(experiment_id,
128128
learning_to_test_ratio=0.5):
129129
if random_data_generation:
130130
data = generate_input_output_data_from_vpa(ground_truth_model,
131-
num_sequances=num_of_learning_seq,
131+
num_sequences=num_of_learning_seq,
132132
max_seq_len=max_learning_seq_len,
133133
)
134134
else:
@@ -150,7 +150,7 @@ def run_experiment(experiment_id,
150150
# wm_negative += 1
151151
# print(wm_negative)
152152

153-
# data = get_sequances_from_active_sevpa(ground_truth_model)
153+
# data = get_sequences_from_active_sevpa(ground_truth_model)
154154

155155
vpa_alphabet = ground_truth_model.get_input_alphabet()
156156

Benchmarking/rpni_papni_memory_footrpint.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
# for size in range(5000, 50001, 5000):
5050
# print(size)
5151
# data = generate_input_output_data_from_vpa(gt,
52-
# num_sequances=size,
52+
# num_sequences=size,
5353
# max_seq_len=randint(6, 30))
5454
#
5555
# y = run_RPNI(data, automaton_type='dfa', print_info=False)

Examples.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -869,7 +869,7 @@ def rpni_check_model_example():
869869

870870
input_al = model.get_input_alphabet()
871871

872-
data = generate_input_output_data_from_automata(model, num_sequances=2000,
872+
data = generate_input_output_data_from_automata(model, num_sequences=2000,
873873
min_seq_len=1, max_seq_len=12)
874874

875875
data = convert_i_o_traces_for_RPNI(data)
@@ -1149,7 +1149,7 @@ def passive_vpa_learning_on_lists():
11491149
def passive_vpa_learning_arithmetics():
11501150
from aalpy.learning_algs import run_PAPNI
11511151
from aalpy.utils.BenchmarkVpaModels import gen_arithmetic_data
1152-
arithmetic_data, vpa_alphabet = gen_arithmetic_data(num_sequances=4000, min_seq_len=2, max_seq_len=10)
1152+
arithmetic_data, vpa_alphabet = gen_arithmetic_data(num_sequences=4000, min_seq_len=2, max_seq_len=10)
11531153

11541154
print(f"Alphabet: {vpa_alphabet}")
11551155

@@ -1168,7 +1168,7 @@ def passive_vpa_learning_on_all_benchmark_models():
11681168

11691169
for gt in [vpa_L1(), vpa_L12(), vpa_for_odd_parentheses()]:
11701170
vpa_alphabet = gt.input_alphabet
1171-
data = generate_input_output_data_from_vpa(gt, num_sequances=2000, max_seq_len=16)
1171+
data = generate_input_output_data_from_vpa(gt, num_sequences=2000, max_seq_len=16)
11721172

11731173
papni = run_PAPNI(data, vpa_alphabet, algorithm='gsm', print_info=True)
11741174

@@ -1336,7 +1336,7 @@ def k_tails_example():
13361336
input_alphabet_size=3,
13371337
output_alphabet_size=3)
13381338

1339-
data = generate_input_output_data_from_automata(model, num_sequances=2000,
1339+
data = generate_input_output_data_from_automata(model, num_sequences=2000,
13401340
min_seq_len=1, max_seq_len=12,
13411341
sequance_type='io_traces')
13421342

aalpy/learning_algs/deterministic_passive/RPNI.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def run_PAPNI(data, vpa_alphabet, algorithm='edsm', print_info=True):
8080

8181
assert algorithm in {'gsm', 'classic', 'edsm'}
8282

83-
# preprocess input sequances to keep track of stack
83+
# preprocess input sequences to keep track of stack
8484
papni_data = []
8585
for input_seq, label in data:
8686
# if input sequance is not balanced we do not consider it (it would lead to error state anyway)

aalpy/learning_algs/non_deterministic/OnfsmLstar.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def run_non_det_Lstar(alphabet: list, sul: SUL, eq_oracle: Oracle, n_sampling=5,
2828
n_sampling: number of times that each cell has to be updated. If this number is to low, all-weather condition
2929
will not hold and learning will not converge to the correct model. (Default value = 50)
3030
31-
samples: input output sequances provided to learning algorithm. List of ((input sequence), (output sequence)).
31+
samples: input output sequences provided to learning algorithm. List of ((input sequence), (output sequence)).
3232
3333
stochastic: if True, non deterministic learning will be performed but probabilities will be added to the
3434
returned model, making it a stochastic Mealy machine

aalpy/learning_algs/stochastic_passive/FPTA.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def create_fpta(data, automaton_type):
6060

6161
for seq in data:
6262
if automaton_type != 'smm' and seq[0] != root_node.output:
63-
print('All sequances passed to Alergia should have the same initial output!')
63+
print('All sequences passed to Alergia should have the same initial output!')
6464
assert False
6565

6666
curr_node = root_node

aalpy/utils/BenchmarkVpaModels.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ def vpa_for_even_parentheses():
350350
return vpa
351351

352352

353-
def gen_arithmetic_data(num_sequances=3000, min_seq_len=2, max_seq_len=8):
353+
def gen_arithmetic_data(num_sequences=3000, min_seq_len=2, max_seq_len=8):
354354
import ast
355355
from aalpy.base import SUL
356356
from aalpy.utils import convert_i_o_traces_for_RPNI
@@ -388,7 +388,7 @@ def step(self, letter):
388388
alphabet = VpaAlphabet(internal_alphabet=['1', '+', ], call_alphabet=['(', ], return_alphabet=[')', ])
389389
merged_alphabet = alphabet.get_merged_alphabet()
390390
data = []
391-
while len(data) < num_sequances:
391+
while len(data) < num_sequences:
392392
seq = []
393393
for _ in range(random.randint(min_seq_len, max_seq_len)):
394394
seq.append(random.choice(merged_alphabet))

aalpy/utils/HelperFunctions.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -340,14 +340,14 @@ def is_balanced(input_seq, vpa_alphabet):
340340
return counter == 0
341341

342342

343-
def generate_input_output_data_from_automata(model, num_sequances=4000, min_seq_len=1, max_seq_len=16,
343+
def generate_input_output_data_from_automata(model, num_sequences=4000, min_seq_len=1, max_seq_len=16,
344344
sequance_type='io_traces'):
345345
assert sequance_type in {'io_traces', 'labeled_sequences'}
346346

347347
alphabet = model.get_input_alphabet()
348348
dataset = []
349349

350-
while len(dataset) < num_sequances:
350+
while len(dataset) < num_sequences:
351351
sequance = []
352352
for _ in range(random.randint(min_seq_len, max_seq_len)):
353353
sequance.append(random.choice(alphabet))
@@ -363,18 +363,18 @@ def generate_input_output_data_from_automata(model, num_sequances=4000, min_seq_
363363
return dataset
364364

365365

366-
def generate_input_output_data_from_vpa(vpa, num_sequances=1000, max_seq_len=16, max_attempts=None):
366+
def generate_input_output_data_from_vpa(vpa, num_sequences=1000, max_seq_len=16, max_attempts=None):
367367
alphabet = vpa.input_alphabet.get_merged_alphabet()
368368
data_set, in_set = [], set()
369369

370-
num_nominal_tries = num_sequances // 2
370+
num_nominal_tries = num_sequences // 2
371371
num_generation_attempts = 0
372372

373-
max_attempts = max_attempts if max_attempts is not None else num_sequances * 50
373+
max_attempts = max_attempts if max_attempts is not None else num_sequences * 50
374374

375-
while len(data_set) < num_sequances:
375+
while len(data_set) < num_sequences:
376376
num_generation_attempts += 1
377-
# it can happen that it is not possible to generate num_sequances balanced words of lenght <= max_seq_len
377+
# it can happen that it is not possible to generate num_sequences balanced words of lenght <= max_seq_len
378378
if num_generation_attempts == max_attempts:
379379
break
380380

0 commit comments

Comments
 (0)