11 "import unicodedata\n",
23 "unaccent_specials = ''.maketrans({\"’\": \"'\", '“': '\"', '”': '\"'})"
34 "def unaccent(text):\n",
35 " translated_text = text.translate(unaccent_specials)\n",
36 " return unicodedata.normalize('NFKD', translated_text).\\\n",
37 " encode('ascii', 'ignore').\\\n",
49 "def only_lower(text):\n",
50 " return all((c in string.ascii_lowercase) for c in text)"
60 "output_type": "stream",
62 "/usr/share/dict/british-english\n",
63 "find: ‘/usr/share/doc/google-chrome-stable’: Permission denied\n",
64 "/usr/share/man/man5/british-english.5.gz\n"
69 "# !find /usr -type f -iname 'british-english*'"
79 "output_type": "stream",
82 "drwxr-xr-x 2 root root 4.0K Dec 29 12:37 .\r\n",
83 "drwxr-xr-x 640 root root 20K Apr 13 17:05 ..\r\n",
84 "-rw-r--r-- 1 root root 917K Oct 23 2011 american-english\r\n",
85 "-rw-r--r-- 1 root root 917K Oct 23 2011 british-english\r\n",
86 "-rw-r--r-- 1 root root 467K Aug 25 2016 cracklib-small\r\n",
87 "-rw-r--r-- 1 root root 199 Aug 29 2016 README.select-wordlist\r\n",
88 "lrwxrwxrwx 1 root root 30 Nov 10 2014 words -> /etc/dictionaries-common/words\r\n",
89 "lrwxrwxrwx 1 root root 16 Jun 18 2014 words.pre-dictionaries-common -> american-english\r\n"
94 "# !ls -lah /usr/share/dict"
99 "execution_count": 17,
106 " return any(w in word \n",
107 " for w in 'piss shit cunt fuck arse crap fart jizz whore bitch'.split())"
112 "execution_count": 18,
121 "execution_count": 18,
123 "output_type": "execute_result"
132 "execution_count": 19,
138 "def words_with_len(n):\n",
139 " return [unaccent(w.strip()) for w in open('/usr/share/dict/british-english').readlines()\n",
140 " if only_lower(unaccent(w.strip()))\n",
141 " if len(unaccent(w.strip())) == n\n",
142 " if not rude(unaccent(w.strip()))]"
147 "execution_count": 20,
152 "output_type": "stream",
154 "2336 4-letter words\n",
155 "4566 5-letter words\n",
156 "7223 6-letter words\n"
163 "for n in [4, 5, 6]:\n",
164 " dicts[n] = words_with_len(n)\n",
165 " print('{} {}-letter words'.format(len(dicts[n]), n))\n",
166 " with open('words{}.txt'.format(n), 'w') as f:\n",
167 " f.write('\\n'.join(sorted(set(dicts[n]))))\n"
172 "execution_count": null,
182 "display_name": "Python 3",
183 "language": "python",
191 "file_extension": ".py",
192 "mimetype": "text/x-python",
194 "nbconvert_exporter": "python",
195 "pygments_lexer": "ipython3",