CoolFace
Apppublic

CalebKoster/Translation_Note_Alignment

sourceHugging Faceupdated 3y agoView on Hugging Face
0likes
tsv_parse27 linesDownload Raw Back to tests
1import csv2 3def parse_tsv_to_json(filepath, book_abbrev):4    result = []  # Initialize an empty list to store the dictionaries.5    6    with open(filepath, mode='r', encoding='utf-8') as file:7        tsv_reader = csv.reader(file, delimiter='\t')8        9        for row in tsv_reader:10            # Check if the row contains a Greek term (non-empty) in the expected position.11            if row and len(row) > 3 and row[4].strip():12                # Construct a dictionary for the current row.13                entry = {14                    "greek_term": row[4].strip(),15                    "translation_note": row[6].strip(),16                    "verse": book_abbrev + row[0].strip()17                }18                # Append the dictionary to the result list.19                result.append(entry)20    21    return result22 23# Example usage24result = parse_tsv_to_json('./translation_notes/tn_ROM.tsv', 'rom')25 26# Print first 5 entries27print(result[:5])