-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclassify.py
More file actions
37 lines (30 loc) · 1.09 KB
/
Copy pathclassify.py
File metadata and controls
37 lines (30 loc) · 1.09 KB
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
import json
# 1. Load your JSON data
print("Loading task_dataset.json...")
with open('task_dataset.json', 'r', encoding='utf-8') as f:
data = json.load(f)
# 2. Define the logic to decide Easy/Medium/Hard
def determine_complexity(text):
# In the real paper, they used AI. Here, we use length as a proxy.
word_count = len(text.split())
if word_count < 50:
return "Easy"
elif word_count < 100:
return "Medium"
else:
return "Hard"
# 3. Update the data
print("Classifying tasks...")
for task in data:
# Get the description
description = task['problem_description']
# Calculate complexity
new_label = determine_complexity(description)
# Update the JSON entry
task['complexity_label'] = new_label
print(f"Task: {task['task_title']} -> Classified as: {new_label}")
# 4. Save the updated JSON (Overwriting the old one)
with open('task_dataset.json', 'w', encoding='utf-8') as f:
json.dump(data, f, indent=4)
print("--------------------------------------------------")
print("SUCCESS: Your JSON file now has complexity labels!")