beir-embed-english-v3 / create_yaml.py
nreimers's picture
add
82568a3
raw
history blame contribute delete
853 Bytes
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())