Created
May 21, 2020 04:17
-
-
Save socrateslee/76d9d5af1a8ee0832150b148647fc610 to your computer and use it in GitHub Desktop.
Get a word list from local man file
This file contains hidden or 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
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