craffel / mir_eval

Evaluation functions for music/audio information retrieval/signal processing algorithms.
MIT License
604 stars 112 forks source link

switched chord label validation to regexp method #242

Closed bmcfee closed 7 years ago

bmcfee commented 7 years ago

This fixes #217 by using a regexp to parse chords, rather than explicit case splitting.

The regexp is ported over from JAMS, where it has already been thoroughly tested. I added an extra test case 'asdf' that was mentioned in the #217 thread as previously passing.

Because the regexp is such a monster, I disabled the pep8 length check for the corresponding line.

bmcfee commented 7 years ago

Thanks. I assume chord experts (@ejhumphrey @mattmcvicar or others) have given this a thorough run-through in JAMS?

Yup. It's exactly the grammar from Harte's paper (which is right-recursive and hence regular, hurray for the chomsky language hierarchy!), with additional terminals for X, 1, 5, 13, and sus2 chords. The code to generate the regexp is here and there are extensive unit tests within jams.