JonXL
Active member
- Local time
- Today, 02:40
- Joined
- Jul 9, 2021
- Messages
- 158
I'm working on a script that will clean up and transpose chord/lyric sheets. Here's a couple examples of what I mean - the chords are the letters atop the lyrics.
The basic form is that the script runs through the range line by line (as split into an array on each new line) and then within the chord line breaks it down into each chord which can then be separately cleaned up/transposed and put back into the string to update the original line ultimately to be written back to the range...
Everything is working well with one exception: I cannot figure out a reliable way to distinguish a line of chords from a line of lyrics.
If I can place the chord line in a specific place (eg, every other line), there is little issue identifying the chord line. But that's not how the real world works - often there are double-enters between groupings of verses, or chords-only/lyrics-only lines, etc. So... how to 'spot' when running through the lines which line has chords vs lyrics... ?
I've thought of maybe trying to identify if there are any real words in a line and thus excluding it - but that would fail on things like A or Am. While I could maybe accommodate that, I'd still have the issue of figuring out if a word is a real word (can I look in the Word dictionary?). Outside that, I can't think of a decent way to do this. I get this is kind of more of a business logic question than one basically on the scripting, but I'm hoping that the group here will be able to spot some additional business logic possibilities given the technology that I've missed.
Any help appreciated!
Code:
G
All of my love all of my kissing
You don't know what you've been a missing
C G
Oh boy when you're with me oh boy
D7 G
The world will see that you were meant for me
All of my life I've been a waiting
Tonight there'll be no hesitating
C G
Oh boy when you're with me oh boy
D7 G
The world will see that you were meant for me
Code:
Em G
Today is gonna be the day
D A7sus4
That they're gonna throw it back to you
Em G
By now you should've somehow
D A7sus4
Realised what you gotta do
Em G
I don't believe that anybody
D A7sus4 Em G D A7sus4
Feels the way I do about you now
The basic form is that the script runs through the range line by line (as split into an array on each new line) and then within the chord line breaks it down into each chord which can then be separately cleaned up/transposed and put back into the string to update the original line ultimately to be written back to the range...
Everything is working well with one exception: I cannot figure out a reliable way to distinguish a line of chords from a line of lyrics.
If I can place the chord line in a specific place (eg, every other line), there is little issue identifying the chord line. But that's not how the real world works - often there are double-enters between groupings of verses, or chords-only/lyrics-only lines, etc. So... how to 'spot' when running through the lines which line has chords vs lyrics... ?
I've thought of maybe trying to identify if there are any real words in a line and thus excluding it - but that would fail on things like A or Am. While I could maybe accommodate that, I'd still have the issue of figuring out if a word is a real word (can I look in the Word dictionary?). Outside that, I can't think of a decent way to do this. I get this is kind of more of a business logic question than one basically on the scripting, but I'm hoping that the group here will be able to spot some additional business logic possibilities given the technology that I've missed.
Any help appreciated!
