# 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 same list with Ё→Е folded and de-duped)
#
# The CI workflow packages dawg/*.dawg into a release artifact on a vX.Y.Z tag.

export GOPRIVATE := gitea.iliadenisov.ru/*

GO        ?= go
PYTHON    ?= python3
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 dictionaries/english/sowpods.txt -alphabet latin -name en_sowpods -out $(DAWG_DIR)

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

dawg-erudit:
	$(PYTHON) dictprep/fold_yo.py dictprep/russian/scrabble.txt > /tmp/ru_erudit_words.txt
	$(BUILDDICT) -dict /tmp/ru_erudit_words.txt -alphabet russian -name ru_erudit -out $(DAWG_DIR)

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