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)"
59 "# !find /usr -type f -iname 'british-english*'"
68 "# !ls -lah /usr/share/dict"
80 " return any(w in word \n",
81 " for w in 'piss shit cunt fuck arse crap fart jizz whore bitch'.split())"
97 "output_type": "execute_result"
106 "execution_count": 10,
110 "def valid_words():\n",
111 " return [unaccent(w.strip()) for w in open('/usr/share/dict/british-english').readlines()\n",
112 " if only_lower(unaccent(w.strip()))\n",
113 " if not rude(unaccent(w.strip()))]"
118 "execution_count": 11,
124 "def words_with_len(n):\n",
125 " return [unaccent(w.strip()) for w in open('/usr/share/dict/british-english').readlines()\n",
126 " if only_lower(unaccent(w.strip()))\n",
127 " if len(unaccent(w.strip())) == n\n",
128 " if not rude(unaccent(w.strip()))]"
133 "execution_count": 13,
138 "output_type": "stream",
145 "words = valid_words()\n",
146 "print('{} words'.format(len(words)))\n",
147 "with open('words.txt', 'w') as f:\n",
148 " f.write('\\n'.join(words))\n"
153 "execution_count": null,
163 "display_name": "Python 3",
164 "language": "python",
172 "file_extension": ".py",
173 "mimetype": "text/x-python",
175 "nbconvert_exporter": "python",
176 "pygments_lexer": "ipython3",