"""Select SCOWL's English vocabulary without importing its personal-name lists."""import tarfileimport unicodedatadef terms(source): words = set()with tarfile.open(source) as archive:for member in archive.getmembers(): category, _, size = member.name.rsplit("/", 1)[-1].rpartition(".")ifnot member.isfile() or"/final/"notin member.name ornot size.isdigit():continue# SCOWL's upper lists at level 50 and above include personal names# such as Aaron and Xavier. Level 35 retains weekdays/languages. selected = (int(size) <= 80and category.endswith(("-words", "-contractions"))) or (int(size) <= 35and category.endswith("-upper"))if selected:for term in archive.extractfile(member).read().decode("latin-1").splitlines(): term = unicodedata.normalize("NFC", term.lower().replace("’", "'"))ifnot term ornot all(c.isalpha() or c in"'-"for c in term):raiseValueError(f"Invalid SCOWL term shape: {term!r}") words.add(term)return sorted(words)