def extract_features(filename): features = {} # File type features['FileExtension'] = filename.split('.')[-1] # Content type (inferred from extension) if features['FileExtension'] == 'rar': features['ContentType'] = 'CompressedArchive' # Temporal and descriptive features match = re.search(r'(\d{4})', filename) if match: features['Year'] = int(match.group(0)) months = re.search(r'(\w+)-(\w+)', filename) if months: month_map = { 'Jan': 1, 'Feb': 2, 'Mar': 3, 'Apr': 4, 'May': 5, 'Jun': 6, 'Jul': 7, 'Aug': 8, 'Sep': 9, 'Oct': 10, 'Nov': 11, 'Dec': 12 } start_month = month_map[months.group(1)] end_month = month_map[months.group(2)] features['MonthsIncluded'] = list(range(start_month, end_month + 1)) # Probable content if 'Loops' in filename: features['ProbableContent'] = 'MusicLoops' # Naming convention components = filename.replace('.rar', '').split('_') features['Prefix'] = components[0] features['Suffix'] = '_'.join(components[1:]) features['FilenameComponents'] = components return features

# Example usage filename = "SFMDH_2021_Loops_Jan-Apr.rar" features = extract_features(filename) for feature, value in features.items(): print(f"{feature}: {value}") This script defines a function extract_features that takes a filename and attempts to extract various features based on its name and extension. The example usage demonstrates how to use this function with the provided filename.

import re from datetime import datetime


Loading

File: Sfmdh_2021_loops_jan-apr.rar ... Access

def extract_features(filename): features = {} # File type features['FileExtension'] = filename.split('.')[-1] # Content type (inferred from extension) if features['FileExtension'] == 'rar': features['ContentType'] = 'CompressedArchive' # Temporal and descriptive features match = re.search(r'(\d{4})', filename) if match: features['Year'] = int(match.group(0)) months = re.search(r'(\w+)-(\w+)', filename) if months: month_map = { 'Jan': 1, 'Feb': 2, 'Mar': 3, 'Apr': 4, 'May': 5, 'Jun': 6, 'Jul': 7, 'Aug': 8, 'Sep': 9, 'Oct': 10, 'Nov': 11, 'Dec': 12 } start_month = month_map[months.group(1)] end_month = month_map[months.group(2)] features['MonthsIncluded'] = list(range(start_month, end_month + 1)) # Probable content if 'Loops' in filename: features['ProbableContent'] = 'MusicLoops' # Naming convention components = filename.replace('.rar', '').split('_') features['Prefix'] = components[0] features['Suffix'] = '_'.join(components[1:]) features['FilenameComponents'] = components return features

# Example usage filename = "SFMDH_2021_Loops_Jan-Apr.rar" features = extract_features(filename) for feature, value in features.items(): print(f"{feature}: {value}") This script defines a function extract_features that takes a filename and attempts to extract various features based on its name and extension. The example usage demonstrates how to use this function with the provided filename. File: SFMDH_2021_Loops_Jan-Apr.rar ...

import re from datetime import datetime