JSONL 文件的检查和修订器
下面是一个JSONL 文件的检查和修订器,代码如下:
import json
import tkinter as tk
from tkinter import filedialog, messagebox
def check_jsonl_file(input_file, log_file, output_file=None):
errors = []
valid_lines = []
with open(input_file, 'r', encoding='utf-8') as infile, open(log_file, 'w', encoding='utf-8') as logfile:
for line_number, line in enumerate(infile, start=1):
try:
data = json.loads(line)
if not (
"question" in data and
"xihe_answers" in data and
"ling_answers" in data and
isinstance(data["question"], str) and
isinstance(data["xihe_answers"], list) and