Suppose I have a dictionary of rules like {('ah','be'): 'ab', ('a?','en'):'an'} and I…
- User
Suppose I have a dictionary of rules like {('ah','be'): 'ab', ('a?','en'):'an'} and I want to match to lists of strings where the question mark is a wildcard character, where I iteratively pull off prefixes from this list. This code does what I want without the wildcards:
def merge_beginnings(in_list, rules): running = [] out = [] for x in in_list: running.append("".join(y for y in x if y.isalpha())) #print(x,running) if tuple(running) in rules: out.append(rules[tuple(running)]) running = [] out = out + list(running) return out Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.