songleaf.parse¶
Parse chords-over-lyrics text into a Song.
This is the format most chord sites use, and the one in the Kaggle corpus: a line of chord symbols, column-aligned over the lyric line it belongs to.
Each chord is anchored on the syllable under it (a chord over a space moves to the start of the next syllable).
A chord line with no lyric line under it (an intro, a solo) becomes an empty text line carrying its chords in order.
Section headers (
Verse 1:,[Chorus],Intro 2x: G D) become section annotations; a header with no lines of its own is a marker ({"marker": True}), usually meaning “play that section again”.Capo,Key/TomandTuninglines become metadata.Tablature and decoration lines (
e|--3--|,=====) are dropped.
>>> song = parse_chords_over_lyrics("Verse 1:\nC G\nHello there my friend")
>>> song.text
'Hello there my friend'
>>> [(a.start, a.body["symbol"]) for a in song.of_kind("chord")]
[(0, 'C'), (8, 'G')]
>>> song.of_kind("section")[0].body["label"]
'Verse 1'
Functions
|
True if every token is a chord or chord-line filler, and at least one is a chord. |
|
True if |
|
Parse chords-over-lyrics text into a |
- songleaf.parse.is_chord_line(line)[source]¶
True if every token is a chord or chord-line filler, and at least one is a chord.
- Return type:
>>> is_chord_line("G D/F# Em (x2)") True >>> is_chord_line("Bad Dad") False
- songleaf.parse.is_chord_token(token)[source]¶
True if
tokenreads as a chord symbol (G,F#m7b5,E7(#9),C/G).- Return type: