text stringlengths 0 828 |
|---|
else: |
diff_index = diff[0] |
low = 0 |
high = len(w_string) |
while True: |
i = (low + high) / 2 |
length = len(self._membership_query(w_string[:i])) |
if length == diff_index + 1: |
return w_string[:i] |
elif length < diff_index + 1: |
low = i + 1 |
else: |
high = i - 1" |
1095,"def _process_counter_example(self, mma, w_string): |
"""""""" |
Process a counterexample in the Rivest-Schapire way. |
Args: |
mma (DFA): The hypothesis automaton |
w_string (str): The examined string to be consumed |
Returns: |
None |
"""""" |
w_string = self._find_bad_transition(mma, w_string) |
diff = len(w_string) |
same = 0 |
while True: |
i = (same + diff) / 2 |
access_string = self._run_in_hypothesis(mma, w_string, i) |
is_diff = self._check_suffix(w_string, access_string, i) |
if is_diff: |
diff = i |
else: |
same = i |
if diff - same == 1: |
break |
exp = w_string[diff:] |
self.observation_table.em_vector.append(exp) |
for row in self.observation_table.sm_vector + self.observation_table.smi_vector: |
self._fill_table_entry(row, exp)" |
1096,"def _ot_make_closed(self, access_string): |
"""""" |
Given a state input_string in Smi that is not equivalent with any state in Sm |
this method will move that state in Sm create a corresponding Smi |
state and fill the corresponding entries in the table. |
Args: |
access_string (str): State access string |
Returns: |
None |
"""""" |
self.observation_table.sm_vector.append(access_string) |
for i in self.alphabet: |
self.observation_table.smi_vector.append(access_string + i) |
for e in self.observation_table.em_vector: |
self._fill_table_entry(access_string + i, e)" |
1097,"def get_mealy_conjecture(self): |
"""""" |
Utilize the observation table to construct a Mealy Machine. |
The library used for representing the Mealy Machine is the python |
bindings of the openFST library (pyFST). |
Args: |
None |
Returns: |
MealyMachine: A mealy machine build based on a closed and consistent |
observation table. |
"""""" |
mma = MealyMachine() |
for s in self.observation_table.sm_vector: |
for i in self.alphabet: |
dst = self.observation_table.equiv_classes[s + i] |
# If dst == None then the table is not closed. |
if dst is None: |
logging.debug('Conjecture attempt on non closed table.') |
return None |
o = self.observation_table[s, i] |
src_id = self.observation_table.sm_vector.index(s) |
dst_id = self.observation_table.sm_vector.index(dst) |
mma.add_arc(src_id, dst_id, i, o) |
# This works only for Mealy machines |
for s in mma.states: |
s.final = True |
return mma" |
1098,"def _init_table(self): |
"""""" |
Initialize the observation table. |
"""""" |
self.observation_table.sm_vector.append('') |
self.observation_table.smi_vector = list(self.alphabet) |
self.observation_table.em_vector = list(self.alphabet) |
for i in self.observation_table.em_vector: |
self._fill_table_entry('', i) |
for s, e in product(self.observation_table.smi_vector, self.observation_table.em_vector): |
self._fill_table_entry(s, e)" |
1099,"def learn_mealy_machine(self): |
"""""" |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.