|
import glob
|
|
import os
|
|
|
|
def read_folder(folder):
|
|
folder_name = os.path.basename(folder)
|
|
|
|
template = f"""- config_name: {folder_name}-corpus
|
|
data_files:
|
|
- split: train
|
|
path: {folder_name}/corpus/*
|
|
- config_name: {folder_name}-queries
|
|
data_files:"""
|
|
|
|
for filepath in glob.glob(f"{folder}/queries/*.parquet"):
|
|
template += f"""
|
|
- split: {os.path.basename(filepath).split('.')[0]}
|
|
path: {filepath}"""
|
|
|
|
template += f"""
|
|
- config_name: {folder_name}-qrels
|
|
data_files:"""
|
|
for filepath in glob.glob(f"{folder}/qrels/*.parquet"):
|
|
template += f"""
|
|
- split: {os.path.basename(filepath).split('.')[0]}
|
|
path: {filepath}"""
|
|
|
|
return template
|
|
|
|
|
|
|
|
|
|
for filepath in sorted(glob.glob("*")):
|
|
if os.path.isdir(filepath):
|
|
print(read_folder(filepath).strip())
|
|
|