Skip to content

Instantly share code, notes, and snippets.

@mpppk
Last active June 30, 2019 05:22
Show Gist options
  • Save mpppk/960046e87cb0484c14f52aad531624b8 to your computer and use it in GitHub Desktop.
Save mpppk/960046e87cb0484c14f52aad531624b8 to your computer and use it in GitHub Desktop.
pokemon.ipynb
Display the source blob
Display the rendered blob
Raw
{
"nbformat": 4,
"nbformat_minor": 0,
"metadata": {
"colab": {
"name": "pokemon.ipynb",
"version": "0.3.2",
"provenance": [],
"collapsed_sections": [],
"include_colab_link": true
},
"kernelspec": {
"name": "python3",
"display_name": "Python 3"
}
},
"cells": [
{
"cell_type": "markdown",
"metadata": {
"id": "view-in-github",
"colab_type": "text"
},
"source": [
"<a href=\"https://colab.research.google.com/gist/mpppk/960046e87cb0484c14f52aad531624b8/pokemon.ipynb\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"/></a>"
]
},
{
"cell_type": "code",
"metadata": {
"id": "OE0wW8tEx4h0",
"colab_type": "code",
"outputId": "479efe31-fcce-444c-f488-301ebb3bc2b9",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 34
}
},
"source": [
"from google.colab import drive\n",
"drive.mount('/content/drive')"
],
"execution_count": 2,
"outputs": [
{
"output_type": "stream",
"text": [
"Drive already mounted at /content/drive; to attempt to forcibly remount, call drive.mount(\"/content/drive\", force_remount=True).\n"
],
"name": "stdout"
}
]
},
{
"cell_type": "code",
"metadata": {
"id": "8OmO2klAyPjP",
"colab_type": "code",
"outputId": "e9edab28-98b0-403c-9080-8d5eb3811202",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 34
}
},
"source": [
"csvPath = 'drive/My Drive/Colab Notebooks/data/pokemon_list.csv'\n",
"!ls drive/'My Drive'/'Colab Notebooks'/data\n",
"\n",
"# ---- install font and delete cache ----\n",
"#!apt-get -y install fonts-ipafont-gothic\n",
"# import matplotlib\n",
"# import subprocess\n",
"# print(matplotlib.get_cachedir())\n",
"# !ls /root/.cache/matplotlib\n",
"# !rm /root/.cache/matplotlib/fontList.json\n",
"# !rm /root/.cache/matplotlib/fontlist-v300.json"
],
"execution_count": 3,
"outputs": [
{
"output_type": "stream",
"text": [
"pokemon_list.csv pokemon_list_medium.csv pokemon_list_small.csv\n"
],
"name": "stdout"
}
]
},
{
"cell_type": "code",
"metadata": {
"id": "t5_Mdg-Oy_7m",
"colab_type": "code",
"colab": {}
},
"source": [
"import pandas as pd\n",
"def to_upper_katakana(series: pd.Series):\n",
" return series.str.replace(\n",
" 'ァ', 'ア'\n",
" ).str.replace(\n",
" 'ィ', 'イ'\n",
" ).str.replace(\n",
" 'ゥ', 'ウ'\n",
" ).str.replace(\n",
" 'ェ', 'エ'\n",
" ).str.replace(\n",
" 'ォ', 'オ'\n",
" ).str.replace(\n",
" 'ッ', 'ツ'\n",
" ).str.replace(\n",
" 'ャ', 'ヤ'\n",
" ).str.replace(\n",
" 'ュ', 'ユ'\n",
" ).str.replace(\n",
" 'ョ', 'ヨ'\n",
" )\n",
"\n",
"def remove_dakuten(series: pd.Series):\n",
" return series.str.replace(\n",
" 'ガ', 'カ'\n",
" ).str.replace(\n",
" 'ギ', 'キ'\n",
" ).str.replace(\n",
" 'グ', 'ク'\n",
" ).str.replace(\n",
" 'ゲ', 'ケ'\n",
" ).str.replace(\n",
" 'ゴ', 'コ'\n",
" ).str.replace(\n",
" 'ザ', 'サ'\n",
" ).str.replace(\n",
" 'ジ', 'シ'\n",
" ).str.replace(\n",
" 'ズ', 'ス'\n",
" ).str.replace(\n",
" 'ゼ', 'セ'\n",
" ).str.replace(\n",
" 'ゾ', 'ソ'\n",
" ).str.replace(\n",
" 'ダ', 'タ'\n",
" ).str.replace(\n",
" 'ヂ', 'チ' \n",
" ).str.replace(\n",
" 'ヅ', 'ツ'\n",
" ).str.replace(\n",
" 'デ', 'テ'\n",
" ).str.replace(\n",
" 'ド', 'ト'\n",
" ).str.replace(\n",
" 'バ|パ', 'ハ'\n",
" ).str.replace(\n",
" 'ビ|ピ', 'ヒ'\n",
" ).str.replace(\n",
" 'ブ|プ', 'フ'\n",
" ).str.replace(\n",
" 'ベ|ペ', 'ヘ'\n",
" ).str.replace(\n",
" 'ボ|ポ', 'ホ'\n",
" ).str.replace(\n",
" 'ヴ', 'ウ'\n",
" )\n"
],
"execution_count": 0,
"outputs": []
},
{
"cell_type": "code",
"metadata": {
"id": "vSa42cm3K3R5",
"colab_type": "code",
"colab": {}
},
"source": [
"import pandas as pd\n",
"import collections\n",
"\n",
"def count_katakana(row: pd.Series):\n",
" s = [n for n in row.get('name')]\n",
" c = collections.Counter(s)\n",
" return pd.Series(c)\n",
"\n",
"df = pd.DataFrame()\n",
"df['name'] = pd.read_csv(\n",
" csvPath, header=None\n",
")[0].pipe( # n行1列のcsvを読み込む前提\n",
" to_upper_katakana\n",
").pipe(\n",
" remove_dakuten\n",
").str.replace('ー','')\n",
"\n",
"katakana_counts = df.apply(\n",
" count_katakana, axis=1\n",
").fillna(0).sum()"
],
"execution_count": 0,
"outputs": []
},
{
"cell_type": "code",
"metadata": {
"id": "5TWYPysS0aRc",
"colab_type": "code",
"outputId": "cf2ce7b8-f693-4cb4-e0f3-393ea1d6cb82",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 319
}
},
"source": [
"import matplotlib\n",
"\n",
"font = {'family' : 'IPAGothic'}\n",
"matplotlib.rc('font', **font)\n",
"katakana_counts.plot.bar()"
],
"execution_count": 6,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
"<matplotlib.axes._subplots.AxesSubplot at 0x7fd9938df7b8>"
]
},
"metadata": {
"tags": []
},
"execution_count": 6
},
{
"output_type": "stream",
"text": [
"/usr/local/lib/python3.6/dist-packages/matplotlib/font_manager.py:1241: UserWarning: findfont: Font family ['IPAGothic'] not found. Falling back to DejaVu Sans.\n",
" (prop.get_family(), self.defaultFamily[fontext]))\n"
],
"name": "stderr"
},
{
"output_type": "display_data",
"data": {
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAXoAAAD4CA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zsXfSputQR3NxY9VuNz2nZzI2Evtqo57EGvn2NMytXPsaV21c+xp\nXbVz7Gm72uTiydgHN9mWZCZBD8DqzGWNHoAVEfQAgxP0AIMT9ACDE/QAg/s/biPAfP4vev4AAAAA\nSUVORK5CYII=\n",
"text/plain": [
"<Figure size 432x288 with 1 Axes>"
]
},
"metadata": {
"tags": []
}
}
]
},
{
"cell_type": "code",
"metadata": {
"id": "RuM7JgJ0hL2u",
"colab_type": "code",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 799
},
"outputId": "98197711-9774-4578-d941-7eaecd2c4fa0"
},
"source": [
"katakana_counts.sort_values()"
],
"execution_count": 7,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
"ヌ 10.0\n",
"ソ 16.0\n",
"セ 18.0\n",
"ヨ 24.0\n",
"ワ 27.0\n",
"ネ 28.0\n",
"ヘ 28.0\n",
"ミ 35.0\n",
"モ 35.0\n",
"メ 38.0\n",
"ノ 38.0\n",
"サ 39.0\n",
"エ 40.0\n",
"ナ 43.0\n",
"ム 44.0\n",
"レ 44.0\n",
"ユ 46.0\n",
"ウ 46.0\n",
"ケ 47.0\n",
"ニ 50.0\n",
"チ 54.0\n",
"ホ 59.0\n",
"ヤ 64.0\n",
"ヒ 65.0\n",
"オ 67.0\n",
"テ 68.0\n",
"ロ 77.0\n",
"ア 78.0\n",
"キ 89.0\n",
"タ 91.0\n",
"マ 103.0\n",
"リ 105.0\n",
"ハ 109.0\n",
"コ 113.0\n",
"カ 113.0\n",
"イ 118.0\n",
"ツ 120.0\n",
"フ 123.0\n",
"シ 128.0\n",
"ラ 133.0\n",
"ス 138.0\n",
"ク 140.0\n",
"ト 170.0\n",
"ル 177.0\n",
"ン 215.0\n",
"dtype: float64"
]
},
"metadata": {
"tags": []
},
"execution_count": 7
}
]
},
{
"cell_type": "code",
"metadata": {
"id": "2XptJW0NYSr2",
"colab_type": "code",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 34
},
"outputId": "e7f9deba-00e8-4024-9214-72c2565219dc"
},
"source": [
"# その文字を含むポケモン名が少ない順で、互いに独立な文字を列挙\n",
"def list_independent_katakana(word_group: pd.DataFrame, katakana_counts: pd.Series):\n",
" checked_katakana = []\n",
" for k, freq in katakana_counts.sort_values().items():\n",
" is_independent = True\n",
" wk = word_group[k]\n",
" for ck in checked_katakana:\n",
" sub_df = wk[wk['name'].str.contains(ck)]\n",
" if len(sub_df) > 0:\n",
" is_independent = False\n",
" break\n",
" if is_independent:\n",
" checked_katakana.append(k)\n",
" return checked_katakana\n",
"\n",
"# ある文字を含むポケモンごとにまとめる\n",
"word_group = {k:df[df['name'].str.contains(k)] for k, _ in katakana_counts.items()}\n",
"independent_katakana = list_independent_katakana(word_group, katakana_counts)\n",
"independent_word_group = {k:word_group[k] for k in independent_katakana}\n",
"independent_katakana"
],
"execution_count": 8,
"outputs": [
{
"output_type": "execute_result",
"data": {
"text/plain": [
"['ヌ', 'ソ', 'セ', 'ワ', 'ヘ']"
]
},
"metadata": {
"tags": []
},
"execution_count": 8
}
]
},
{
"cell_type": "code",
"metadata": {
"id": "6UpfJp7jjSgl",
"colab_type": "code",
"colab": {
"base_uri": "https://localhost:8080/",
"height": 362
},
"outputId": "fa1fa732-78c1-4fc8-ec9d-99ce88bd9987"
},
"source": [
"# 上記のグループの全組み合わせの数\n",
"# 文字が重複するものは除く\n",
"from itertools import chain\n",
"from typing import List\n",
"\n",
"def combi(remain_words_list):\n",
" if len(remain_words_list) == 1:\n",
" return [[w] for w in remain_words_list[0].to_list()]\n",
" new_words_list = []\n",
" for w in remain_words_list[0].to_list():\n",
" new_combi = combi(remain_words_list[1:])\n",
" temp_words_list = [words + [w] for words in combi(remain_words_list[1:])]\n",
" new_words_list += [words for words in temp_words_list if not is_duplicate_katakana(words)]\n",
" return new_words_list\n",
"\n",
"def is_duplicate_katakana(words: List[str]) -> bool:\n",
" katakana_dict = count_katakana_list(words)\n",
" for count in katakana_dict.values():\n",
" if count > 1:\n",
" return False\n",
" return True\n",
"\n",
"def flatten(nest_list):\n",
" return list(chain.from_iterable(nest_list))\n",
" \n",
"def count_katakana_list(words: List[str]):\n",
" s = [[w for w in word] for word in words]\n",
" return collections.Counter(flatten(s))\n",
" \n",
"independent_words_list = [ws['name'] for ws in independent_word_group.values()]\n",
"combinations = combi(independent_words_list[])\n",
"len(combinations)"
],
"execution_count": 12,
"outputs": [
{
"output_type": "error",
"ename": "NameError",
"evalue": "ignored",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mNameError\u001b[0m Traceback (most recent call last)",
"\u001b[0;32m<ipython-input-12-20140b226ea6>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m()\u001b[0m\n\u001b[1;32m 27\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 28\u001b[0m \u001b[0mindependent_words_list\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;34m[\u001b[0m\u001b[0mws\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m'name'\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;32mfor\u001b[0m \u001b[0mws\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mindependent_word_group\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mvalues\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 29\u001b[0;31m \u001b[0mcombinations\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mcombi\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mindependent_words_list\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 30\u001b[0m \u001b[0mlen\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mcombinations\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;32m<ipython-input-12-20140b226ea6>\u001b[0m in \u001b[0;36mcombi\u001b[0;34m(remain_words_list)\u001b[0m\n\u001b[1;32m 7\u001b[0m \u001b[0mnew_words_list\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;34m[\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 8\u001b[0m \u001b[0;32mfor\u001b[0m \u001b[0mw\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mremain_words_list\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m0\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mto_list\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 9\u001b[0;31m \u001b[0mnew_combi\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mcombi\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mremain_words_list\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 10\u001b[0m \u001b[0mnew_words_list\u001b[0m \u001b[0;34m+=\u001b[0m \u001b[0;34m[\u001b[0m\u001b[0mwords\u001b[0m \u001b[0;32mfor\u001b[0m \u001b[0mwords\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mtemp_words_list\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0;32mnot\u001b[0m \u001b[0mis_duplicate_katakana\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mwords\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 11\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0mnew_words_list\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;32m<ipython-input-12-20140b226ea6>\u001b[0m in \u001b[0;36mcombi\u001b[0;34m(remain_words_list)\u001b[0m\n\u001b[1;32m 7\u001b[0m \u001b[0mnew_words_list\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;34m[\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 8\u001b[0m \u001b[0;32mfor\u001b[0m \u001b[0mw\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mremain_words_list\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m0\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mto_list\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 9\u001b[0;31m \u001b[0mnew_combi\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mcombi\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mremain_words_list\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 10\u001b[0m \u001b[0mnew_words_list\u001b[0m \u001b[0;34m+=\u001b[0m \u001b[0;34m[\u001b[0m\u001b[0mwords\u001b[0m \u001b[0;32mfor\u001b[0m \u001b[0mwords\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mtemp_words_list\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0;32mnot\u001b[0m \u001b[0mis_duplicate_katakana\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mwords\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 11\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0mnew_words_list\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;32m<ipython-input-12-20140b226ea6>\u001b[0m in \u001b[0;36mcombi\u001b[0;34m(remain_words_list)\u001b[0m\n\u001b[1;32m 8\u001b[0m \u001b[0;32mfor\u001b[0m \u001b[0mw\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mremain_words_list\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m0\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mto_list\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 9\u001b[0m \u001b[0mnew_combi\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mcombi\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mremain_words_list\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 10\u001b[0;31m \u001b[0mnew_words_list\u001b[0m \u001b[0;34m+=\u001b[0m \u001b[0;34m[\u001b[0m\u001b[0mwords\u001b[0m \u001b[0;32mfor\u001b[0m \u001b[0mwords\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mtemp_words_list\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0;32mnot\u001b[0m \u001b[0mis_duplicate_katakana\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mwords\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 11\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0mnew_words_list\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 12\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;31mNameError\u001b[0m: name 'temp_words_list' is not defined"
]
}
]
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment