cur_obj = root_object; for c in my_string[1:]: new_obj = Graph(graphID="Char"); # Unknown Object new_obj.matching_object = c; cur_obj.nexts.append(new_obj); cur_obj = new_obj; cur_obj = root_object; while cur_obj != None: #print(cur_obj); if len(cur_obj.nexts) > 0: cur_obj = cur_obj.nexts[0]; else: cur_obj = None; my_machine = Machine(); # # Number Graph: One node, the number # nn = Graph().node_from_file("number_node.txt","Number Node"); # number = Graph(startNodes=[nn], graphID="Number"); # # Letter Graph: One node, the letter # ln = Graph().node_from_file("letter_node.txt","Letter Node"); # letter = Graph(startNodes=[ln],graphID="Letter"); # # Space Graph: One node: the space # sn = Graph().node_from_file("space_node.txt","Space Node"); # space = Graph(startNodes=[sn], graphID="Space"); # # Punctuation Graph: One node, the punctuation # pn = Graph().node_from_file("punctuation_node.txt","Punctuation Node");
for c in my_string[1:]: new_obj = Graph(graphID="Char") # Unknown Object new_obj.matching_object = c cur_obj.nexts.append(new_obj) cur_obj = new_obj cur_obj = root_object while cur_obj != None: # print(cur_obj); if len(cur_obj.nexts) > 0: cur_obj = cur_obj.nexts[0] else: cur_obj = None my_machine = Machine() # Number Graph: One node, the number # nn = Graph().node_from_file("number_node.txt","Number Node"); # number = Graph(startNodes=[nn], graphID="Number"); # Letter Graph: One node, the letter # ln = Graph().node_from_file("letter_node.txt","Letter Node"); # letter = Graph(startNodes=[ln],graphID="Letter"); # Space Graph: One node: the space # sn = Graph().node_from_file("space_node.txt","Space Node"); # space = Graph(startNodes=[sn], graphID="Space"); # Punctuation Graph: One node, the punctuation # pn = Graph().node_from_file("punctuation_node.txt","Punctuation Node");