Files
CustosPublic/crates/custos-gen/wordlists/derive_memorable.py
T

25 lines
1.1 KiB
Python

"""Rebuilds memorable.txt: the EFF large wordlist minus every word that the standard US English
spellchecker dictionary (SCOWL/ESDB size 60, the size of hunspell's en_US) does not list as a plain
lowercase word. That removes brand names (walmart), names and capitalised words (monday) and coinages
(pranker). See SOURCES.md for the exact download.
python derive_memorable.py <scowl-size-60.txt>
"""
import sys
from pathlib import Path
here = Path(__file__).parent
scowl = Path(sys.argv[1]).read_text(encoding="utf-8")
dictionary = set(scowl.split("---", 1)[1].split())
eff = [line.split("\t")[1].strip() for line in (here / "eff_large_wordlist.txt").read_text().splitlines()]
kept = [w for w in eff if w in dictionary]
header = """\
# Memorable-password words: the EFF large wordlist (CC BY 3.0 US, (c) Electronic Frontier Foundation)
# minus the words not in SCOWL/ESDB size 60 (US). Word list (c) 2000-2026 by Kevin Atkinson, see SOURCES.md.
# Generated by derive_memorable.py; do not edit by hand.
"""
(here / "memorable.txt").write_text(header + "\n".join(kept) + "\n", encoding="utf-8", newline="\n")
print(f"kept {len(kept)} of {len(eff)}")