File size: 851 Bytes
9ec26b4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import json
import random
import re
import names

def parse_example(example):
    parsed_objects = []
    for i in range(len(example)):
        text = """A transcript of a roleplay chat between several participants."""

        for j in range(len(example[i]['conversations'])):
          sender = example[i]['conversations'][j]['author']
          text += f"\n{sender}: {example[i]['conversations'][j]['message']}"

        parsed_objects.append({"text": text.strip()})

    return parsed_objects

# Load the JSON file containing numerous objects
with open('discord_logs.json', 'r', encoding="UTF-8") as file:
    data = json.load(file)

parsed_data = parse_example(data)

# Save the parsed data to a new JSON file
with open('discord_logs_vicuna.json', 'w') as output_file:
    json.dump(parsed_data, output_file, indent=2)