Fix common path issues in the JSON data: 1. Replace 'selected_chart2code_benchmark_data' in directory names with '-data' 2. Handle duplicated path segments
(path_str: str)
| 1035 | |
| 1036 | |
| 1037 | def fix_path(path_str: str) -> str: |
| 1038 | """ |
| 1039 | Fix common path issues in the JSON data: |
| 1040 | 1. Replace 'selected_chart2code_benchmark_data' in directory names with '-data' |
| 1041 | 2. Handle duplicated path segments |
| 1042 | """ |
| 1043 | if not path_str or not isinstance(path_str, str): |
| 1044 | return path_str |
| 1045 | |
| 1046 | import re |
| 1047 | |
| 1048 | # Fix pattern 1: xxx-selected_chart2code_benchmark_data -> xxx-data |
| 1049 | # Example: yukawithdata_taylor-swift-the-eras-tour-official-setlist-selected_chart2code_benchmark_data |
| 1050 | pattern1 = r'([\w-]+)-selected_chart2code_benchmark_data' |
| 1051 | path_str = re.sub(pattern1, r'\1-data', path_str) |
| 1052 | |
| 1053 | # Fix pattern 2: xxxselected_chart2code_benchmark_data (without dash) -> xxx-data |
| 1054 | # Example: zyrkzys_beaverselected_chart2code_benchmark_data |
| 1055 | pattern2 = r'([\w]+)selected_chart2code_benchmark_data' |
| 1056 | path_str = re.sub(pattern2, r'\1-data', path_str) |
| 1057 | |
| 1058 | return path_str |
| 1059 | |
| 1060 | |
| 1061 | def run_benchmark(args): |