<commit_before>from symbtr import getTrueLyricsIdx
from structure_label import labelStructures, get_symbtr_labels

def extractAnnotatedPhrase(score, sections = [], lyrics_sim_thres = 0.25, melody_sim_thres = 0.25):
    bound_codes = [51,53,54,55]
    anno_codes = [53,54,55]

    all_bounds = [i for i, code in enumerate(score['code']) if code in bound_codes]
    anno_bounds = [i for i, code in enumerate(score['code']) if code in anno_codes]
    if anno_bounds:
        phrases = extractPhrases(all_bounds, score, sections = sections, lyrics_sim_thres = 0.25, 
            melody_sim_thres = 0.25)
    else:
        phrases = []

    return phrases

def extractAutoSegPhrase(score, autoSegBounds, sections = [], lyrics_sim_thres = 0.25, melody_sim_thres = 0.25):
    # Boundaries start from 1, convert them to python indexing (0) by subtracting 1
    autoSegBound_idx = [a-1 for a in autoSegBounds]

    if autoSegBound_idx:
        phrases = extractPhrases(autoSegBound_idx, score, sections = sections, lyrics_sim_thres = 0.25, 
            melody_sim_thres = 0.25)
    else:
        phrases = []

    return phrases<commit_msg>Fixed an error when the automatic phrase segmentation exsits but empty<commit_after>from symbtr import getTrueLyricsIdx
from structure_label import labelStructures, get_symbtr_labels

def extractAnnotatedPhrase(score, sections = [], lyrics_sim_thres = 0.25, melody_sim_thres = 0.25):
    bound_codes = [51,53,54,55]
    anno_codes = [53,54,55]

    all_bounds = [i for i, code in enumerate(score['code']) if code in bound_codes]
    anno_bounds = [i for i, code in enumerate(score['code']) if code in anno_codes]
    if anno_bounds:
        phrases = extractPhrases(all_bounds, score, sections = sections, lyrics_sim_thres = 0.25, 
            melody_sim_thres = 0.25)
    else:
        phrases = []

    return phrases

def extractAutoSegPhrase(score, autoSegBounds, sections = [], lyrics_sim_thres = 0.25, melody_sim_thres = 0.25):
    # Boundaries start from 1, convert them to python indexing (0) by subtracting 1
    try:
        autoSegBound_idx = [a-1 for a in autoSegBounds]

        if autoSegBound_idx:
            phrases = extractPhrases(autoSegBound_idx, score, sections = sections, lyrics_sim_thres = 0.25, 
                melody_sim_thres = 0.25)
        else:
            phrases = []
    except TypeError:  # the json saved by MATLAB phrase segmentation sends a special structure 
        # specifying the 0 dimensional array 
        phrases = []

    return phrases
{'fraction_non_alphanumeric': 0.08545310015898251, 'fraction_numerical': 0.033783783783783786, 'mean_word_length': 3.3697916666666665, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3602223', 'n_tokens_mistral': 874, 'n_tokens_neox': 795, 'n_words': 227}