File size: 1,127 Bytes
07baa2c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
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);
}