Created
December 1, 2023 17:23
-
-
Save wjt/a3686718033855979222295e9e35b9d5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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