This commit is contained in:
2026-04-23 12:41:50 +02:00
parent bc47f81556
commit dd0d757fc9
4 changed files with 96 additions and 16 deletions
+22 -6
View File
@@ -12,8 +12,7 @@ import annotating_with_checks
from utils import natural_key
# Roughly 10 A4 pages at 100 DPI
MAX_HEIGHT_PX = 20000 # Can be increased by 10%.
MAX_HEIGHT_PX = 25000 # Can be increased by 10%.
def render_item(item):
student_id, label, content = item
@@ -134,15 +133,32 @@ def main():
shutil.rmtree(bgnot_dir)
os.makedirs(bgnot_dir, exist_ok=True)
used_prefixes = set()
previous_prefix = None
for line in lines:
labels = [l.strip() for l in line.split(',') if l.strip()]
safe_labels = [l.replace(":", "").strip() for l in line.split(',') if l.strip()]
if not labels:
continue
prefix = os.path.commonprefix(safe_labels).strip()
if not prefix:
prefix = "Group"
base_prefix = os.path.commonprefix(safe_labels).strip()
if not base_prefix:
base_prefix = "Group"
unique_prefix = base_prefix
if unique_prefix[-1] == "i":
unique_prefix = unique_prefix[:-1]
counter = 2
while unique_prefix in used_prefixes:
unique_prefix = f"{base_prefix}-{counter}"
counter += 1
if counter == 2 and previous_prefix and previous_prefix in unique_prefix:
unique_prefix = f"{previous_prefix}-{counter}"
elif counter == 2:
previous_prefx = unique_prefix
used_prefixes.add(unique_prefix)
items_to_render = []
for sid, lbls in results.items():
@@ -201,7 +217,7 @@ def main():
batches = batches2
for i, batch in enumerate(batches, 1):
save_batch(batch, prefix, i, root_dir, args.overwrite)
save_batch(batch, unique_prefix, i, root_dir, args.overwrite)
if __name__ == "__main__":
main()