Skip to content

Instantly share code, notes, and snippets.

@socrateslee
Created May 21, 2020 04:17
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 socrateslee/76d9d5af1a8ee0832150b148647fc610 to your computer and use it in GitHub Desktop.
Save socrateslee/76d9d5af1a8ee0832150b148647fc610 to your computer and use it in GitHub Desktop.
Get a word list from local man file
import re
import gzip
def get_word_list(f, pattern=None):
pattern = pattern if pattern else r'[a-zA-Z0-9-_]+'
l = re.findall(pattern, gzip.decompress(open(f, 'rb').read()).decode('utf-8'))
return list(set(l))
# Example
# get_word_list('/usr/share/man/man1/git.1.gz', r'[a-zA-Z0-9-_]+')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment