|
import json
|
|
|
|
|
|
with open('discord_logs.json', 'r') as json_file:
|
|
data = json.load(json_file)
|
|
|
|
|
|
minimum_average_token_length = 125
|
|
minimum_median_token_length = 125
|
|
minimum_conversations_length = 6
|
|
|
|
|
|
filtered_items = [
|
|
item for item in data
|
|
if item.get('average_token_length', 0) >= minimum_average_token_length
|
|
and item.get('median_token_length', 0) >= minimum_median_token_length
|
|
and len(item.get('conversations', [])) >= minimum_conversations_length
|
|
]
|
|
|
|
|
|
with open(f'{minimum_median_token_length}_tokens_{minimum_conversations_length}_messages.json', 'w') as filtered_json_file:
|
|
json.dump(filtered_items, filtered_json_file, indent=4)
|
|
|
|
|
|
for i, item in enumerate(filtered_items):
|
|
print(f"Filtered Item {i + 1} - Average Token Length: {item.get('average_token_length')}, Conversations Length: {len(item.get('conversations', []))}") |