fix: sentences generation with spaces
Python Lint CI / ruff-format-check (push) Canceled after 2m36s
Python Lint CI / ty (push) Canceled after 2m37s
Python Lint CI / ruff (push) Canceled after 2m39s

This commit is contained in:
2026-11-11 17:59:23 +01:00
parent 14230bd489
commit a9d250944b
2 changed files with 9 additions and 7 deletions
+3 -1
View File
@@ -105,6 +105,8 @@ class Generator:
self.log.info("Wrote sentences output to %s", self.target_sentences_path)
except OSError as e:
self.log.error(
"Could not write sentences output file at: %s (%s)", self.target_sentences_path, e
"Could not write sentences output file at: %s (%s)",
self.target_sentences_path,
e,
)
sys.exit(1)
+6 -6
View File
@@ -49,15 +49,15 @@ class Sentence:
@classmethod
def from_text(cls, src_text: str, names: list[str]) -> Sentence:
text = src_text
if "EMPTY" in names:
text = text.replace(" ", "{EMPTY}")
else:
log.warning("No EMPTY tile in names, removing spaces in '%s'", src_text)
text.replace(" ", "")
changed = True
data = []
remaining_text = ""
while changed:
while changed and len(text):
if text[0] == " " and "EMPTY" in names:
text = text[1:]
data += [names.index("EMPTY")]
continue
changed = False
min_name = None
min_pattern = None