const fs = require("fs"); try { let json = fs.readFileSync("ShareGPT_V4.1_unfiltered_cleaned_split.json", "utf8"); var obj = JSON.parse(json); console.log("No structure problem"); let sameTalker = 0; let notEnoughTalkers = 0; //let dupeIndex = []; for (var i = 0; i < obj.length; i++) { let last = ""; if (obj[i]["conversations"].length <= 1) { // console.log(obj[i-1]["conversations"]); //console.log(obj[i]["conversations"][0]["from"]); notEnoughTalkers++; } for (var j = 0; j < obj[i]["conversations"].length; j++) { let conv = obj[i]["conversations"][j] if (last == conv["from"]) { //dupeIndex.push(i); sameTalker++; break; } last = conv["from"]; //console.log(last); } } console.log("Found empty or single-message " + notEnoughTalkers + " conversations"); console.log("Found subsequent messages in " + sameTalker + " conversations"); console.log("Total Bad Conversations: " + (sameTalker + notEnoughTalkers) + "/" + obj.length); console.log("Done") } catch (e) { // The JSON was invalid, `e` has some further information console.log(e); }