Skip to content

Instantly share code, notes, and snippets.

@wjt
Created December 1, 2023 17:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wjt/a3686718033855979222295e9e35b9d5 to your computer and use it in GitHub Desktop.
Save wjt/a3686718033855979222295e9e35b9d5 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python3
from gi.repository import GLib
import argparse
import itertools
def main():
parser = argparse.ArgumentParser()
parser.add_argument("wordlist", type=argparse.FileType("r"))
args = parser.parse_args()
words = [
line.strip()
for line in args.wordlist.splitlines()
if GLib.VariantType.string_is_valid(f"({line.strip()})")
]
words.sort(key=len, reverse=True)
for n, group in itertools.islice(itertools.groupby(words, key=len), 2):
print(n)
for word in group:
print(word)
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment