text stringlengths 0 828 |
|---|
# get the first path from the queue |
path = queue.pop(0) |
# get the last node from the path |
node = path[-1][1] |
# path found """""" |
if node.stateid not in pathstates and node.stateid != len(list(graph.states)): |
pathstates[node.stateid] = ''.join( |
[mnode[0] for mnode in path]) |
visited.append(node.stateid) |
# enumerate all adjacent nodes, construct a new path and push it |
# into the queue |
for arc in node.arcs: |
char = graph.isyms.find(arc.ilabel) |
next_state = graph[arc.nextstate] |
if next_state.stateid not in visited: |
new_path = list(path) |
new_path.append([char, next_state]) |
queue.append(new_path) |
return pathstates" |
1552,"def _get_accepted(self, graph): |
"""""" |
Find the accepted states |
Args: |
graph (DFA): The DFA states |
Return: |
list: Returns the list of the accepted states |
"""""" |
accepted = [] |
for state in graph.states: |
if state.final != TropicalWeight(float('inf')): |
accepted.append(state) |
return accepted" |
1553,"def _object_set_to_state_list(self, objectset): |
"""""" |
Args: |
objectset (list): A list of all the DFA states (as objects) |
Return: |
list: A list of all the DFA states (as identifiers) |
"""""" |
state_list = [] |
for state in list(objectset): |
state_list.append(state.stateid) |
return state_list" |
1554,"def _get_group_from_state(self, sid): |
"""""" |
Args: |
sid (int): The state identifier |
Return: |
int: The group identifier that the state belongs |
"""""" |
for index, selectgroup in enumerate(self.groups): |
if sid in selectgroup: |
return index" |
1555,"def _reverse_to_source(self, target, group1): |
"""""" |
Args: |
target (dict): A table containing the reverse transitions for each state |
group1 (list): A group of states |
Return: |
Set: A set of states for which there is a transition with the states of the group |
"""""" |
new_group = [] |
for dst in group1: |
new_group += target[dst] |
return set(new_group)" |
1556,"def _partition_group(self, group): |
"""""" |
Args: |
group (list): A group of states |
Return: |
tuple: A set of two groups |
"""""" |
for (group1, group2, distinguish_string) in self.bookeeping: |
if group & group1 != set() and not group.issubset(group1): |
new_g1 = group & group1 |
new_g2 = group - group1 |
return (new_g1, new_g2, distinguish_string) |
if group & group2 != set() and not group.issubset(group2): |
new_g1 = group & group2 |
new_g2 = group - group2 |
return (new_g1, new_g2, distinguish_string) |
assert False, ""Unmatched group partition""" |
1557,"def _init_smi(self, graph, access_strings_map): |
"""""" |
Args: |
graph (DFA): The DFA states |
access_strings_map (list): a dict containing all the access strings for each state |
Return: |
list: SMI transition table |
"""""" |
smi = [] |
for selected_state in sorted(graph.states, key=attrgetter('initial'), reverse=True): |
# Initially gather all transitions of the state into a dictionary |
transitions_map = defaultdict(list) |
for character in self.alphabet: |
destination_state = self._delta(graph, selected_state, character) |
transitions_map[destination_state.stateid].append(character) |
chars_in_smi = [] |
sorted_transitions = sorted( |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.