-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathparse_cremona_chunks.py
More file actions
47 lines (34 loc) · 1.13 KB
/
Copy pathparse_cremona_chunks.py
File metadata and controls
47 lines (34 loc) · 1.13 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
38
39
40
41
42
43
44
45
46
47
import os
import re
# Path to repo root
REPO_ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), ".."))
CURVEDATA_DIR = os.path.join(REPO_ROOT, "data", "ecdata", "curvedata")
LABEL_RE = re.compile(r"(\d+)([a-z]+)(\d+)$")
def extract_labels_from_chunks():
"""
Parse data/ecdata/curvedata/curvedata.*
and extract Cremona labels from each line.
"""
labels = []
for fname in sorted(os.listdir(CURVEDATA_DIR)):
if not fname.startswith("curvedata."):
continue
path = os.path.join(CURVEDATA_DIR, fname)
with open(path) as f:
for line in f:
parts = line.strip().split()
if not parts:
continue
label = parts[0]
if LABEL_RE.match(label):
labels.append(label)
return labels
def main():
labels = extract_labels_from_chunks()
# Sort lexicographically for reproducibility
labels = sorted(labels)
# Print first 1000 labels
for L in labels[:1000]:
print(L)
if __name__ == "__main__":
main()