feat: aggiunge CLI unificata, build vocabolario e filtro lessicale

This commit is contained in:
2026-04-13 19:04:01 +02:00
parent 0b42c2ecd4
commit 77c7e709b6
24 changed files with 161767 additions and 1 deletions

View File

@@ -1,6 +1,7 @@
from __future__ import annotations
from dataclasses import dataclass
import locale
import sys
import time
from typing import Dict, Iterable, List, Optional, Sequence, Set, Tuple
@@ -36,6 +37,8 @@ WORDS = [
HORIZONTAL = "H"
VERTICAL = "V"
DIFFXY = 7
EMPTY_CELL_RENDER = ""
EMPTY_CELL_FALLBACK = "#"
@dataclass(frozen=True)
@@ -361,6 +364,9 @@ def render_grid(grid: Grid, placements: Sequence[Placement]) -> str:
if not grid:
return "(griglia vuota)"
encoding = (getattr(sys.stdout, "encoding", None) or locale.getpreferredencoding(False) or "").lower()
empty_cell = EMPTY_CELL_RENDER if "utf" in encoding else EMPTY_CELL_FALLBACK
x_min = min(x for x, _ in grid)
x_max = max(x for x, _ in grid)
y_min = min(y for _, y in grid)
@@ -373,7 +379,7 @@ def render_grid(grid: Grid, placements: Sequence[Placement]) -> str:
for y in range(y_min, y_max + 1):
row = [f"{y:>3} "]
for x in range(x_min, x_max + 1):
row.append(grid.get((x, y), ".").upper().rjust(2))
row.append(grid.get((x, y), empty_cell).upper().rjust(2))
lines.append(" ".join(row))
lines.append("")