{
  "cells": [
    {
      "cell_type": "code",
      "source": [
        "!date\n",
        "!python --version"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "u37VZg9nUo-F",
        "outputId": "dc34ca61-ba0f-4a6c-a207-8a9a5a1913fd"
      },
      "execution_count": 1,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "Wed Jun  5 07:35:52 AM UTC 2024\n",
            "Python 3.10.12\n"
          ]
        }
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "Ebv719CATiiZ"
      },
      "source": [
        "# テキストのベクトル化（spacy + α)\n",
        "- spacyに限定しない、一般的に共通した考え方。\n",
        "  - まずベクトル化するテキストの単位を決める。決めた単位でまとめておく。\n",
        "    - 複数文章？単一文章？複数文？単一文？複数単語？単一単語？\n",
        "  - テキスト群をtokenに分割する。ここでは分かち書き+原形処理に留める。\n",
        "  - token系列に対し、分布類似度仮説を踏まえた特徴量設計を考える。\n",
        "- 今回の例\n",
        "  - 文章のベクトル化\n",
        "    - [Bag-of-Words（BoW）](https://en.wikipedia.org/wiki/Bag-of-words_model), sklearnを利用。\n",
        "    - [TF-IDF](https://en.wikipedia.org/wiki/Tf–idf), sklearnを利用。\n",
        "    - [word2vec](https://ja.wikipedia.org/wiki/Word2vec)\n",
        "  - ベクトル空間を利用した類似コメント検索。\n",
        "- 今回は扱わない別例\n",
        "  - 名詞や形容詞など特定品詞のみ処理する。ストップワードで不要語を削除する。類語をまとめてしまう。n-gram、共起、係り受け情報の利用, etc."
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "# spacy, ginzaインストール\n",
        "!pip install -U ginza ja_ginza"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "zzc4KkEDUuz7",
        "outputId": "4c0d8e89-4b72-4dbb-b1dc-6eb33136a664"
      },
      "execution_count": 2,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "Collecting ginza\n",
            "  Downloading ginza-5.2.0-py3-none-any.whl (21 kB)\n",
            "Collecting ja_ginza\n",
            "  Downloading ja_ginza-5.2.0-py3-none-any.whl (59.1 MB)\n",
            "\u001b[2K     \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m59.1/59.1 MB\u001b[0m \u001b[31m9.6 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
            "\u001b[?25hRequirement already satisfied: spacy<4.0.0,>=3.4.4 in /usr/local/lib/python3.10/dist-packages (from ginza) (3.7.4)\n",
            "Collecting plac>=1.3.3 (from ginza)\n",
            "  Downloading plac-1.4.3-py2.py3-none-any.whl (22 kB)\n",
            "Collecting SudachiPy<0.7.0,>=0.6.2 (from ginza)\n",
            "  Downloading SudachiPy-0.6.8-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.6 MB)\n",
            "\u001b[2K     \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m2.6/2.6 MB\u001b[0m \u001b[31m29.4 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
            "\u001b[?25hCollecting SudachiDict-core>=20210802 (from ginza)\n",
            "  Downloading SudachiDict_core-20240409-py3-none-any.whl (72.0 MB)\n",
            "\u001b[2K     \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m72.0/72.0 MB\u001b[0m \u001b[31m5.7 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
            "\u001b[?25hRequirement already satisfied: spacy-legacy<3.1.0,>=3.0.11 in /usr/local/lib/python3.10/dist-packages (from spacy<4.0.0,>=3.4.4->ginza) (3.0.12)\n",
            "Requirement already satisfied: spacy-loggers<2.0.0,>=1.0.0 in /usr/local/lib/python3.10/dist-packages (from spacy<4.0.0,>=3.4.4->ginza) (1.0.5)\n",
            "Requirement already satisfied: murmurhash<1.1.0,>=0.28.0 in /usr/local/lib/python3.10/dist-packages (from spacy<4.0.0,>=3.4.4->ginza) (1.0.10)\n",
            "Requirement already satisfied: cymem<2.1.0,>=2.0.2 in /usr/local/lib/python3.10/dist-packages (from spacy<4.0.0,>=3.4.4->ginza) (2.0.8)\n",
            "Requirement already satisfied: preshed<3.1.0,>=3.0.2 in /usr/local/lib/python3.10/dist-packages (from spacy<4.0.0,>=3.4.4->ginza) (3.0.9)\n",
            "Requirement already satisfied: thinc<8.3.0,>=8.2.2 in /usr/local/lib/python3.10/dist-packages (from spacy<4.0.0,>=3.4.4->ginza) (8.2.3)\n",
            "Requirement already satisfied: wasabi<1.2.0,>=0.9.1 in /usr/local/lib/python3.10/dist-packages (from spacy<4.0.0,>=3.4.4->ginza) (1.1.2)\n",
            "Requirement already satisfied: srsly<3.0.0,>=2.4.3 in /usr/local/lib/python3.10/dist-packages (from spacy<4.0.0,>=3.4.4->ginza) (2.4.8)\n",
            "Requirement already satisfied: catalogue<2.1.0,>=2.0.6 in /usr/local/lib/python3.10/dist-packages (from spacy<4.0.0,>=3.4.4->ginza) (2.0.10)\n",
            "Requirement already satisfied: weasel<0.4.0,>=0.1.0 in /usr/local/lib/python3.10/dist-packages (from spacy<4.0.0,>=3.4.4->ginza) (0.3.4)\n",
            "Requirement already satisfied: typer<0.10.0,>=0.3.0 in /usr/local/lib/python3.10/dist-packages (from spacy<4.0.0,>=3.4.4->ginza) (0.9.4)\n",
            "Requirement already satisfied: smart-open<7.0.0,>=5.2.1 in /usr/local/lib/python3.10/dist-packages (from spacy<4.0.0,>=3.4.4->ginza) (6.4.0)\n",
            "Requirement already satisfied: tqdm<5.0.0,>=4.38.0 in /usr/local/lib/python3.10/dist-packages (from spacy<4.0.0,>=3.4.4->ginza) (4.66.4)\n",
            "Requirement already satisfied: requests<3.0.0,>=2.13.0 in /usr/local/lib/python3.10/dist-packages (from spacy<4.0.0,>=3.4.4->ginza) (2.31.0)\n",
            "Requirement already satisfied: pydantic!=1.8,!=1.8.1,<3.0.0,>=1.7.4 in /usr/local/lib/python3.10/dist-packages (from spacy<4.0.0,>=3.4.4->ginza) (2.7.2)\n",
            "Requirement already satisfied: jinja2 in /usr/local/lib/python3.10/dist-packages (from spacy<4.0.0,>=3.4.4->ginza) (3.1.4)\n",
            "Requirement already satisfied: setuptools in /usr/local/lib/python3.10/dist-packages (from spacy<4.0.0,>=3.4.4->ginza) (67.7.2)\n",
            "Requirement already satisfied: packaging>=20.0 in /usr/local/lib/python3.10/dist-packages (from spacy<4.0.0,>=3.4.4->ginza) (24.0)\n",
            "Requirement already satisfied: langcodes<4.0.0,>=3.2.0 in /usr/local/lib/python3.10/dist-packages (from spacy<4.0.0,>=3.4.4->ginza) (3.4.0)\n",
            "Requirement already satisfied: numpy>=1.19.0 in /usr/local/lib/python3.10/dist-packages (from spacy<4.0.0,>=3.4.4->ginza) (1.25.2)\n",
            "Requirement already satisfied: language-data>=1.2 in /usr/local/lib/python3.10/dist-packages (from langcodes<4.0.0,>=3.2.0->spacy<4.0.0,>=3.4.4->ginza) (1.2.0)\n",
            "Requirement already satisfied: annotated-types>=0.4.0 in /usr/local/lib/python3.10/dist-packages (from pydantic!=1.8,!=1.8.1,<3.0.0,>=1.7.4->spacy<4.0.0,>=3.4.4->ginza) (0.7.0)\n",
            "Requirement already satisfied: pydantic-core==2.18.3 in /usr/local/lib/python3.10/dist-packages (from pydantic!=1.8,!=1.8.1,<3.0.0,>=1.7.4->spacy<4.0.0,>=3.4.4->ginza) (2.18.3)\n",
            "Requirement already satisfied: typing-extensions>=4.6.1 in /usr/local/lib/python3.10/dist-packages (from pydantic!=1.8,!=1.8.1,<3.0.0,>=1.7.4->spacy<4.0.0,>=3.4.4->ginza) (4.12.0)\n",
            "Requirement already satisfied: charset-normalizer<4,>=2 in /usr/local/lib/python3.10/dist-packages (from requests<3.0.0,>=2.13.0->spacy<4.0.0,>=3.4.4->ginza) (3.3.2)\n",
            "Requirement already satisfied: idna<4,>=2.5 in /usr/local/lib/python3.10/dist-packages (from requests<3.0.0,>=2.13.0->spacy<4.0.0,>=3.4.4->ginza) (3.7)\n",
            "Requirement already satisfied: urllib3<3,>=1.21.1 in /usr/local/lib/python3.10/dist-packages (from requests<3.0.0,>=2.13.0->spacy<4.0.0,>=3.4.4->ginza) (2.0.7)\n",
            "Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.10/dist-packages (from requests<3.0.0,>=2.13.0->spacy<4.0.0,>=3.4.4->ginza) (2024.2.2)\n",
            "Requirement already satisfied: blis<0.8.0,>=0.7.8 in /usr/local/lib/python3.10/dist-packages (from thinc<8.3.0,>=8.2.2->spacy<4.0.0,>=3.4.4->ginza) (0.7.11)\n",
            "Requirement already satisfied: confection<1.0.0,>=0.0.1 in /usr/local/lib/python3.10/dist-packages (from thinc<8.3.0,>=8.2.2->spacy<4.0.0,>=3.4.4->ginza) (0.1.4)\n",
            "Requirement already satisfied: click<9.0.0,>=7.1.1 in /usr/local/lib/python3.10/dist-packages (from typer<0.10.0,>=0.3.0->spacy<4.0.0,>=3.4.4->ginza) (8.1.7)\n",
            "Requirement already satisfied: cloudpathlib<0.17.0,>=0.7.0 in /usr/local/lib/python3.10/dist-packages (from weasel<0.4.0,>=0.1.0->spacy<4.0.0,>=3.4.4->ginza) (0.16.0)\n",
            "Requirement already satisfied: MarkupSafe>=2.0 in /usr/local/lib/python3.10/dist-packages (from jinja2->spacy<4.0.0,>=3.4.4->ginza) (2.1.5)\n",
            "Requirement already satisfied: marisa-trie>=0.7.7 in /usr/local/lib/python3.10/dist-packages (from language-data>=1.2->langcodes<4.0.0,>=3.2.0->spacy<4.0.0,>=3.4.4->ginza) (1.1.1)\n",
            "Installing collected packages: SudachiPy, plac, SudachiDict-core, ginza, ja_ginza\n",
            "Successfully installed SudachiDict-core-20240409 SudachiPy-0.6.8 ginza-5.2.0 ja_ginza-5.2.0 plac-1.4.3\n"
          ]
        }
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "Mj0kuXzbTiib"
      },
      "source": [
        "## 利用ライブラリの用意、データセット準備\n",
        "事前に、[load_r_assesment.ipynb](./load_r_assesment.ipynb) でデータセットを作成し、pkl形式でファイル保存(r_assesment.pkl)しておく。今回は作成済みファイルをダウンロードして利用することにする。\n",
        "\n",
        "r_assesment.pklは授業評価アンケートの自由記述欄をpd.DataFrame形式で保存したもので、授業名(title)、学年(grade)、必修か否か(required)、質問番号(q_id)、コメント(comment)で構成される。"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 3,
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "RpaweeaoTiib",
        "outputId": "f3e35818-b846-478b-f283-0a7849d2ad8d"
      },
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current\n",
            "                                 Dload  Upload   Total   Spent    Left  Speed\n",
            "100 34834  100 34834    0     0  16431      0  0:00:02  0:00:02 --:--:-- 16438\n"
          ]
        }
      ],
      "source": [
        "!curl -O https://ie.u-ryukyu.ac.jp/~tnal/2022/dm/static/r_assesment.pkl"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 4,
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 204
        },
        "id": "XJwi0DZPTiic",
        "outputId": "8a05ef18-fc17-4e40-e5c7-dddac339fe56"
      },
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "text/plain": [
              "   title  grade  required     q_id                       comment\n",
              "0  工業数学Ⅰ      1      True  Q21 (1)                          特になし\n",
              "1  工業数学Ⅰ      1      True  Q21 (2)            正直わかりずらい。むだに間があるし。\n",
              "2  工業数学Ⅰ      1      True  Q21 (2)          例題を取り入れて理解しやすくしてほしい。\n",
              "3  工業数学Ⅰ      1      True  Q21 (2)                          特になし\n",
              "4  工業数学Ⅰ      1      True  Q21 (2)  スライドに書く文字をもう少しわかりやすくして欲しいです。"
            ],
            "text/html": [
              "\n",
              "  <div id=\"df-e989814e-9063-424c-b71e-b1563b0ea040\" class=\"colab-df-container\">\n",
              "    <div>\n",
              "<style scoped>\n",
              "    .dataframe tbody tr th:only-of-type {\n",
              "        vertical-align: middle;\n",
              "    }\n",
              "\n",
              "    .dataframe tbody tr th {\n",
              "        vertical-align: top;\n",
              "    }\n",
              "\n",
              "    .dataframe thead th {\n",
              "        text-align: right;\n",
              "    }\n",
              "</style>\n",
              "<table border=\"1\" class=\"dataframe\">\n",
              "  <thead>\n",
              "    <tr style=\"text-align: right;\">\n",
              "      <th></th>\n",
              "      <th>title</th>\n",
              "      <th>grade</th>\n",
              "      <th>required</th>\n",
              "      <th>q_id</th>\n",
              "      <th>comment</th>\n",
              "    </tr>\n",
              "  </thead>\n",
              "  <tbody>\n",
              "    <tr>\n",
              "      <th>0</th>\n",
              "      <td>工業数学Ⅰ</td>\n",
              "      <td>1</td>\n",
              "      <td>True</td>\n",
              "      <td>Q21 (1)</td>\n",
              "      <td>特になし</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>1</th>\n",
              "      <td>工業数学Ⅰ</td>\n",
              "      <td>1</td>\n",
              "      <td>True</td>\n",
              "      <td>Q21 (2)</td>\n",
              "      <td>正直わかりずらい。むだに間があるし。</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>2</th>\n",
              "      <td>工業数学Ⅰ</td>\n",
              "      <td>1</td>\n",
              "      <td>True</td>\n",
              "      <td>Q21 (2)</td>\n",
              "      <td>例題を取り入れて理解しやすくしてほしい。</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>3</th>\n",
              "      <td>工業数学Ⅰ</td>\n",
              "      <td>1</td>\n",
              "      <td>True</td>\n",
              "      <td>Q21 (2)</td>\n",
              "      <td>特になし</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>4</th>\n",
              "      <td>工業数学Ⅰ</td>\n",
              "      <td>1</td>\n",
              "      <td>True</td>\n",
              "      <td>Q21 (2)</td>\n",
              "      <td>スライドに書く文字をもう少しわかりやすくして欲しいです。</td>\n",
              "    </tr>\n",
              "  </tbody>\n",
              "</table>\n",
              "</div>\n",
              "    <div class=\"colab-df-buttons\">\n",
              "\n",
              "  <div class=\"colab-df-container\">\n",
              "    <button class=\"colab-df-convert\" onclick=\"convertToInteractive('df-e989814e-9063-424c-b71e-b1563b0ea040')\"\n",
              "            title=\"Convert this dataframe to an interactive table.\"\n",
              "            style=\"display:none;\">\n",
              "\n",
              "  <svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\" viewBox=\"0 -960 960 960\">\n",
              "    <path d=\"M120-120v-720h720v720H120Zm60-500h600v-160H180v160Zm220 220h160v-160H400v160Zm0 220h160v-160H400v160ZM180-400h160v-160H180v160Zm440 0h160v-160H620v160ZM180-180h160v-160H180v160Zm440 0h160v-160H620v160Z\"/>\n",
              "  </svg>\n",
              "    </button>\n",
              "\n",
              "  <style>\n",
              "    .colab-df-container {\n",
              "      display:flex;\n",
              "      gap: 12px;\n",
              "    }\n",
              "\n",
              "    .colab-df-convert {\n",
              "      background-color: #E8F0FE;\n",
              "      border: none;\n",
              "      border-radius: 50%;\n",
              "      cursor: pointer;\n",
              "      display: none;\n",
              "      fill: #1967D2;\n",
              "      height: 32px;\n",
              "      padding: 0 0 0 0;\n",
              "      width: 32px;\n",
              "    }\n",
              "\n",
              "    .colab-df-convert:hover {\n",
              "      background-color: #E2EBFA;\n",
              "      box-shadow: 0px 1px 2px rgba(60, 64, 67, 0.3), 0px 1px 3px 1px rgba(60, 64, 67, 0.15);\n",
              "      fill: #174EA6;\n",
              "    }\n",
              "\n",
              "    .colab-df-buttons div {\n",
              "      margin-bottom: 4px;\n",
              "    }\n",
              "\n",
              "    [theme=dark] .colab-df-convert {\n",
              "      background-color: #3B4455;\n",
              "      fill: #D2E3FC;\n",
              "    }\n",
              "\n",
              "    [theme=dark] .colab-df-convert:hover {\n",
              "      background-color: #434B5C;\n",
              "      box-shadow: 0px 1px 3px 1px rgba(0, 0, 0, 0.15);\n",
              "      filter: drop-shadow(0px 1px 2px rgba(0, 0, 0, 0.3));\n",
              "      fill: #FFFFFF;\n",
              "    }\n",
              "  </style>\n",
              "\n",
              "    <script>\n",
              "      const buttonEl =\n",
              "        document.querySelector('#df-e989814e-9063-424c-b71e-b1563b0ea040 button.colab-df-convert');\n",
              "      buttonEl.style.display =\n",
              "        google.colab.kernel.accessAllowed ? 'block' : 'none';\n",
              "\n",
              "      async function convertToInteractive(key) {\n",
              "        const element = document.querySelector('#df-e989814e-9063-424c-b71e-b1563b0ea040');\n",
              "        const dataTable =\n",
              "          await google.colab.kernel.invokeFunction('convertToInteractive',\n",
              "                                                    [key], {});\n",
              "        if (!dataTable) return;\n",
              "\n",
              "        const docLinkHtml = 'Like what you see? Visit the ' +\n",
              "          '<a target=\"_blank\" href=https://colab.research.google.com/notebooks/data_table.ipynb>data table notebook</a>'\n",
              "          + ' to learn more about interactive tables.';\n",
              "        element.innerHTML = '';\n",
              "        dataTable['output_type'] = 'display_data';\n",
              "        await google.colab.output.renderOutput(dataTable, element);\n",
              "        const docLink = document.createElement('div');\n",
              "        docLink.innerHTML = docLinkHtml;\n",
              "        element.appendChild(docLink);\n",
              "      }\n",
              "    </script>\n",
              "  </div>\n",
              "\n",
              "\n",
              "<div id=\"df-3a85416f-4a4e-4e4c-b0c8-9ff29dc0f645\">\n",
              "  <button class=\"colab-df-quickchart\" onclick=\"quickchart('df-3a85416f-4a4e-4e4c-b0c8-9ff29dc0f645')\"\n",
              "            title=\"Suggest charts\"\n",
              "            style=\"display:none;\">\n",
              "\n",
              "<svg xmlns=\"http://www.w3.org/2000/svg\" height=\"24px\"viewBox=\"0 0 24 24\"\n",
              "     width=\"24px\">\n",
              "    <g>\n",
              "        <path d=\"M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zM9 17H7v-7h2v7zm4 0h-2V7h2v10zm4 0h-2v-4h2v4z\"/>\n",
              "    </g>\n",
              "</svg>\n",
              "  </button>\n",
              "\n",
              "<style>\n",
              "  .colab-df-quickchart {\n",
              "      --bg-color: #E8F0FE;\n",
              "      --fill-color: #1967D2;\n",
              "      --hover-bg-color: #E2EBFA;\n",
              "      --hover-fill-color: #174EA6;\n",
              "      --disabled-fill-color: #AAA;\n",
              "      --disabled-bg-color: #DDD;\n",
              "  }\n",
              "\n",
              "  [theme=dark] .colab-df-quickchart {\n",
              "      --bg-color: #3B4455;\n",
              "      --fill-color: #D2E3FC;\n",
              "      --hover-bg-color: #434B5C;\n",
              "      --hover-fill-color: #FFFFFF;\n",
              "      --disabled-bg-color: #3B4455;\n",
              "      --disabled-fill-color: #666;\n",
              "  }\n",
              "\n",
              "  .colab-df-quickchart {\n",
              "    background-color: var(--bg-color);\n",
              "    border: none;\n",
              "    border-radius: 50%;\n",
              "    cursor: pointer;\n",
              "    display: none;\n",
              "    fill: var(--fill-color);\n",
              "    height: 32px;\n",
              "    padding: 0;\n",
              "    width: 32px;\n",
              "  }\n",
              "\n",
              "  .colab-df-quickchart:hover {\n",
              "    background-color: var(--hover-bg-color);\n",
              "    box-shadow: 0 1px 2px rgba(60, 64, 67, 0.3), 0 1px 3px 1px rgba(60, 64, 67, 0.15);\n",
              "    fill: var(--button-hover-fill-color);\n",
              "  }\n",
              "\n",
              "  .colab-df-quickchart-complete:disabled,\n",
              "  .colab-df-quickchart-complete:disabled:hover {\n",
              "    background-color: var(--disabled-bg-color);\n",
              "    fill: var(--disabled-fill-color);\n",
              "    box-shadow: none;\n",
              "  }\n",
              "\n",
              "  .colab-df-spinner {\n",
              "    border: 2px solid var(--fill-color);\n",
              "    border-color: transparent;\n",
              "    border-bottom-color: var(--fill-color);\n",
              "    animation:\n",
              "      spin 1s steps(1) infinite;\n",
              "  }\n",
              "\n",
              "  @keyframes spin {\n",
              "    0% {\n",
              "      border-color: transparent;\n",
              "      border-bottom-color: var(--fill-color);\n",
              "      border-left-color: var(--fill-color);\n",
              "    }\n",
              "    20% {\n",
              "      border-color: transparent;\n",
              "      border-left-color: var(--fill-color);\n",
              "      border-top-color: var(--fill-color);\n",
              "    }\n",
              "    30% {\n",
              "      border-color: transparent;\n",
              "      border-left-color: var(--fill-color);\n",
              "      border-top-color: var(--fill-color);\n",
              "      border-right-color: var(--fill-color);\n",
              "    }\n",
              "    40% {\n",
              "      border-color: transparent;\n",
              "      border-right-color: var(--fill-color);\n",
              "      border-top-color: var(--fill-color);\n",
              "    }\n",
              "    60% {\n",
              "      border-color: transparent;\n",
              "      border-right-color: var(--fill-color);\n",
              "    }\n",
              "    80% {\n",
              "      border-color: transparent;\n",
              "      border-right-color: var(--fill-color);\n",
              "      border-bottom-color: var(--fill-color);\n",
              "    }\n",
              "    90% {\n",
              "      border-color: transparent;\n",
              "      border-bottom-color: var(--fill-color);\n",
              "    }\n",
              "  }\n",
              "</style>\n",
              "\n",
              "  <script>\n",
              "    async function quickchart(key) {\n",
              "      const quickchartButtonEl =\n",
              "        document.querySelector('#' + key + ' button');\n",
              "      quickchartButtonEl.disabled = true;  // To prevent multiple clicks.\n",
              "      quickchartButtonEl.classList.add('colab-df-spinner');\n",
              "      try {\n",
              "        const charts = await google.colab.kernel.invokeFunction(\n",
              "            'suggestCharts', [key], {});\n",
              "      } catch (error) {\n",
              "        console.error('Error during call to suggestCharts:', error);\n",
              "      }\n",
              "      quickchartButtonEl.classList.remove('colab-df-spinner');\n",
              "      quickchartButtonEl.classList.add('colab-df-quickchart-complete');\n",
              "    }\n",
              "    (() => {\n",
              "      let quickchartButtonEl =\n",
              "        document.querySelector('#df-3a85416f-4a4e-4e4c-b0c8-9ff29dc0f645 button');\n",
              "      quickchartButtonEl.style.display =\n",
              "        google.colab.kernel.accessAllowed ? 'block' : 'none';\n",
              "    })();\n",
              "  </script>\n",
              "</div>\n",
              "    </div>\n",
              "  </div>\n"
            ],
            "application/vnd.google.colaboratory.intrinsic+json": {
              "type": "dataframe",
              "variable_name": "assesment_df",
              "summary": "{\n  \"name\": \"assesment_df\",\n  \"rows\": 170,\n  \"fields\": [\n    {\n      \"column\": \"title\",\n      \"properties\": {\n        \"dtype\": \"category\",\n        \"num_unique_values\": 16,\n        \"samples\": [\n          \"\\u5de5\\u696d\\u6570\\u5b66\\u2160\",\n          \"\\u6280\\u8853\\u8005\\u306e\\u502b\\u7406\",\n          \"\\u30a2\\u30eb\\u30b4\\u30ea\\u30ba\\u30e0\\u3068\\u30c7\\u30fc\\u30bf\\u69cb\\u9020\"\n        ],\n        \"semantic_type\": \"\",\n        \"description\": \"\"\n      }\n    },\n    {\n      \"column\": \"grade\",\n      \"properties\": {\n        \"dtype\": \"number\",\n        \"std\": 0,\n        \"min\": 1,\n        \"max\": 3,\n        \"num_unique_values\": 3,\n        \"samples\": [\n          1,\n          2,\n          3\n        ],\n        \"semantic_type\": \"\",\n        \"description\": \"\"\n      }\n    },\n    {\n      \"column\": \"required\",\n      \"properties\": {\n        \"dtype\": \"boolean\",\n        \"num_unique_values\": 2,\n        \"samples\": [\n          false,\n          true\n        ],\n        \"semantic_type\": \"\",\n        \"description\": \"\"\n      }\n    },\n    {\n      \"column\": \"q_id\",\n      \"properties\": {\n        \"dtype\": \"category\",\n        \"num_unique_values\": 5,\n        \"samples\": [\n          \"Q21 (2)\",\n          \"Q22\"\n        ],\n        \"semantic_type\": \"\",\n        \"description\": \"\"\n      }\n    },\n    {\n      \"column\": \"comment\",\n      \"properties\": {\n        \"dtype\": \"string\",\n        \"num_unique_values\": 153,\n        \"samples\": [\n          \"\\u30fb\\u6559\\u79d1\\u66f8\\u304c\\u5fc5\\u8981\\u306a\\u306e\\u304b\\u5fc5\\u8981\\u3067\\u306a\\u3044\\u306e\\u304b\\u304c\\u66d6\\u6627\\u306a\\u307e\\u307e\\u6388\\u696d\\u304c\\u59cb\\u307e\\u308a\\u3001\\u975e\\u5e38\\u306b\\u4e0d\\u5b89\\u3060\\u3063\\u305f\\u305f\\u3081\\u3001\\u6559\\u79d1\\u66f8\\u304c\\u5fc5\\u9808\\u304b\\u305d\\u3046\\u3067\\u306a\\u3044\\u306e\\u304b\\u306f\\u6700\\u521d\\u306b\\u306f\\u3063\\u304d\\u308a\\u3057\\u3066\\u6b32\\u3057\\u3044\\u3002\\r\\n\\u30fb\\u8ab2\\u984c\\u3092\\u51fa\\u3059\\u3060\\u3051\\u51fa\\u3055\\u305b\\u3066\\u304a\\u3044\\u3066\\u3001\\u63a1\\u70b9\\u3082\\u305b\\u305a\\u3001\\u3069\\u3046\\u3044\\u3063\\u305f\\u89e3\\u7b54\\u304c\\u6b63\\u3057\\u3044\\u306e\\u304b\\u3068\\u3044\\u3063\\u305f\\u6307\\u91dd\\u3082\\u51fa\\u3059\\u306e\\u304c\\u3068\\u3066\\u3082\\u9045\\u3044\\u3002\\u8ab2\\u984c\\u306f\\u89e3\\u304f\\u3060\\u3051\\u3067\\u306f\\u77e5\\u8b58\\u306e\\u5b9a\\u7740\\u306b\\u3064\\u306a\\u304c\\u3089\\u306a\\u3044\\u3068\\u601d\\u3044\\u307e\\u3059\\u304c\\u3001\\u305d\\u3053\\u3089\\u3078\\u3093\\u306f\\u3069\\u3046\\u306a\\u3093\\u3067\\u3057\\u3087\\u3046\\u304b\\u3002\\r\\n\\u30fb\\u914d\\u5e03\\u8cc7\\u6599\\u3068\\u3057\\u3066\\u3001\\u904e\\u53bb\\u554f\\u3082\\u914d\\u5e03\\u3057\\u3066\\u304f\\u308c\\u308b\\u3068\\u3068\\u3066\\u3082\\u52a9\\u304b\\u308b\\u306a\\u3001\\u3068\\u601d\\u3044\\u307e\\u3059\\u3002\\u3054\\u691c\\u8a0e\\u304a\\u9858\\u3044\\u3057\\u307e\\u3059\\u3002\",\n          \"\\u30fb\\u4e2d\\u9593\\u30c6\\u30b9\\u30c8\\u3092\\u5ef6\\u671f\\u3057\\u7d9a\\u3051\\u3001\\u6700\\u7d42\\u7684\\u306b\\u4e2d\\u9593\\u30fb\\u671f\\u672b\\u8a66\\u9a13\\u3092\\uff12\\u9031\\u7d9a\\u3051\\u3066\\u3084\\u308b\\u3053\\u3068\\u3068\\u306a\\u308a\\u3001\\u8a08\\u753b\\u6027\\u304c\\u6b20\\u3051\\u3066\\u3044\\u308b\\u3002\\r\\n\\u30fb\\u914d\\u5e03\\u8cc7\\u6599\\u306e\\u8aa4\\u5b57\\u8131\\u5b57\\u304c\\u591a\\u3059\\u304e\\u308b\\u3002\"\n        ],\n        \"semantic_type\": \"\",\n        \"description\": \"\"\n      }\n    }\n  ]\n}"
            }
          },
          "metadata": {},
          "execution_count": 4
        }
      ],
      "source": [
        "import numpy as np\n",
        "import pandas as pd\n",
        "import spacy\n",
        "\n",
        "nlp = spacy.load(\"ja_ginza\")\n",
        "\n",
        "assesment_df = pd.read_pickle('r_assesment.pkl')\n",
        "assesment_df.head()"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "3MhIDL_FTiid"
      },
      "source": [
        "## サンプルの単位（ベクトル化の対象）を決める\n",
        "assesment_dfの comment はある科目（title）の質問（q_id）に対する回答内容（comment）が記録されている。この回答内容は受講者毎に別コメントとして記載されている。例えば上記出力内容においては、``title = 工業数学Ⅰ and q_id = Q21(2)`` となっているコメントが4件表示されている。これらは異なる受講者が同一質問に対して回答したことを示している。また2行目の出力では「正直わかりづらい。むだに間があるし。」のように2つの文が記入されている。このようにコメントには複数文が含まれることもあることを想定しておこう。\n",
        "\n",
        "今回はこの「1受講生の、ある科目のある質問に対するコメント」を1サンプルとして扱うことにしよう。つまり、このassesment_dfにおけるcommentをそのままベクトル化する単位とする。"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "s4Z6MTk-Tiid"
      },
      "source": [
        "## 分かち書き処理\n",
        "spacyを使って分かち書きしよう。この際、token.lemma_により原形処理するものとする。また分かち書き結果を「スペースを区切り文字としたtoken系列」として保存することとする。例えば「これはテストです」を「これ は テスト です」という文字列として保存する。"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 5,
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "b9vYBE0CTiie",
        "outputId": "faaf7546-2852-4627-b7b7-10b7e73cb913"
      },
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "特になし\n",
            "特に なし\n"
          ]
        }
      ],
      "source": [
        "def text_to_sequence_of_words(text, sep=' '):\n",
        "    '''テキストをtokenに分割し、sep区切りの文字列として結合した文字列を返す。\n",
        "    args:\n",
        "      text (str): 処理対象となるテキスト。\n",
        "      sep (str): 処理結果を結合するための区切り文字。\n",
        "    return\n",
        "      str: sepで結合した分かち書き結果。\n",
        "    '''\n",
        "    doc = nlp(text)\n",
        "    sequence = []\n",
        "    for token in doc:\n",
        "        sequence.append(token.lemma_)\n",
        "    return sep.join(sequence)\n",
        "\n",
        "def df_to_sequence_of_words(df, column, sep=' '):\n",
        "    '''df[column]を対象として分かち書きする。\n",
        "    args:\n",
        "      df (pd.DataFrame): テキストを含むデータフレーム。\n",
        "      column (str): dfにおける処理対象となる列名。\n",
        "      sep (str): 分かち書き結果を結合する文字。\n",
        "    return\n",
        "      result ([str]): text_to_sequence_of_words()で分かち書き処理された文字列のリスト。\n",
        "    '''\n",
        "    result = []\n",
        "    for comment in df[column]:\n",
        "        result.append(text_to_sequence_of_words(comment, sep))\n",
        "    return result\n",
        "\n",
        "sequence_of_words = df_to_sequence_of_words(assesment_df, 'comment')\n",
        "print(assesment_df['comment'][0])\n",
        "print(sequence_of_words[0])"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "1XrouUPBTiie"
      },
      "source": [
        "### Bag-of-Wordsによるベクトル化"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 6,
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "SY2XonwBTiif",
        "outputId": "4f5a74f5-6a01-4214-b004-8321a3e10776"
      },
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "# normal BoW\n",
            "shape =  (170, 790)\n",
            "feature_names[:10] =  ['100' '19' '20' '30' '40' '80' 'cm' 'covid' 'css' 'denchu']\n",
            "vectors[0] = \n",
            "   (0, 596)\t1\n",
            "  (0, 122)\t1\n",
            "type(vectors[0]) =  <class 'scipy.sparse._csr.csr_matrix'>\n",
            "焼く\n",
            "ながら\n"
          ]
        }
      ],
      "source": [
        "import sklearn.feature_extraction.text as fe_text\n",
        "\n",
        "def bow(docs, stop_words=[]):\n",
        "    '''Bag-of-Wordsによるベクトルを生成。\n",
        "\n",
        "    :param docs(list): 1文書1文字列で保存。複数文書をリストとして並べたもの。\n",
        "    :return: 文書ベクトル。\n",
        "    '''\n",
        "    vectorizer = fe_text.CountVectorizer(stop_words=stop_words)\n",
        "    vectors = vectorizer.fit_transform(docs)\n",
        "    return vectors, vectorizer\n",
        "\n",
        "stop_words = ['こと', '\\r\\n', 'ため', '思う', 'いる', 'ある', 'する', 'なる']\n",
        "vectors_bow, vectorizer_bow = bow(sequence_of_words, stop_words)\n",
        "print('# normal BoW')\n",
        "print('shape = ', vectors_bow.shape)\n",
        "print('feature_names[:10] = ', vectorizer_bow.get_feature_names_out()[:10])\n",
        "print('vectors[0] = \\n',vectors_bow[0])\n",
        "print('type(vectors[0]) = ', type(vectors_bow[0]))\n",
        "print(vectorizer_bow.get_feature_names_out()[594])\n",
        "print(vectorizer_bow.get_feature_names_out()[121])"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "VpvqTGmMTiif"
      },
      "source": [
        "### TF-IDFによる特徴量調整"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 7,
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "QwYo5cmgTiif",
        "outputId": "e108ea8c-51a6-4ce7-f168-0815d37c4d41"
      },
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "# BoW + tfidf\n",
            "  (0, 122)\t3.1972245773362196\n",
            "  (0, 596)\t3.00616934057351\n"
          ]
        }
      ],
      "source": [
        "def bow_tfidf(docs, stop_words=[]):\n",
        "    '''Bag-of-WordsにTF-IDFで重み調整したベクトルを生成。\n",
        "\n",
        "    :param docs(list): 1文書1文字列で保存。複数文書をリストとして並べたもの。\n",
        "    :return: 重み調整したベクトル。\n",
        "    '''\n",
        "    vectorizer = fe_text.TfidfVectorizer(norm=None, stop_words=stop_words)\n",
        "    vectors = vectorizer.fit_transform(docs)\n",
        "    return vectors, vectorizer\n",
        "\n",
        "vectors_tfidf, vectorizer_tfidf = bow_tfidf(sequence_of_words, stop_words)\n",
        "print('# BoW + tfidf')\n",
        "print(vectors_tfidf[0])"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "dBzjaZ5WTiif"
      },
      "source": [
        "### ja_ginza(word2vec)によるベクトル化"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 8,
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "EgyLHUvATiif",
        "outputId": "270488f7-d601-4788-afa6-f1b3cd3875ed"
      },
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "# word2vec\n",
            "vectors_w2v[0][:10] =  [ 0.03997449 -0.12051773 -0.04468929 -0.12576343 -0.11509937 -0.02549797\n",
            " -0.04673433 -0.12278005  0.06705444 -0.05726326]\n"
          ]
        }
      ],
      "source": [
        "def word2vec(df, column):\n",
        "    vectors = []\n",
        "    for text in df[column]:\n",
        "        doc = nlp(text)\n",
        "        vectors.append(doc.vector)\n",
        "    return np.array(vectors)\n",
        "\n",
        "vectors_w2v = word2vec(assesment_df, 'comment')\n",
        "print('# word2vec')\n",
        "print('vectors_w2v[0][:10] = ', vectors_w2v[0][:10])"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "0PtHzI25Tiig"
      },
      "source": [
        "## 類似コメント抽出実験\n",
        "テキストを3手法でベクトル化することが出来た。このベクトル空間を使って類似コメント（ベクトル空間内でのコサイン類似度が高いコメント）を検索してみよう。3つのベクトル空間はそれぞれ異なるため、例えばBoWで検索したい場合には検索クエリをBoWベクトル空間に写像し、近いベクトルを探すという手順を踏む必要がある。"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "12iT70HATiig"
      },
      "source": [
        "### BoWの場合"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 9,
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "1RCUSu2dTiig",
        "outputId": "f6775b80-71ac-457c-d7cf-b43c06ed7c08"
      },
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "授業 が 難しい\n",
            "  (0, 489)\t1\n",
            "  (0, 775)\t1\n"
          ]
        }
      ],
      "source": [
        "query = '授業が難しい'\n",
        "sequence_of_words = text_to_sequence_of_words(query)\n",
        "print(sequence_of_words)\n",
        "target_vector_bow = vectorizer_bow.transform([sequence_of_words])\n",
        "print(target_vector_bow)"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 10,
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "wTXcGGbsTiig",
        "outputId": "cc287772-7513-4c04-81ba-972bc646b2e6"
      },
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "similarity = 0.500 => 難しかったです\n",
            "similarity = 0.354 => コロナのせいで無くなったけど合宿授業したかった。でも、改めて授業として道徳を学ぶことができてためになったのでよかったです。\n",
            "similarity = 0.345 => 試験内容に初めて見る問題があった．さらにその後の解説もあまりなかったので難易度が他の授業に比べて高すぎると感じました．それは，内容が難しいというよりも授業で試験に出る内容を網羅し切れていないことによるものと思いました．遠隔の試験であったことが大きいということは重々承知の上で，問題内容が伝わり辛かったので他の授業のようにどうにか対応して欲しかったです．また，平均点が他の授業と比べて低すぎるので追加で課題などが欲しかったです．\n",
            "similarity = 0.289 => 元気がある先生で、授業も楽しく聞けました。\n",
            "similarity = 0.289 => プログラミングを全く触ったことがなかったのでとても難しかった。\n"
          ]
        }
      ],
      "source": [
        "from sklearn.metrics.pairwise import cosine_similarity\n",
        "\n",
        "def most_similar_comment_indices(vectors, query_vector, n=3):\n",
        "    similarities = cosine_similarity(vectors, query_vector)\n",
        "    similarities = similarities.reshape(len(similarities)) # 1行に整形\n",
        "    most_similar_indicies = np.argsort(similarities)[::-1][:n]\n",
        "    most_similarities = np.sort(similarities)[::-1][:n]\n",
        "    return most_similar_indicies, most_similarities\n",
        "\n",
        "def print_comment_with_similarity(df, column, indicies, similarities):\n",
        "    for i in range(len(indicies)):\n",
        "        comment = df[column][indicies[i]]\n",
        "        similarity = similarities[i]\n",
        "        print(f'similarity = {similarity:.3f} => {comment}')\n",
        "\n",
        "indicies, similarities = most_similar_comment_indices(vectors_bow, target_vector_bow, 5)\n",
        "print_comment_with_similarity(assesment_df, 'comment', indicies, similarities)\n"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "q0_6UYyATiig"
      },
      "source": [
        "### TF-IDFの場合"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 11,
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "4wT58atKTiig",
        "outputId": "8434a06a-9de4-49e6-fea7-8d4b8473f9bc"
      },
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "  (0, 775)\t3.502606226887401\n",
            "  (0, 489)\t2.55814461804655\n",
            "similarity = 0.699 => 難しかったです\n",
            "similarity = 0.287 => プログラミングを全く触ったことがなかったのでとても難しかった。\n",
            "similarity = 0.279 => まだ１年次ということもあり、特に難しくなくてよかったです。\n",
            "similarity = 0.236 => 試験内容に初めて見る問題があった．さらにその後の解説もあまりなかったので難易度が他の授業に比べて高すぎると感じました．それは，内容が難しいというよりも授業で試験に出る内容を網羅し切れていないことによるものと思いました．遠隔の試験であったことが大きいということは重々承知の上で，問題内容が伝わり辛かったので他の授業のようにどうにか対応して欲しかったです．また，平均点が他の授業と比べて低すぎるので追加で課題などが欲しかったです．\n",
            "similarity = 0.228 => 課題は学びはじめにとっては難しかったけど達成感はGOOD\n"
          ]
        }
      ],
      "source": [
        "target_vector_tfidf = vectorizer_tfidf.transform([sequence_of_words])\n",
        "print(target_vector_tfidf)\n",
        "\n",
        "indicies, similarities = most_similar_comment_indices(vectors_tfidf, target_vector_tfidf, 5)\n",
        "print_comment_with_similarity(assesment_df, 'comment', indicies, similarities)"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "lGhNIAMKTiih"
      },
      "source": [
        "### word2vecの場合"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 12,
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "iWrt2B0rTiih",
        "outputId": "5db01ff3-5796-46b9-cb32-dde6379b9d7f"
      },
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "[-0.09240351 -0.11036714 -0.05784035 -0.07640907 -0.04625978]\n",
            "similarity = 0.839 => 教科書が必要ない講義ということで最初は不安でしたが、講義内の説明もわかりやすく、授業資料もとても丁寧に書かれていたため、しっかりと学習することができました。\n",
            "similarity = 0.821 => 生徒が自主学習できる環境を作ってくれていたため、とても勉強しやすかったです。\n",
            "similarity = 0.820 => 元気がある先生で、授業も楽しく聞けました。\n",
            "similarity = 0.820 => 受講前から噂は聞いていたので心してかかったつもりですが、それでも思わずクソゲーと叫びたくなるような難易度でした。これの恐ろしいところは、課題や授業で出された問題は解けるのですが、中間・期末テストで急激に難易度が跳ね上がるところですね。\r\n",
            "\r\n",
            "せめて過去問を配布してくれたりすると、生徒側としてはテストに向けての勉強が捗るだけでなく、授業でも要点をしっかり押さえて勉強できたりすると思います。\n",
            "similarity = 0.817 => ・授業の方法自体は普通であったと思います(板書が若干見づらかったが、オンラインのために板書が汚かったりすることなどはしょうがないと思いました)。\n"
          ]
        }
      ],
      "source": [
        "target_vector_w2v = [nlp(query).vector]\n",
        "print(target_vector_w2v[0][:5])\n",
        "\n",
        "indicies, similarities = most_similar_comment_indices(vectors_w2v, target_vector_w2v, 5)\n",
        "print_comment_with_similarity(assesment_df, 'comment', indicies, similarities)"
      ]
    }
  ],
  "metadata": {
    "interpreter": {
      "hash": "880b2a8c90f9e6beae80b56829e3f671fedd58b6d14887184ddce26124cedfbd"
    },
    "kernelspec": {
      "display_name": "Python 3.8.9 64-bit",
      "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.8.9"
    },
    "orig_nbformat": 4,
    "colab": {
      "provenance": []
    }
  },
  "nbformat": 4,
  "nbformat_minor": 0
}