Beispiel #1
0
def parse_bracket_chords(line, state):
    bracketed = BRACKETS_REGEX.findall(line)
    bracket_words = [b[1:-1] for b in bracketed]

    if ((len(bracket_words) > 1 or state['has_had_bracket_chords']) and
        all([CHORD_REGEX.match(w) for w in bracket_words])):
        state['has_had_bracket_chords'] = True
        return bracket_words, state

    return [], state
Beispiel #2
0
def parse_parens_chords(line, state):
    parensed = PARENS_REGEX.findall(line)
    parens_words = [p[1:-1] for p in parensed]

    if parens_words:
        line_chords = parse_line_chords(PARENS_REGEX.sub('', line))
        if line_chords:
            return line_chords, state

    if ((len(parens_words) > 1 or state['has_had_parens_chords']) and
        all([CHORD_REGEX.match(w) for w in parens_words])):
        state['has_had_parens_chords'] = True
        return parens_words, state

    return [], state
Beispiel #3
0
def parse_line_chords(line):
    words = line.split()
    if all([CHORD_REGEX.match(w) for w in words]):
        return words
    return []
Beispiel #4
0
def get_lab_chord(c):
    match = CHORD_REGEX.match(c.lower())
    root = match.group('root')
    chord = match.group('chord')
    return '%s%s' % (root.upper(), CHORD_SUBSET_MAP[chord])