@@ -256,12 +256,21 @@ def _changeRepresentation(self) -> None:
256256 if self .dcml_version == 2 :
257257 self .chord = self .chord .replace ('%' , 'ø' )
258258 self .chord = handleAddedTones (self .chord )
259+ # prefix figures for Mm7 chords on degrees other than 'V' with 'd'
259260 if (
260261 self .extra .get ('chord_type' , '' ) == 'Mm7'
261262 and self .numeral != 'V'
262263 ):
263- # we need to make sure not to match [add4] and the like
264- self .chord = re .sub (r'(\d+)(?!])' , r'd\1' , self .chord )
264+ # However, we need to make sure not to match [add13] and
265+ # the like, otherwise we will end up with [addd13]
266+ self .chord = re .sub (
267+ r'''
268+ (\d+) # match one or more digits
269+ (?![\]\d]) # without a digit or a ']' to the right
270+ ''' ,
271+ r'd\1' ,
272+ self .chord ,
273+ flags = re .VERBOSE )
265274
266275 # Local - relative and figure
267276 if isMinor (self .local_key ):
@@ -869,7 +878,10 @@ def _m21ToTsv_v2(self) -> list[list[str]]:
869878 relativeroot = characterSwaps (
870879 relativeroot , isMinor (local_key ), direction = 'm21-DCML'
871880 )
872- thisEntry .chord = thisRN .figure # NB: slightly different from DCML: no key.
881+ # We replace the "d" annotation for Mm7 chords on degrees other than
882+ # V because it is not used by the DCML standard
883+ # NB: slightly different from DCML: no key.
884+ thisEntry .chord = thisRN .figure .replace ('d' , '' , 1 )
873885 thisEntry .pedal = None
874886 thisEntry .numeral = thisRN .romanNumeral
875887 thisEntry .form = getForm (thisRN )
0 commit comments