{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": { "Collapsed": "false" }, "outputs": [], "source": [ "from szyfrow.support.language_models import *\n", "from szyfrow.support.utilities import *\n", "import collections" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "Collapsed": "false" }, "outputs": [ { "data": { "text/plain": [ "14843" ] }, "execution_count": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [ "words8 = [w for w in keywords if len(w) == 8]\n", "len(words8)" ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "Collapsed": "false" }, "outputs": [], "source": [ "anags8 = collections.defaultdict(list)\n", "for w in words8:\n", " anags8[cat(sorted(w))] += [w]" ] }, { "cell_type": "code", "execution_count": 4, "metadata": { "Collapsed": "false" }, "outputs": [ { "data": { "text/plain": [ "['aegilnrt', 'aeginrst', 'deeinrst', 'ceeprsst', 'aeinrrst']" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "cands = [w for w in anags8 if len(anags8[w]) >= 5]\n", "cands" ] }, { "cell_type": "code", "execution_count": 5, "metadata": { "Collapsed": "false" }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "aegilnrt ['alerting', 'altering', 'integral', 'relating', 'triangle']\n", "aeginrst ['angriest', 'gantries', 'granites', 'ingrates', 'rangiest', 'tangiers']\n", "deeinrst ['dniester', 'inserted', 'nerdiest', 'resident', 'trendies']\n", "ceeprsst ['respects', 'scepters', 'sceptres', 'specters', 'spectres']\n", "aeinrrst ['restrain', 'retrains', 'strainer', 'terrains', 'trainers']\n" ] } ], "source": [ "for c in cands:\n", " print(c, anags8[c])" ] }, { "cell_type": "code", "execution_count": 13, "metadata": { "Collapsed": "false" }, "outputs": [ { "data": { "text/plain": [ "\"alerting', 'altering', 'integral', 'relating', 'triangle', 'angriest', 'gantries', 'granites', 'ingrates', 'rangiest', 'tangiers', 'dniester', 'inserted', 'nerdiest', 'resident', 'trendies', 'respects', 'scepters', 'sceptres', 'specters', 'spectres', 'restrain', 'retrains', 'strainer', 'terrains', 'trainers\"" ] }, "execution_count": 13, "metadata": {}, "output_type": "execute_result" } ], "source": [ "\"', '\".join(w for c in cands for w in anags8[c])" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "Collapsed": "false" }, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.7.4" } }, "nbformat": 4, "nbformat_minor": 4 }