Datasets:
Delete token_filter.py
Browse files- token_filter.py +0 -24
token_filter.py
DELETED
|
@@ -1,24 +0,0 @@
|
|
| 1 |
-
import json
|
| 2 |
-
|
| 3 |
-
# Load the JSON data from your file
|
| 4 |
-
with open('your_json_file_here.json', 'r') as json_file:
|
| 5 |
-
data = json.load(json_file)
|
| 6 |
-
|
| 7 |
-
# Define the minimum values for filtering
|
| 8 |
-
minimum_average_token_length = 125 # Set your desired minimum average token length
|
| 9 |
-
minimum_conversations_length = 10 # Set your desired minimum length of the 'conversations' array
|
| 10 |
-
|
| 11 |
-
# Filter the items that meet the minimum criteria
|
| 12 |
-
filtered_items = [
|
| 13 |
-
item for item in data
|
| 14 |
-
if item.get('average_token_length', 0) >= minimum_average_token_length
|
| 15 |
-
and len(item.get('conversations', [])) >= minimum_conversations_length
|
| 16 |
-
]
|
| 17 |
-
|
| 18 |
-
# Save the filtered items to a new JSON file
|
| 19 |
-
with open('filtered_json_file.json', 'w') as filtered_json_file:
|
| 20 |
-
json.dump(filtered_items, filtered_json_file, indent=4)
|
| 21 |
-
|
| 22 |
-
# Optionally, you can print the filtered items
|
| 23 |
-
for i, item in enumerate(filtered_items):
|
| 24 |
-
print(f"Filtered Item {i + 1} - Average Token Length: {item.get('average_token_length')}, Conversations Length: {len(item.get('conversations', []))}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|