Loading ...
Sorry, an error occurred while loading the content.

Re: [Clip] Extracting text from a music .XML file.

Expand Messages
  • Don
    ^!Set %WordCountMaster%=^?{Race Division=1|2|3|4|5|6|7|_8|9|10} ^!Find @ CIWS ^!IfError Skip ^!Continue Program will bomb it has an @ sign in the text.
    Message 1 of 47 , Nov 12, 2012
    • 0 Attachment
      ^!Set %WordCountMaster%=^?{Race Division=1|2|3|4|5|6|7|_8|9|10}

      ^!Find "@" CIWS
      ^!IfError Skip
      ^!Continue Program will bomb it has an @ sign in the text.
      ^!Find "|" CIWS
      ^!IfError Skip
      ^!Continue Program will bomb it has an | character in the text.

      ^!Jump Doc_Start

      ^!Set %LyricCounter%="1"

      :GatherLoop
      ^!Set %LyricEnd%="^%LyricCounter%"

      ;long line follows
      ^!Set %Lyrics^%LyricCounter%%="^$GetDocListAll(" *\<lyric
      number\="^%LyricCounter%"\>\r\n *\<syllabic\>(.*?)\</syllabic\>\r\n
      *\<text\>(.*?)\</text\>\r\n *\</lyric\>";"$1|$2@")$"
      ;long line precedes
      ^!If "^%Lyrics^%LyricCounter%%" = "" Process
      ^!Inc %LyricCounter%
      ^!Goto GatherLoop

      :Process
      ^!Set %LyricCounter%="1"
      ^!Select All

      :ProcessLoop
      ^!If "^%LyricCounter%" = "^%LyricEnd%" FinishIt
      ^!InsertText Lyrics ^%LyricCounter%:^P^%Lyrics^%LyricCounter%%^P
      ^!Inc %LyricCounter%
      ^!Goto ProcessLoop

      :FinishIt

      ;alternate
      :LineLoop
      ^!Jump Doc_Start
      :LineLoopVerse

      ^!Set %WordCount%=^$Calc(^%WordCountMaster%-1)$

      :LineLoop2
      ^!Replace "(.*?@){^%WordCount%}\K(.*?@)" >> "$2\r\n" RS
      ^!IfError ProcessNext
      ^!If "^%WordCount%" = "^$Calc(^%WordCountMaster%-1)$" Minus ELSE Plus
      :Minus
      ^!Dec %WordCount%
      ^!Goto LineLoop2
      :Plus
      ^!Inc %WordCount%
      ^!Goto LineLoop2

      :ProcessNext
      ^!If "^$GetLineCount$" = "^$GetRow$" DoneProcess ELSE Next
      ^!Jump +1
      ^!Goto LineLoopVerse

      :DoneProcess

      ^!Replace "begin\|(.*?)@" >> "$1" RAWS
      ^!Replace "middle\|(.*?)@" >> "$1" RAWS
      ^!Replace "single\|(.*?)@" >> " $1 " RAWS
      ^!Replace "end\|(.*?)@" >> "$1 " RAWS
      ^!Replace "@" >> " " ACIWS
      ^!Replace " +" >> " " RAWS
      ^!Replace "^ +" >> "" RAWS
      ^!Replace " +$" >> "" RAWS


      Yields this ...

      Lyrics 1:
      People sing your country's an them,
      Shout your land's undying fame;
      Light the wondrous tale of nat ions
      With you people's gol den name.
      Tell your forebear's noble stor y,
      Raise on high your coun try's sign;
      Join, then, in the final glory
      Come and lift your flag with mine.

      Lyrics 2:
      Hail the sun of peace now ris ing;
      Hold the warclouds ever furled;
      Blend your banners, sister, broth er,
      In the rainbow of the world!
      Red as blood and blue as heav en,
      Wise as age and proud as youth,
      Melt your col ours, wonder wov en
      In the glowing light of truth.

      Lyrics 3:
      Build the road of peace before us,
      Build it wide and deep and long;
      Speed the slow and check the eag er,
      Help the weak and curb the strong.
      None shall push aside anoth er,
      None shall let anoth er fail:
      March beside me sister, broth er,
      All for one and one for all!



      There are a few weird spaces ... like eag er and anoth er but if you
      look the second syllable is marked as "single". I assume that is
      because you need to stay on the "beat" or something.

      I also assume that you are saying that the 87 is not in the coding so
      you have to tell it 8.
    • Adrian Worsfold
      Hello flo Brilliant. Later on today I will alter the clip and instructions on my webpage. How you have managed to account for different line lengths in verses
      Message 47 of 47 , Nov 16, 2012
      • 0 Attachment
        Hello flo

        Brilliant. Later on today I will alter the clip and instructions on my webpage. How you have managed to account for different line lengths in verses baffles me but thanks and I'll give appropriate thanks on the webpage when I re do it, including your further advice.




        Adrian Worsfold

        http://www.pluralist.co.uk
        http://pluralistspeaks.blogspot.com
        pluralist@...
        16-11-2012
        ----- Received the following content -----
        From: flo.gehrke
        Receiver: ntb-clips
        Time: 2012-11-16, 13:42:25
        Subject: Re: [Clip] Extracting text from a music .XML file.


        [Non-text portions of this message have been removed]
      Your message has been successfully submitted and would be delivered to recipients shortly.