# scrabble-dictionary build helpers.
#
# `make dawg` (re)builds the dictionary DAWGs under dawg/ from their word lists, using the
# published scrabble-solver dictdawg/wordlist builders (pinned in go.mod), so the on-disk
# format and letter indexing match the running backend exactly (no index drift):
#   en_sowpods.dawg  — English SOWPODS (Latin alphabet)
#   ru_scrabble.dawg — Russian Scrabble nouns (Cyrillic, 33 letters)
#   ru_erudit.dawg   — Эрудит (the Ё→Е folded + de-duped list, committed as russian/erudit.txt)
#
# CI builds the DAWGs as a validation gate; release artifacts are published from this output
# (see README.md). Regenerate russian/erudit.txt from scrabble.txt with tools/fold_yo.py.

export GOPRIVATE := gitea.iliadenisov.ru/*

GO        ?= go
DAWG_DIR  := dawg
BUILDDICT := $(GO) run ./cmd/builddict

.PHONY: dawg dawg-en dawg-ru dawg-erudit clean-dawg

dawg: dawg-en dawg-ru dawg-erudit

dawg-en:
	$(BUILDDICT) -dict sources/scrabble_en/sowpods.txt -alphabet latin -name en_sowpods -out $(DAWG_DIR)

dawg-ru:
	$(BUILDDICT) -dict sources/scrabble_ru/scrabble.txt -alphabet russian -name ru_scrabble -out $(DAWG_DIR)

dawg-erudit:
	$(BUILDDICT) -dict sources/erudit_ru/erudit.txt -alphabet russian -name ru_erudit -out $(DAWG_DIR)

clean-dawg:
	rm -f $(DAWG_DIR)/*.dawg
