Ejemplo n.º 1
0
    def format_sym(self, sym):
        is_roman = is_roman_numeral(sym)
        formatted_sym = sym
        # print 'format_sym', sym, is_roman

        if is_roman and self.symbol_type != 'roman':
            formatted_sym = self.rn2letter(sym)
        elif not is_roman and self.symbol_type == 'roman':
            formatted_sym = self.letter2rn(sym)

        if formatted_sym is not None:
            if self.symbol_type == 'roman':
                for k, v in ROMAN_PARTIAL_RELABELS.iteritems():
                    if k in formatted_sym:
                        formatted_sym = formatted_sym.replace(k, v)
            else:
                for k, v in LETTER_PARTIAL_RELABELS_FOR_USER.iteritems():
                    if k in formatted_sym:
                        formatted_sym = formatted_sym.replace(k, v)

        # check = sym2chord(sym)
        # if check is None:
        #     return None
        if formatted_sym == '':
            return sym, False
        return formatted_sym, True
Ejemplo n.º 2
0
 def roman(self, sym):
     if sym is None:
         return None
     if is_roman_numeral(sym):
         return sym
     else:
         return self.letter2rn(sym)
Ejemplo n.º 3
0
def duplicate_by_transposing_and_into_letters(seqs):
    assert is_roman_numeral(seqs[0][0])
    print "# of seqs:", len(seqs)
    augmented_seqs = []
    translation_dict = {}

    for seq in seqs:
        for i in range(12):
            transposed_seq = []
            for sym in seq:
                letter = roman2letter_transpose(sym, -i, translation_dict=translation_dict)
                transposed_seq.append(letter)

            augmented_seqs.append(transposed_seq)
    print "# of augmented_seqs:", len(augmented_seqs)
    print "translation_dict"
    for key, val in translation_dict.iteritems():
        print key, val
    for seq in augmented_seqs:
        print seq[:6]
    assert len(seqs) * 12 == len(augmented_seqs)
    return augmented_seqs, translation_dict
Ejemplo n.º 4
0
 def back_to_roman(self, sym):
     is_roman = is_roman_numeral(sym)
     if not is_roman:
         sym = self.letter2rn(sym)
     return sym
Ejemplo n.º 5
0
 def letter(self, sym):
     if is_roman_numeral(sym):
         return self.rn2letter(sym)
     else:
         return sym