trop.auxilary

View Source
 0import re
 1
 2def change_extractor(list):
 3    ''' Function extracting the melodic changes from the input
 4    
 5    Parameter: 
 6    ----------
 7    list: list
 8        list of the split input string
 9    
10    Return:
11    ----------
12    changes: list
13        list of the melodic changes as integers
14    
15    '''
16    changes = []
17    for i in range(len(list)):
18        if list[i][0].isdigit():
19            changes.append(int(list[i][0]))
20        else:
21            changes.append(-int(list[i][1]))    
22    return changes
23
24
25
26def get_lyric(input):
27    ''' Function retrieving the lyrics from the input
28    
29    Parameter:
30    ---------
31    input: str
32        split off input string
33
34    Return:
35    --------
36    lyric: str
37        Lyric from the string
38    '''
39    
40    assert isinstance(input, str), "invalid input"
41    if input.count('(') == 1:
42        lyric = re.search(r'\((.*?)\)',input).group(1)
43    else:
44        lyric = ''
45    return lyric
#   def change_extractor(list):
View Source
 3def change_extractor(list):
 4    ''' Function extracting the melodic changes from the input
 5    
 6    Parameter: 
 7    ----------
 8    list: list
 9        list of the split input string
10    
11    Return:
12    ----------
13    changes: list
14        list of the melodic changes as integers
15    
16    '''
17    changes = []
18    for i in range(len(list)):
19        if list[i][0].isdigit():
20            changes.append(int(list[i][0]))
21        else:
22            changes.append(-int(list[i][1]))    
23    return changes

Function extracting the melodic changes from the input

Parameter:

list: list list of the split input string

Return:

changes: list list of the melodic changes as integers

#   def get_lyric(input):
View Source
27def get_lyric(input):
28    ''' Function retrieving the lyrics from the input
29    
30    Parameter:
31    ---------
32    input: str
33        split off input string
34
35    Return:
36    --------
37    lyric: str
38        Lyric from the string
39    '''
40    
41    assert isinstance(input, str), "invalid input"
42    if input.count('(') == 1:
43        lyric = re.search(r'\((.*?)\)',input).group(1)
44    else:
45        lyric = ''
46    return lyric

Function retrieving the lyrics from the input

Parameter:

input: str split off input string

Return:

lyric: str Lyric from the string