MCPcopy Create free account
hub / github.com/RingBDStack/GDAP / match_sublist

Function match_sublist

extraction/extract_constraint.py:14–27  ·  view source on GitHub ↗

:param the_list: [1, 2, 3, 4, 5, 6, 1, 2, 4, 5] :param to_match: [1, 2] :return: [(0, 1), (6, 7)]

(the_list, to_match)

Source from the content-addressed store, hash-verified

12
13
14def match_sublist(the_list, to_match):
15 """
16
17 :param the_list: [1, 2, 3, 4, 5, 6, 1, 2, 4, 5]
18 :param to_match: [1, 2]
19 :return:
20 [(0, 1), (6, 7)]
21 """
22 len_to_match = len(to_match)
23 matched_list = list()
24 for index in range(len(the_list) - len_to_match):
25 if to_match == the_list[index:index + len_to_match]:
26 matched_list += [(index, index + len_to_match - 1)]
27 return matched_list
28
29
30def find_bracket_position(generated_text, _type_start, _type_end):

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected