-------- Original-Nachricht --------
> Datum: Thu, 20 Dec 2007 00:01:05 +0900
> Von: Lunatic Denial <lunatic / aunetic.org>
> An: ruby-talk / ruby-lang.org
> Betreff: Music notation ABC

> Hi,
> 
> Do you know something about library for parse ABC music notation?
> 
> I want something or write something to load files containig mutliple ABC
> tunes, organise then cherche for similar tunes in the files, create
> listes of tunes from the files, sets of tunes and books of sets whith
> index.
> 
> I leanr Ruby (beginner) and I think it's a good thing o do for a
> musician to work around is center of interests.
> 
> Here is a linl about ABC notation: http://www.walshaw.plus.com/abc/
> 
> Thanks for informations and afflicted to make you undergo my aglais.
> -- 
> Posted via http://www.ruby-forum.com/.

Hello,

welcome to Ruby :).
I couldn't find any ready-made library for abc in Ruby.
But as the link you gave shows that the notation is done in ASCII
text, you can search that text for tune bits (=Strings) or
for Regular Expressions. These are patterns which allow you
to search for occurrences of many strings at the same time, e.g.,
you can search for all Strings having 

"at least three, but at most
five occurrences of any of "a","b","c", followed but a letter, which
is anything but "C" or "D", then something arbitrary and a "c" at the
end."

The corresponding Regexp is 

reg=/[a-c]{3,5}[^CD].+c$/  . So, for

tune1="CDEabcacdAAc"
tune2="CDabcacdCCc"
ref1=reg.match(tune1)
ref2=reg.match(tune2)
p ref1[0] => "abcacdAAc"
p ref2[0] => "abcacdCCc"


There is more comprehensive information about what Regexps
can do for you here:

http://www.rubyist.net/~slagell/ruby/regexp.html
http://www.regular-expressions.info/ruby.html .

I know too little about music to say what similarity between
tunes might mean to a musician (... please tell me) , but I guess
it can somewhat be boiled down to the number of replacements
on tune1 to get to tune2 (possibly one needs to exclude some
tunes that are too awkward using a Regexp search first).

This is what Levenstein distance 
(http://en.wikipedia.org/wiki/Levenshtein_distance)
and the diff/lcs algorithms do.

A Ruby implementation of Levenstein distance is here:

http://rubyforge.org/projects/text

Diff/LCS is implemented here:

http://raa.ruby-lang.org/project/diff-lcs/


Best regards,

Axel 


-- 
Psssst! Schon vom neuen GMX MultiMessenger geh÷˛t?
Der kann`s mit allen: http://www.gmx.net/de/go/multimessenger?did=10