use sorted() for repeatable generation outputs (e.g. GALLERY.md)

This commit is contained in:
Andreas Koepf 2025-01-30 23:33:43 +01:00
parent c6634fd538
commit a577f7cdf6
4 changed files with 30 additions and 24 deletions

View file

@ -51,7 +51,7 @@ class LetterCountingDataset(ProceduralDataset):
letters = {"a"} # Fallback if span has no letters
# Select random letter that appears in the span
target_letter = rng.choice(list(letters))
target_letter = rng.choice(sorted(letters))
# Count occurrences
count = sum(word.lower().count(target_letter) for word in span)

View file

@ -49,7 +49,7 @@ class WordSortingDataset(ProceduralDataset):
# Load and preprocess text
text = read_data_file("in_the_year_2889.txt")
# Extract unique words within length constraints
self.words = list(
self.words = sorted(
set(
word
for word in re.findall(r"\b\w+\b", text)