- "['late', 'lats', 'lets', 'leas', 'seas', 'seam', 'swam', 'sway']\n",
- "['leap', 'heap', 'hear', 'dear', 'deer']\n",
- "['peel', 'peek', 'perk', 'park', 'nark']\n",
- "['sing', 'sang', 'sand', 'said', 'sail', 'hail', 'haul']\n",
- "['vats', 'bats', 'bets', 'bees', 'been', 'teen', 'then', 'thin', 'this', 'thus', 'thud']\n",
- "['sues', 'sees', 'seen', 'sewn', 'hewn']\n",
- "['rash', 'bash', 'bast', 'bait', 'bail', 'hail', 'hair', 'heir']\n",
- "['apex', 'aped', 'sped', 'seed', 'deed', 'dead', 'deal', 'veal']\n",
- "['gulf', 'golf', 'gold', 'bold', 'bond', 'bony', 'tony']\n",
- "['snag', 'shag', 'shat', 'seat', 'peat', 'pent', 'pint', 'mint']\n",
- "['rife', 'rime', 'rims', 'rums', 'cums', 'cuss']\n",
- "['diss', 'kiss', 'kits']\n",
- "['gyps', 'gaps', 'gads', 'wads', 'wade', 'wide', 'tide']\n",
- "['bilk', 'bill', 'bell', 'tell', 'teal', 'tear', 'tzar']\n",
- "['logo', 'loge', 'lode', 'lade', 'jade', 'jape']\n",
- "['hunt', 'bunt', 'buns', 'nuns', 'nubs']\n",
- "['glow', 'glop', 'plop', 'prop', 'prep', 'peep', 'keep']\n",
- "['iamb', 'lamb', 'lams', 'laps', 'lips', 'pips']\n",
- "['pain', 'lain', 'laid', 'land', 'lend', 'vend', 'veld']\n",
- "['fake', 'bake', 'bare', 'bars', 'ears', 'errs', 'ergs', 'eggs', 'egos']\n"
+ "['drip', 'grip', 'grit', 'gait', 'bait', 'bast', 'base', 'babe']\n",
+ "['cape', 'cope', 'dope', 'dole', 'dolt']\n",
+ "['laze', 'late', 'lats', 'pats']\n",
+ "['zest', 'best', 'bust', 'buss', 'buds', 'suds']\n",
+ "['gape', 'gaps', 'paps', 'peps', 'pees', 'peel']\n",
+ "['yogi', 'yoga', 'toga', 'togs', 'tors', 'tore']\n",
+ "['flux', 'flex', 'fled', 'feed', 'fees', 'foes', 'toes', 'toys']\n",
+ "['bike', 'bake', 'base', 'bast', 'best', 'beet', 'feet']\n",
+ "['tows', 'lows', 'laws', 'lams', 'lame']\n",
+ "['jock', 'pock', 'pork', 'pore', 'pure']\n",
+ "['tabu', 'tabs', 'cabs', 'caws', 'cows', 'cowl', 'coil', 'coif']\n",
+ "['reek', 'week', 'wees', 'weds', 'wads', 'wadi']\n",
+ "['gene', 'gone', 'gong', 'song']\n",
+ "['mete', 'mate', 'bate', 'bats', 'baas', 'bras', 'brag', 'crag', 'cram']\n",
+ "['gnus', 'anus', 'ants', 'acts', 'aces', 'ayes', 'byes', 'bees', 'been', 'teen']\n",
+ "['comb', 'come', 'core', 'corn', 'torn', 'tern']\n",
+ "['ouch', 'much', 'muck', 'buck', 'beck', 'beak', 'beat', 'teat', 'that', 'than', 'khan']\n",
+ "['rids', 'reds', 'reps', 'peps', 'peas', 'peal', 'deal']\n",
+ "['calm', 'balm', 'bald', 'bold', 'bolt', 'bout', 'tout']\n",
+ "['toed', 'toad', 'goad', 'grad', 'gray', 'grey', 'grew']\n"
- "execution_count": 88,
- "metadata": {
- "collapsed": false
- },
- "outputs": [
- {
- "data": {
- "text/plain": [
- "{2: [['heel', 'keel'], ['wane', 'wave'], ['cell', 'sell'], ['cons', 'cobs']],\n",
- " 3: [['hank', 'haws'], ['bars', 'bets'], ['rats', 'paws'], ['lock', 'hack']],\n",
- " 4: [['rule', 'sore'], ['wavy', 'rape'], ['peas', 'ping'], ['bond', 'toll']],\n",
- " 5: [['cope', 'yowl'], ['lose', 'loci'], ['rump', 'dash'], ['four', 'dyes']],\n",
- " 6: [['boon', 'sell'], ['lots', 'pomp'], ['cola', 'turn'], ['boos', 'laid']],\n",
- " 7: [['eave', 'inns'], ['meek', 'mere'], ['keys', 'wily'], ['slam', 'yore']],\n",
- " 8: [['hack', 'flip'], ['crag', 'huge'], ['flux', 'gill'], ['play', 'busy']],\n",
- " 9: [['lacy', 'whey'], ['wren', 'rook'], ['lire', 'drip'], ['grab', 'lame']],\n",
- " 10: [['over', 'turn'], ['worn', 'anew'], ['stow', 'elks'], ['ergo', 'rich']],\n",
- " 11: [['bask', 'idea'], ['gabs', 'thud'], ['idea', 'clod'], ['mark', 'ibis']],\n",
- " 12: [['umps', 'torn'], ['futz', 'shun'], ['abut', 'face'], ['slug', 'open']],\n",
- " 13: [['umps', 'skin'], ['chum', 'rats'], ['fury', 'chum'], ['omen', 'zany']],\n",
- " 14: [['chug', 'gaff'], ['atom', 'fizz']],\n",
- " 15: [['chug', 'oxen']]}"
- ]
- },
- "execution_count": 88,
- "metadata": {},
- "output_type": "execute_result"
- }
- ],
+ "execution_count": 68,
+ "metadata": {},
+ "outputs": [],
+ {
+ "cell_type": "code",
+ "execution_count": 90,
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "bash bush True\n",
+ "rush bush True\n"
+ ]
+ },
+ {
+ "data": {
+ "text/plain": [
+ "2"
+ ]
+ },
+ "execution_count": 90,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "nb_count = collections.Counter()\n",
+ "for w in neighbours['rash']:\n",
+ " for w2 in neighbours[w]:\n",
+ " if w2 == 'bush': print(w, w2, w2 not in neighbours['rash'])\n",
+ " if w2 != 'rash' and w2 not in neighbours['rash']:\n",
+ " nb_count.update([w2])\n",
+ "nb_count.most_common(1)[0][1]"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 91,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "['gush', 'hush', 'lush', 'mush', 'push', 'tush', 'bosh']"
+ ]
+ },
+ "execution_count": 91,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "[w for w in neighbours['bush'] if w in nb_count]"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 89,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "('gibe', 2)"
+ ]
+ },
+ "execution_count": 89,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "best_start = ''\n",
+ "best_overlap_count = 0\n",
+ "for w0 in neighbours: \n",
+ " nb_count = collections.Counter()\n",
+ " for w in neighbours[w0]:\n",
+ " for w2 in neighbours[w]:\n",
+ " if w2 != w0 and w2 not in neighbours[w0]:\n",
+ " nb_count.update([w2])\n",
+ " if len(nb_count) > 0:\n",
+ " if nb_count.most_common(1)[0][1] > best_overlap_count:\n",
+ " best_start = w0\n",
+ " best_overlap_count = nb_count.most_common(1)[0][1]\n",
+ " \n",
+ "best_start, best_overlap_count"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 88,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "'memo'"
+ ]
+ },
+ "execution_count": 88,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "w0"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 76,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "{'bash', 'rush'}"
+ ]
+ },
+ "execution_count": 76,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "set(neighbours['rash']) & set(neighbours['bush'])"
+ ]
+ },