marksaroufim commited on
Commit
b010c7c
·
1 Parent(s): 3d84e4a
Files changed (3) hide show
  1. output_dataset.parquet +2 -2
  2. par.py → process.py +14 -9
  3. viz.py +7 -2
output_dataset.parquet CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:c49abfa2591aac4b75847bb0f31e4ed5581eb94727308af9c5c6c31657d4946c
3
- size 22475137
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:822e90e030672c607877152140280388b8a0d803489c396e06fc5b9e57fb0724
3
+ size 22498566
par.py → process.py RENAMED
@@ -28,18 +28,23 @@ def collect_data(directory):
28
  image_files = {re.search(r'(\d+)', filename).group(1): filename
29
  for filename in os.listdir(directory) if filename.endswith('.jpg')}
30
 
31
- # Iterate over all files in the directory and organize them by problem ID
32
- for filename in os.listdir(directory):
33
- problem_id = filename.split('.')[0]
34
- file_type = filename.split('.')[-1]
35
- file_path = os.path.join(directory, filename)
36
-
37
  if problem_id not in data:
38
  data[problem_id] = {'Problem ID': problem_id, 'Images': [], 'in': None, 'out': None, 'cpp': None, 'md': None, 'sol.md': None}
39
 
40
- if file_type in ['in', 'out', 'cpp', 'md', 'sol.md']:
41
- content = encode_file(file_path)
42
- if content is not None:
 
 
 
 
 
 
43
  data[problem_id][file_type] = content
44
  if file_type in ['md', 'sol.md']:
45
  image_ids = extract_images(content)
 
28
  image_files = {re.search(r'(\d+)', filename).group(1): filename
29
  for filename in os.listdir(directory) if filename.endswith('.jpg')}
30
 
31
+ # Identify Markdown and solution Markdown files and establish correct problem IDs
32
+ markdown_files = [f for f in os.listdir(directory) if f.endswith('.md') or f.endswith('.sol.md')]
33
+ for mfile in markdown_files:
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, 'md': None, 'sol.md': None}
38
 
39
+ # Now associate other files with these problem IDs
40
+ for filename in os.listdir(directory):
41
+ problem_id = re.sub(r'sol$', '', filename.split('.')[0]) # Strip "sol" from end if present
42
+ if problem_id in data: # Only process if the problem_id is recognized
43
+ file_type = filename.split('.')[-1]
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', 'md', 'sol.md']:
48
  data[problem_id][file_type] = content
49
  if file_type in ['md', 'sol.md']:
50
  image_ids = extract_images(content)
viz.py CHANGED
@@ -1,10 +1,15 @@
1
  import pandas as pd
 
 
2
 
3
  # Load the Parquet file
4
  df = pd.read_parquet('output_dataset.parquet')
5
 
 
 
6
  # Display the first few rows of the dataframe
7
- print(df.head())
8
 
9
  # Basic statistics for numerical columns
10
- print(df.describe())
 
 
1
  import pandas as pd
2
+ # pd.set_option('display.max_columns', None) # None means no limit
3
+ # pd.set_option('display.width', None) # None means use the current terminal width
4
 
5
  # Load the Parquet file
6
  df = pd.read_parquet('output_dataset.parquet')
7
 
8
+ print(df.columns)
9
+
10
  # Display the first few rows of the dataframe
11
+ print(df)
12
 
13
  # Basic statistics for numerical columns
14
+ # print(df.describe())
15
+ #