<commit_before># Utility functions for thumbnail GENERATION_RE

import os

def build_thumbnail_filepath(image_filepath, thumbnail_root_dir):
    '''
    Builds the thumbnail file path as thumbnail_dir/collection/dataset/version/<name>.png
    '''
    
    (dirname, filename) = os.path.split( image_filepath )
    (name, ext) = os.path.splitext(filename)
    dirparts = dirname.split("/")
    if dirparts[-1]=="1":
        subdir = "/".join( dirparts[-3:] )
    else:
        subdir = "/".join(dirparts[-2:].join("/")) + "1/"
    
    thumbnail_dir = os.path.join(thumbnail_root_dir, subdir)
    if not os.path.exists(thumbnail_dir):
        os.makedirs(thumbnail_dir)
    thumb_filepath = os.path.join(thumbnail_dir, name + ".png")
    
    return thumb_filepath<commit_msg>Fixing problem with thumbnail path<commit_after># Utility functions for thumbnail GENERATION_RE

import os

def build_thumbnail_filepath(image_filepath, thumbnail_root_dir):
    '''
    Builds the thumbnail file path as thumbnail_dir/collection/dataset/version/<name>.png
    '''
    
    labcas_archive = os.environ.get('LABCAS_ARCHIVE','')
    thumbnail_dir = image_filepath.replace(labcas_archive, thumbnail_root_dir)
    if not os.path.exists(thumbnail_dir):
        os.makedirs(thumbnail_dir)

    thumb_filepath = thumbnail_dir + ".png"
    return thumb_filepath
{'fraction_non_alphanumeric': 0.11764705882352941, 'fraction_numerical': 0.0037230081906180195, 'mean_word_length': 3.7829181494661923, 'pattern_counts': {'":': 1, '<': 5, '<?xml version=': 0, '>': 5, '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': '7488208', 'n_tokens_mistral': 452, 'n_tokens_neox': 446, 'n_words': 84}