def parse_clue_text(clue_text): if '|' not in clue_text: clue_text += ' |' clue_text = clue_text.lower() clue, rest = clue_text.split('(') length, rest = rest.split(')') length = int(length) pattern, answer = rest.split('|') pattern = pattern.strip() clue = re.sub(r'[^a-zA-Z\ _]', '', clue) clue = re.sub(r'\ +', ' ', clue) phrases = clue.split(' ') phrases = [p for p in phrases if p.strip() != ''] all_phrasings = [] for p in phrasings(phrases): p += [length, pattern] all_phrasings.append(p) return all_phrasings, answer
def parse_clue_text(clue_text): phrases, lengths, pattern, answer = split_clue_text(clue_text) return phrasings(phrases), lengths, pattern, answer