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

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

Expand Messages
  • flo.gehrke
    ... I m still playing with the sample code we saw in the first message #23352 of this topic (haven t seen any other sample so far). Now that we ve got a kind
    Message 1 of 47 , Nov 14, 2012
      --- In ntb-clips@yahoogroups.com, Don <don@...> wrote:
      >
      > Do over ... this is syllable sensitive ... though I am sure
      > there is an easier way (...)
      >
      > ^!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%: ^%Lyrics^%LyricCounter%%^P
      > ^!Inc %LyricCounter%
      > ^!Goto ProcessLoop
      >
      > :FinishIt
      > ^!Replace "begin\|(.*?);" >> "$1" RAWS
      > ^!Replace "middle\|(.*?);" >> "$1" RAWS
      > ^!Replace "single\|(.*?);" >> " $1 " RAWS
      > ^!Replace "end\|(.*?);" >> "$1 " RAWS
      > ^!Replace ";" >> " " ACIWS
      > ^!Replace " +" >> " " RAWS

      I'm still playing with the sample code we saw in the first message #23352 of this topic (haven't seen any other sample so far).

      Now that we've got a kind of rule for inserting spaces we could possibly shorten Don's last proposal a bit as follows. The clip starts with inserting spaces:


      ^!Replace "<syllabic>(?:single|end)\X+?<text>\w+\K" >> "\x20" WARS
      ^!Select All
      ^$GetDocListAll("^\x20*<lyric number="(\d+)\X+?<text>([\w\x20]+)";$1|$2\r\n)$
      ^!Set %Nr%=1

      :Loop
      ^!Set %Text%=^$GetDocListAll("^^%Nr%\|(.+)";"$1")$
      ^!IfEmpty ^%Text% Out
      ^!Append %All%=Lyrics^%Nr%:^%Space%^%Text%^P
      ^!Inc %Nr%
      ^!Goto Loop

      :Out
      ^!Select All
      ^!InsertText ^%All%
      ^!ClearVariables


      As with Don's proposal, the output is:

      Lyrics1: People
      Lyrics2: Hail the
      Lyrics3: Build the

      Regards,
      Flo
    • 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
        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.