marksaroufim
commited on
Commit
·
a8d95cd
1
Parent(s):
05a6587
yolo
Browse files- output_dataset.parquet +2 -2
- process.py +10 -6
- viz.py +1 -1
output_dataset.parquet
CHANGED
@@ -1,3 +1,3 @@
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:
|
3 |
-
size
|
|
|
1 |
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:b81f2017ea6db55ced797c0fa4045bae4927347ea42dc041d02f1ea6b856616e
|
3 |
+
size 22517556
|
process.py
CHANGED
@@ -34,7 +34,7 @@ def collect_data(directory):
|
|
34 |
# Adjust the pattern if problem IDs include characters before "sol"
|
35 |
problem_id = re.sub(r'sol$', '', mfile.split('.')[0]) # Strip "sol" from end
|
36 |
if problem_id not in data:
|
37 |
-
data[problem_id] = {'Problem ID': problem_id, 'Images': [], 'in': None, 'out': None, 'cpp': None, '
|
38 |
|
39 |
# Now associate other files with these problem IDs
|
40 |
for filename in os.listdir(directory):
|
@@ -44,12 +44,16 @@ def collect_data(directory):
|
|
44 |
file_path = os.path.join(directory, filename)
|
45 |
content = encode_file(file_path) if not filename.endswith('.jpg') else None
|
46 |
|
47 |
-
if file_type in ['in', 'out', 'cpp'
|
48 |
data[problem_id][file_type] = content
|
49 |
-
|
50 |
-
|
51 |
-
data[problem_id]['
|
52 |
-
|
|
|
|
|
|
|
|
|
53 |
|
54 |
return list(data.values())
|
55 |
|
|
|
34 |
# Adjust the pattern if problem IDs include characters before "sol"
|
35 |
problem_id = re.sub(r'sol$', '', mfile.split('.')[0]) # Strip "sol" from end
|
36 |
if problem_id not in data:
|
37 |
+
data[problem_id] = {'Problem ID': problem_id, 'Images': [], 'in': None, 'out': None, 'cpp': None, 'Problem': None, 'Solution': None}
|
38 |
|
39 |
# Now associate other files with these problem IDs
|
40 |
for filename in os.listdir(directory):
|
|
|
44 |
file_path = os.path.join(directory, filename)
|
45 |
content = encode_file(file_path) if not filename.endswith('.jpg') else None
|
46 |
|
47 |
+
if file_type in ['in', 'out', 'cpp']:
|
48 |
data[problem_id][file_type] = content
|
49 |
+
if file_type == "md":
|
50 |
+
if "sol" in filename:
|
51 |
+
data[problem_id]['Solution'] = content
|
52 |
+
else:
|
53 |
+
data[problem_id]['Problem'] = content
|
54 |
+
image_ids = extract_images(content)
|
55 |
+
data[problem_id]['Images'] += [image_files[id] for id in image_ids if id in image_files]
|
56 |
+
data[problem_id]['Images'] = list(set(data[problem_id]['Images'])) # Remove duplicates
|
57 |
|
58 |
return list(data.values())
|
59 |
|
viz.py
CHANGED
@@ -8,7 +8,7 @@ df = pd.read_parquet('output_dataset.parquet')
|
|
8 |
print(df.columns)
|
9 |
|
10 |
# Display the first few rows of the dataframe
|
11 |
-
print(df
|
12 |
|
13 |
|
14 |
# Basic statistics for numerical columns
|
|
|
8 |
print(df.columns)
|
9 |
|
10 |
# Display the first few rows of the dataframe
|
11 |
+
print(df)
|
12 |
|
13 |
|
14 |
# Basic statistics for numerical columns
|