{
  "cells": [
    {
      "cell_type": "code",
      "source": [
        "!date\n",
        "!python --version"
      ],
      "metadata": {
        "id": "55i28xNNNd_q",
        "outputId": "4ba96e67-6443-4e00-8d4c-008ba97004b6",
        "colab": {
          "base_uri": "https://localhost:8080/"
        }
      },
      "execution_count": 1,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "Mon Apr 14 06:51:06 AM UTC 2025\n",
            "Python 3.11.12\n"
          ]
        }
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "nwW4_C94NYOl"
      },
      "source": [
        "# Spacyの基本的な使い方\n",
        "- 代表的な処理\n",
        "    - 形態素解析\n",
        "    - 原形処理\n",
        "    - カウント\n",
        "    - 品詞推定\n",
        "        - [Universal POS tags](https://universaldependencies.org/u/pos/index.html)\n",
        "    - ストップワード\n",
        "    - 類義語処理（手動）\n",
        "    - 用例集\n",
        "    - n-grams\n",
        "    - 係り受け推定\n",
        "        - [Part-of-speech tags and dependencies](https://spacy.io/usage/spacy-101#annotations-pos-deps)\n",
        "    - 固有表現抽出\n",
        "    - 分散表現\n",
        "- 更新ログ\n",
        "  - 2025年4月14日: matplotlib => plotly"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "YAO5gPgXNYOn"
      },
      "source": [
        "## 環境構築\n",
        "ginza, ja_ginza をインストールしておこう。spacyも自動でインストールされます。なお、Google Colabでも実行できますが、この環境は毎回1時間程度立つとリセットされるため、その度にインストールするところからやり直す必要があります。これは手間がかかりますので、なるべくなら自身のPC内に環境構築することをお勧めします。"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 2,
      "metadata": {
        "id": "YXK3LOj0NYOn",
        "outputId": "f7758640-82e0-4b27-905b-ed17f9de2c1d",
        "colab": {
          "base_uri": "https://localhost:8080/"
        }
      },
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "Requirement already satisfied: ginza in /usr/local/lib/python3.11/dist-packages (5.2.0)\n",
            "Requirement already satisfied: ja_ginza in /usr/local/lib/python3.11/dist-packages (5.2.0)\n",
            "Requirement already satisfied: spacy<4.0.0,>=3.4.4 in /usr/local/lib/python3.11/dist-packages (from ginza) (3.8.5)\n",
            "Requirement already satisfied: plac>=1.3.3 in /usr/local/lib/python3.11/dist-packages (from ginza) (1.4.5)\n",
            "Requirement already satisfied: SudachiPy<0.7.0,>=0.6.2 in /usr/local/lib/python3.11/dist-packages (from ginza) (0.6.10)\n",
            "Requirement already satisfied: SudachiDict-core>=20210802 in /usr/local/lib/python3.11/dist-packages (from ginza) (20250129)\n",
            "Requirement already satisfied: spacy-legacy<3.1.0,>=3.0.11 in /usr/local/lib/python3.11/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.11/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.11/dist-packages (from spacy<4.0.0,>=3.4.4->ginza) (1.0.12)\n",
            "Requirement already satisfied: cymem<2.1.0,>=2.0.2 in /usr/local/lib/python3.11/dist-packages (from spacy<4.0.0,>=3.4.4->ginza) (2.0.11)\n",
            "Requirement already satisfied: preshed<3.1.0,>=3.0.2 in /usr/local/lib/python3.11/dist-packages (from spacy<4.0.0,>=3.4.4->ginza) (3.0.9)\n",
            "Requirement already satisfied: thinc<8.4.0,>=8.3.4 in /usr/local/lib/python3.11/dist-packages (from spacy<4.0.0,>=3.4.4->ginza) (8.3.6)\n",
            "Requirement already satisfied: wasabi<1.2.0,>=0.9.1 in /usr/local/lib/python3.11/dist-packages (from spacy<4.0.0,>=3.4.4->ginza) (1.1.3)\n",
            "Requirement already satisfied: srsly<3.0.0,>=2.4.3 in /usr/local/lib/python3.11/dist-packages (from spacy<4.0.0,>=3.4.4->ginza) (2.5.1)\n",
            "Requirement already satisfied: catalogue<2.1.0,>=2.0.6 in /usr/local/lib/python3.11/dist-packages (from spacy<4.0.0,>=3.4.4->ginza) (2.0.10)\n",
            "Requirement already satisfied: weasel<0.5.0,>=0.1.0 in /usr/local/lib/python3.11/dist-packages (from spacy<4.0.0,>=3.4.4->ginza) (0.4.1)\n",
            "Requirement already satisfied: typer<1.0.0,>=0.3.0 in /usr/local/lib/python3.11/dist-packages (from spacy<4.0.0,>=3.4.4->ginza) (0.15.2)\n",
            "Requirement already satisfied: tqdm<5.0.0,>=4.38.0 in /usr/local/lib/python3.11/dist-packages (from spacy<4.0.0,>=3.4.4->ginza) (4.67.1)\n",
            "Requirement already satisfied: numpy>=1.19.0 in /usr/local/lib/python3.11/dist-packages (from spacy<4.0.0,>=3.4.4->ginza) (2.0.2)\n",
            "Requirement already satisfied: requests<3.0.0,>=2.13.0 in /usr/local/lib/python3.11/dist-packages (from spacy<4.0.0,>=3.4.4->ginza) (2.32.3)\n",
            "Requirement already satisfied: pydantic!=1.8,!=1.8.1,<3.0.0,>=1.7.4 in /usr/local/lib/python3.11/dist-packages (from spacy<4.0.0,>=3.4.4->ginza) (2.11.2)\n",
            "Requirement already satisfied: jinja2 in /usr/local/lib/python3.11/dist-packages (from spacy<4.0.0,>=3.4.4->ginza) (3.1.6)\n",
            "Requirement already satisfied: setuptools in /usr/local/lib/python3.11/dist-packages (from spacy<4.0.0,>=3.4.4->ginza) (75.2.0)\n",
            "Requirement already satisfied: packaging>=20.0 in /usr/local/lib/python3.11/dist-packages (from spacy<4.0.0,>=3.4.4->ginza) (24.2)\n",
            "Requirement already satisfied: langcodes<4.0.0,>=3.2.0 in /usr/local/lib/python3.11/dist-packages (from spacy<4.0.0,>=3.4.4->ginza) (3.5.0)\n",
            "Requirement already satisfied: language-data>=1.2 in /usr/local/lib/python3.11/dist-packages (from langcodes<4.0.0,>=3.2.0->spacy<4.0.0,>=3.4.4->ginza) (1.3.0)\n",
            "Requirement already satisfied: annotated-types>=0.6.0 in /usr/local/lib/python3.11/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.33.1 in /usr/local/lib/python3.11/dist-packages (from pydantic!=1.8,!=1.8.1,<3.0.0,>=1.7.4->spacy<4.0.0,>=3.4.4->ginza) (2.33.1)\n",
            "Requirement already satisfied: typing-extensions>=4.12.2 in /usr/local/lib/python3.11/dist-packages (from pydantic!=1.8,!=1.8.1,<3.0.0,>=1.7.4->spacy<4.0.0,>=3.4.4->ginza) (4.13.1)\n",
            "Requirement already satisfied: typing-inspection>=0.4.0 in /usr/local/lib/python3.11/dist-packages (from pydantic!=1.8,!=1.8.1,<3.0.0,>=1.7.4->spacy<4.0.0,>=3.4.4->ginza) (0.4.0)\n",
            "Requirement already satisfied: charset-normalizer<4,>=2 in /usr/local/lib/python3.11/dist-packages (from requests<3.0.0,>=2.13.0->spacy<4.0.0,>=3.4.4->ginza) (3.4.1)\n",
            "Requirement already satisfied: idna<4,>=2.5 in /usr/local/lib/python3.11/dist-packages (from requests<3.0.0,>=2.13.0->spacy<4.0.0,>=3.4.4->ginza) (3.10)\n",
            "Requirement already satisfied: urllib3<3,>=1.21.1 in /usr/local/lib/python3.11/dist-packages (from requests<3.0.0,>=2.13.0->spacy<4.0.0,>=3.4.4->ginza) (2.3.0)\n",
            "Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python3.11/dist-packages (from requests<3.0.0,>=2.13.0->spacy<4.0.0,>=3.4.4->ginza) (2025.1.31)\n",
            "Requirement already satisfied: blis<1.4.0,>=1.3.0 in /usr/local/lib/python3.11/dist-packages (from thinc<8.4.0,>=8.3.4->spacy<4.0.0,>=3.4.4->ginza) (1.3.0)\n",
            "Requirement already satisfied: confection<1.0.0,>=0.0.1 in /usr/local/lib/python3.11/dist-packages (from thinc<8.4.0,>=8.3.4->spacy<4.0.0,>=3.4.4->ginza) (0.1.5)\n",
            "Requirement already satisfied: click>=8.0.0 in /usr/local/lib/python3.11/dist-packages (from typer<1.0.0,>=0.3.0->spacy<4.0.0,>=3.4.4->ginza) (8.1.8)\n",
            "Requirement already satisfied: shellingham>=1.3.0 in /usr/local/lib/python3.11/dist-packages (from typer<1.0.0,>=0.3.0->spacy<4.0.0,>=3.4.4->ginza) (1.5.4)\n",
            "Requirement already satisfied: rich>=10.11.0 in /usr/local/lib/python3.11/dist-packages (from typer<1.0.0,>=0.3.0->spacy<4.0.0,>=3.4.4->ginza) (13.9.4)\n",
            "Requirement already satisfied: cloudpathlib<1.0.0,>=0.7.0 in /usr/local/lib/python3.11/dist-packages (from weasel<0.5.0,>=0.1.0->spacy<4.0.0,>=3.4.4->ginza) (0.21.0)\n",
            "Requirement already satisfied: smart-open<8.0.0,>=5.2.1 in /usr/local/lib/python3.11/dist-packages (from weasel<0.5.0,>=0.1.0->spacy<4.0.0,>=3.4.4->ginza) (7.1.0)\n",
            "Requirement already satisfied: MarkupSafe>=2.0 in /usr/local/lib/python3.11/dist-packages (from jinja2->spacy<4.0.0,>=3.4.4->ginza) (3.0.2)\n",
            "Requirement already satisfied: marisa-trie>=1.1.0 in /usr/local/lib/python3.11/dist-packages (from language-data>=1.2->langcodes<4.0.0,>=3.2.0->spacy<4.0.0,>=3.4.4->ginza) (1.2.1)\n",
            "Requirement already satisfied: markdown-it-py>=2.2.0 in /usr/local/lib/python3.11/dist-packages (from rich>=10.11.0->typer<1.0.0,>=0.3.0->spacy<4.0.0,>=3.4.4->ginza) (3.0.0)\n",
            "Requirement already satisfied: pygments<3.0.0,>=2.13.0 in /usr/local/lib/python3.11/dist-packages (from rich>=10.11.0->typer<1.0.0,>=0.3.0->spacy<4.0.0,>=3.4.4->ginza) (2.18.0)\n",
            "Requirement already satisfied: wrapt in /usr/local/lib/python3.11/dist-packages (from smart-open<8.0.0,>=5.2.1->weasel<0.5.0,>=0.1.0->spacy<4.0.0,>=3.4.4->ginza) (1.17.2)\n",
            "Requirement already satisfied: mdurl~=0.1 in /usr/local/lib/python3.11/dist-packages (from markdown-it-py>=2.2.0->rich>=10.11.0->typer<1.0.0,>=0.3.0->spacy<4.0.0,>=3.4.4->ginza) (0.1.2)\n"
          ]
        }
      ],
      "source": [
        "# spacy, ginzaインストール\n",
        "!pip install -U ginza ja_ginza\n",
        "\n",
        "# 以下はこのコードでは使わないが、別例で使う予定のライブラリ\n",
        "#!pip install networkx # ネットワーク分析\n",
        "#!pip install pyviz    # グラフ描画ライブラリ。networkxと組み合わせて日本語化対応用。"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "QEw3HTeeNYOo"
      },
      "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": {
        "id": "97nK5CvwNYOo",
        "outputId": "89174952-3ec7-4e3d-cbfc-bca3c46f0e1a",
        "colab": {
          "base_uri": "https://localhost:8080/"
        }
      },
      "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  14713      0  0:00:02  0:00:02 --:--:-- 14710\n"
          ]
        }
      ],
      "source": [
        "!curl -O https://ie.u-ryukyu.ac.jp/~tnal/2022/dm/static/r_assesment.pkl"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 4,
      "metadata": {
        "id": "M_KsyUa6NYOo",
        "outputId": "1d6ff03a-113e-4ac3-d39a-63b87e694fd3",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 284
        }
      },
      "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-85adadf4-fb37-4c41-89d8-7053a75f1939\" 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-85adadf4-fb37-4c41-89d8-7053a75f1939')\"\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-85adadf4-fb37-4c41-89d8-7053a75f1939 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-85adadf4-fb37-4c41-89d8-7053a75f1939');\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-6f25b86e-3549-45ce-b93a-48385ead7eb6\">\n",
              "  <button class=\"colab-df-quickchart\" onclick=\"quickchart('df-6f25b86e-3549-45ce-b93a-48385ead7eb6')\"\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-6f25b86e-3549-45ce-b93a-48385ead7eb6 button');\n",
              "      quickchartButtonEl.style.display =\n",
              "        google.colab.kernel.accessAllowed ? 'block' : 'none';\n",
              "    })();\n",
              "  </script>\n",
              "</div>\n",
              "\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 collections\n",
        "\n",
        "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": "code",
      "execution_count": 5,
      "metadata": {
        "id": "5atZ_WVjNYOp",
        "outputId": "b5bd8d9a-aabe-4a8c-ad6a-4b78c3e9c90d",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 412
        }
      },
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "総件数 =  170\n",
            "grade内訳:  Counter({2: 86, 1: 78, 3: 6})\n",
            "授業内訳:  Counter({'コンピュータシステム': 32, 'プログラミングⅠ': 19, '技術者の倫理': 18, '工業数学Ⅰ': 16, 'アルゴリズムとデータ構造': 15, 'データサイエンス基礎': 15, 'プログラミング演習Ⅰ': 13, '工学基礎演習': 12, 'プロジェクトデザイン': 9, '情報ネットワークⅠ': 7, '情報処理技術概論': 7, '知能情報実験Ⅲ': 3, 'ディジタル回路': 1, 'キャリアデザイン': 1, 'データマイニング': 1, 'ICT実践英語Ⅰ': 1})\n",
            "comment統計情報\n"
          ]
        },
        {
          "output_type": "execute_result",
          "data": {
            "text/plain": [
              "count    170.000000\n",
              "mean      61.352941\n",
              "std       61.641492\n",
              "min        4.000000\n",
              "25%       21.000000\n",
              "50%       42.000000\n",
              "75%       79.750000\n",
              "max      414.000000\n",
              "dtype: float64"
            ],
            "text/html": [
              "<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>0</th>\n",
              "    </tr>\n",
              "  </thead>\n",
              "  <tbody>\n",
              "    <tr>\n",
              "      <th>count</th>\n",
              "      <td>170.000000</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>mean</th>\n",
              "      <td>61.352941</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>std</th>\n",
              "      <td>61.641492</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>min</th>\n",
              "      <td>4.000000</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>25%</th>\n",
              "      <td>21.000000</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>50%</th>\n",
              "      <td>42.000000</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>75%</th>\n",
              "      <td>79.750000</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>max</th>\n",
              "      <td>414.000000</td>\n",
              "    </tr>\n",
              "  </tbody>\n",
              "</table>\n",
              "</div><br><label><b>dtype:</b> float64</label>"
            ]
          },
          "metadata": {},
          "execution_count": 5
        }
      ],
      "source": [
        "# 全体像の観察\n",
        "print('総件数 = ', len(assesment_df))\n",
        "print('grade内訳: ', collections.Counter(assesment_df['grade']))\n",
        "print('授業内訳: ', collections.Counter(assesment_df['title']))\n",
        "\n",
        "print('comment統計情報')\n",
        "comments_length = [len(comment) for comment in assesment_df['comment']]\n",
        "pd.Series(comments_length).describe()"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "fZjUc0cUNYOp"
      },
      "source": [
        "## spacyによる自然言語処理の全体像\n",
        "- 参考: [公式ページ:spaCy 101: Everything you need to know](https://spacy.io/usage/spacy-101)\n",
        "  - [Doc形式](https://spacy.io/api/doc)\n",
        "  - [Token形式](https://spacy.io/api/token)\n",
        "  - [Span形式](https://spacy.io/api/span)\n",
        "\n",
        "<img src=\"https://spacy.io/images/pipeline.svg\">\n",
        "\n",
        "基本的な使い方は、予め学習済み言語モデルを用意し、用意したモデルに対して文章を与えるだけで一通りの解析を実行してくれる。上図は公式ページのusageから引用したもの。中間部分の青い点線で囲まれている ``nlp`` 部分が解析部分に相当する。用意したnlpに文章を入力すると自動でtagger(品詞推定)、parser(依存関係推定)、ner(固有表現推定)等の処理を一括して行う。解析結果はDoc形式として保存されている。コードで示すと以下のようになる。\n",
        "\n",
        "```Python\n",
        "import spacy\n",
        "nlp = spacy.load('ja_ginza') # 事前学習済みモデルを用意\n",
        "doc = nlp('今回は自然言語処理ライブラリであるspaCyについて紹介します。') # nlpに文章を入力すると、その戻り値に解析結果が保存される。\n",
        "```\n",
        "\n",
        "<img src=\"https://spacy.io/images/architecture.svg\">\n",
        "\n",
        "上図はspacyによる処理の流れを示している。ここでは以下の流れを把握しよう。\n",
        "- 上部のText(文章)をnlp(事前学習済み言語モデル)に与えると、赤枠のTokenizer等が実行され、結果が紫枠の[Doc形式](https://spacy.io/api/doc)で保存される。\n",
        "- Doc形式は[Token形式](https://spacy.io/api/token)もしくは[Span形式](https://spacy.io/api/span)のシーケンスである。シーケンスになっているため、これに対してループ処理を実行することで文頭から文末までのTokenまたはSpanを一つずつ参照することで詳細を確認することができる。\n",
        "- 分かち書き結果を利用する場合にはTokenを利用する。\n",
        "- Token単位では扱い難い名詞句や固有表現を利用する場合にはSpanを利用する。\n",
        "\n",
        "一例をコードで示すと以下のようになる。\n",
        "\n",
        "```Python\n",
        "import spacy\n",
        "nlp = spacy.load('ja_ginza') # 事前学習済みモデルを用意。\n",
        "doc = nlp('今回は自然言語処理ライブラリであるspaCyについて紹介します。')   # nlpに文章を入力すると、その戻り値に解析結果が保存される。\n",
        "for token in doc:  # Token単位で処理結果を参照。\n",
        "  print(token.i, token.lemma_, token.pos_)\n",
        "```\n",
        "\n",
        "上記コードを実行すると以下のような結果が得られる。文章が単語に分割されていることを確認しよう。\n",
        "```\n",
        "0 今回 NOUN\n",
        "1 は ADP\n",
        "2 自然言語処理 ADV\n",
        "3 ライブラリ ADJ\n",
        "4 だ AUX\n",
        "5 ある VERB\n",
        "6 spacy NOUN\n",
        "7 に ADP\n",
        "8 つく VERB\n",
        "9 て SCONJ\n",
        "10 紹介 VERB\n",
        "11 する AUX\n",
        "12 ます AUX\n",
        "13 。 PUNCT\n",
        "```"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "vR8z7efqNYOp"
      },
      "source": [
        "## 形態素解析による分かち書き\n",
        "ここでは良く使う機能として分かち書き、原形処理、品詞推定、ストップワードを眺めるとともに、類語をまとめる例について紹介する。それ以外の[Token利用法についてはドキュメントを参照](https://spacy.io/api/token#attributes)しよう。\n",
        "\n",
        "- case 0: 形態素解析の基本\n",
        "- case 1: 分かち書き, 原形処理(lemmatize) + カウント\n",
        "- case 2: 分かち書き, 原形処理 + 品詞別カウント\n",
        "- case 3: 分かち書き, 原形処理 + ストップワード + 品詞別カウント\n",
        "- case 4: 分かち書き, 原形処理 + ストップワード + 手動類義語処理 + 品詞別カウント"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "z_G47aXzNYOp"
      },
      "source": [
        "### case 0: 形態素解析の基本\n",
        "nlpの解析結果をfor文で順序よく参照する。"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 6,
      "metadata": {
        "id": "_kIKfhvJNYOp",
        "outputId": "8889bf44-cf68-459f-83dd-80c241648816",
        "colab": {
          "base_uri": "https://localhost:8080/"
        }
      },
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "機械トラブルの操作で授業が止まることがあった。\r\n",
            "新しいことが学べて大学って感じがした。\n",
            "0 機械 機械 NOUN compound 1\n",
            "1 トラブル トラブル NOUN nmod 3\n",
            "2 の の ADP case 1\n",
            "3 操作 操作 NOUN obl 7\n",
            "4 で で ADP case 3\n",
            "5 授業 授業 NOUN nsubj 7\n",
            "6 が が ADP case 5\n",
            "7 止まる 止まる VERB acl 8\n",
            "8 こと こと NOUN nsubj 10\n",
            "9 が が ADP case 8\n",
            "10 あっ ある VERB ROOT 10\n",
            "11 た た AUX aux 10\n",
            "12 。 。 PUNCT punct 10\n",
            "13 \r\n",
            " \r\n",
            " NOUN compound 14\n",
            "14 新しい 新しい ADJ acl 15\n",
            "15 こと こと NOUN nsubj 17\n",
            "16 が が ADP case 15\n",
            "17 学べ 学べる VERB acl 19\n",
            "18 て て SCONJ mark 17\n",
            "19 大学 大学 NOUN advcl 23\n",
            "20 って って AUX aux 19\n",
            "21 感じ 感じ NOUN nsubj 23\n",
            "22 が が ADP case 21\n",
            "23 し する VERB ROOT 23\n",
            "24 た た AUX aux 23\n",
            "25 。 。 PUNCT punct 23\n"
          ]
        }
      ],
      "source": [
        "# case 0: 形態素解析の基本\n",
        "#   token.i = 分かち書きされた単語のインデックス\n",
        "#   token.text = 分かち書きされた単語そのもの\n",
        "#   token.lemma_ = 単語を原形処理したもの\n",
        "#   token.pos_ = 品詞推定結果\n",
        "#   token.dep_ = 係り受け情報\n",
        "#   token.head.i = 係り受け元単語のインデックス\n",
        "\n",
        "sample_text = assesment_df['comment'][10]\n",
        "print(sample_text)\n",
        "\n",
        "doc = nlp(sample_text)\n",
        "for token in doc:\n",
        "    print(token.i, token.text, token.lemma_, token.pos_, token.dep_, token.head.i)"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 7,
      "metadata": {
        "id": "fn5XxEIRNYOq",
        "outputId": "f7aebd64-0036-4cfe-c31a-2f911f88615b",
        "colab": {
          "base_uri": "https://localhost:8080/"
        }
      },
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "subordinating conjunction\n",
            "nominal subject\n"
          ]
        }
      ],
      "source": [
        "# 品詞、係り受け情報等の用語は spacy.explain で補足情報を確認できる。\n",
        "# 詳細はドキュメントページ参照。\n",
        "# Universal POS tags: https://universaldependencies.org/u/pos/index.html\n",
        "# Part-of-speech tags and dependencies: https://spacy.io/usage/spacy-101#annotations-pos-deps\n",
        "\n",
        "print(spacy.explain(\"SCONJ\"))\n",
        "print(spacy.explain(\"nsubj\"))"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "v9HEru2xNYOq"
      },
      "source": [
        "### case 1: 分かち書き, 原形処理(lemmatize) + カウント\n",
        "表記上は異なる同一語に活用する語がある。これらを表記によらず同一語として扱うために、原形処理結果(token.lemma_)を処理対象としよう。"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 8,
      "metadata": {
        "id": "3qrz8V-nNYOq",
        "outputId": "f2b4fd0b-f827-48fd-e61b-5a631841369a",
        "colab": {
          "base_uri": "https://localhost:8080/"
        }
      },
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "[('た', 337), ('の', 310), ('が', 260), ('て', 233), ('。', 231), ('だ', 211), ('、', 193), ('を', 166), ('に', 162), ('と', 147)]\n"
          ]
        }
      ],
      "source": [
        "# case 1: 分かち書き, 原形処理(lemmatize) + カウント\n",
        "\n",
        "def count_lemma(df, column):\n",
        "    '''分かち書き1：原形処理のみ。\n",
        "    args:\n",
        "      df (pd.DataFrame): 読み込み対象データフレーム。\n",
        "      column (str): データフレーム内の読み込み対象列名。\n",
        "    return\n",
        "      words_list ([token.lemma_,,,]): 原形処理済み単語のリスト。\n",
        "    '''\n",
        "    words_list = []\n",
        "    for comment in df[column]:\n",
        "        doc = nlp(comment)\n",
        "        for token in doc:\n",
        "            words_list.append(token.lemma_)\n",
        "    return words_list\n",
        "\n",
        "words_list = count_lemma(assesment_df, 'comment')\n",
        "words_count = collections.Counter(words_list)\n",
        "print(words_count.most_common(10))"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "dTBXb0AcNYOq"
      },
      "source": [
        "### case 2: 分かち書き, 原形処理 + 品詞別カウント\n",
        "多くの場合、データの全体像を観察するために処理結果をカウントする。分かち書き結果の場合には多くの文章で共通して現れる助詞が圧倒的多数となってしまうため、直接カウントするだけだとあまり意味のない結果になってしまう。そこで品詞別にカウントしてみることにしよう。"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 9,
      "metadata": {
        "id": "ZInkifZzNYOq",
        "outputId": "395606a3-e69a-4712-8d0c-07d415f32b48",
        "colab": {
          "base_uri": "https://localhost:8080/"
        }
      },
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "pos =  PROPN\n",
            "[('webclass', 5), ('和田', 2), ('沖縄', 1), ('工学部', 1), ('當間', 1), ('アルゴリズム', 1), ('解決策', 1), ('クソゲー', 1), ('キャンパス', 1), ('github', 1)]\n",
            "pos =  NOUN\n",
            "[('こと', 73), ('授業', 44), ('課題', 39), ('試験', 38), ('\\r\\n', 34), ('講義', 31), ('内容', 22), ('ため', 21), ('問題', 20), ('説明', 19)]\n",
            "pos =  VERB\n",
            "[('思う', 68), ('いる', 56), ('ある', 44), ('する', 35), ('なる', 31), ('わかる', 27), ('いう', 21), ('学ぶ', 20), ('できる', 18), ('出す', 17)]\n",
            "pos =  ADJ\n",
            "[('良い', 25), ('ない', 24), ('よい', 21), ('多い', 19), ('難しい', 13), ('楽しい', 11), ('非常', 10), ('いい', 9), ('新しい', 6), ('大変', 5)]\n",
            "pos =  ADV\n",
            "[('とても', 28), ('特に', 22), ('少し', 14), ('どう', 8), ('今後', 6), ('すぐ', 6), ('もう', 4), ('まだ', 4), ('初めて', 4), ('あまり', 4)]\n"
          ]
        }
      ],
      "source": [
        "# case 2: 分かち書き, 原形処理 + 品詞別カウント\n",
        "# 対象品詞\n",
        "#  名詞(NOUN), 動詞(VERB), 形容詞(ADJ), 副詞(ADV)\n",
        "# spacyによる品詞一覧: https://universaldependencies.org/u/pos/\n",
        "\n",
        "def count_lemma2(df, column, target_poses):\n",
        "    '''分かち書き2：原形処理し、品詞別にカウント。\n",
        "    args:\n",
        "      df (pd.DataFrame): 読み込み対象データフレーム。\n",
        "      column (str): データフレーム内の読み込み対象列名。\n",
        "      target_poses ([str]): カウント対象となる品詞名のリスト。\n",
        "    return\n",
        "      words_dict ({pos1:{token1.lemma_:i, token2.lemma_:j},\n",
        "                   pos2:{token3.lemma_:k, token4.lemma_:l}}): 品詞(pos)別に、単語をカウント。\n",
        "    '''\n",
        "    words_dict = {}\n",
        "    for pos in target_poses:\n",
        "        words_dict[pos] = {}\n",
        "\n",
        "    for comment in df[column]:\n",
        "        doc = nlp(comment)\n",
        "        for token in doc:\n",
        "            if token.pos_ in target_poses:\n",
        "                if token.lemma_ not in words_dict[token.pos_]:\n",
        "                    words_dict[token.pos_].update({token.lemma_: 1})\n",
        "                else:\n",
        "                    words_dict[token.pos_][token.lemma_] += 1\n",
        "    return words_dict\n",
        "\n",
        "target_poses = ['PROPN', 'NOUN', 'VERB', 'ADJ', 'ADV']\n",
        "words_dict = count_lemma2(assesment_df, 'comment', target_poses)\n",
        "\n",
        "for pos in target_poses:\n",
        "    print('pos = ', pos)\n",
        "    words_count[pos] = collections.Counter(words_dict[pos])\n",
        "    print(words_count[pos].most_common(10))\n",
        "\n"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "iBxN3Qo5NYOq"
      },
      "source": [
        "### case 3: 分かち書き, 原形処理 + ストップワード + 品詞別カウント\n",
        "品詞別カウントのお陰である程度は概要を掴みやすくなったが、それでも「こと」「ため」「いる」のような頻出語が上位に位置してしまう。見たくない単語（ストップワード）を指定し、削除してしまおう。"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 10,
      "metadata": {
        "id": "-357LsRANYOr",
        "outputId": "e45a6f14-a01d-4409-8ecd-fb2559a934b1",
        "colab": {
          "base_uri": "https://localhost:8080/"
        }
      },
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "pos =  PROPN\n",
            "[('webclass', 5), ('和田', 2), ('沖縄', 1), ('工学部', 1), ('當間', 1), ('アルゴリズム', 1), ('解決策', 1), ('クソゲー', 1), ('キャンパス', 1), ('github', 1)]\n",
            "pos =  NOUN\n",
            "[('授業', 44), ('課題', 39), ('試験', 38), ('講義', 31), ('内容', 22), ('問題', 20), ('説明', 19), ('なし', 18), ('資料', 16), ('先生', 15)]\n",
            "pos =  VERB\n",
            "[('わかる', 27), ('いう', 21), ('学ぶ', 20), ('できる', 18), ('出す', 17), ('書く', 16), ('ござる', 13), ('つく', 13), ('理解', 12), ('見る', 11)]\n",
            "pos =  ADJ\n",
            "[('良い', 25), ('ない', 24), ('よい', 21), ('多い', 19), ('難しい', 13), ('楽しい', 11), ('非常', 10), ('いい', 9), ('新しい', 6), ('大変', 5)]\n",
            "pos =  ADV\n",
            "[('とても', 28), ('特に', 22), ('少し', 14), ('どう', 8), ('今後', 6), ('すぐ', 6), ('もう', 4), ('まだ', 4), ('初めて', 4), ('あまり', 4)]\n"
          ]
        }
      ],
      "source": [
        "# case 3: 分かち書き, 原形処理 + ストップワード + 品詞別カウント\n",
        "def count_lemma3(df, column, target_poses, stop_words):\n",
        "    '''分かち書き3：原形処理し、ストップワードを除き、品詞別にカウント。\n",
        "    args:\n",
        "      df (pd.DataFrame): 読み込み対象データフレーム。\n",
        "      column (str): データフレーム内の読み込み対象列名。\n",
        "      target_poses ([str]): カウント対象となる品詞名のリスト。\n",
        "      stop_words ([str]): 削除したい単語のリスト。\n",
        "    return\n",
        "      words_dict ({pos1:{token1.lemma_:i, token2.lemma_:j},\n",
        "                   pos2:{token3.lemma_:k, token4.lemma_:l}}): 品詞(pos)別に、単語をカウント。\n",
        "    '''\n",
        "    words_dict = {}\n",
        "    for pos in target_poses:\n",
        "        words_dict[pos] = {}\n",
        "\n",
        "    for comment in df[column]:\n",
        "        doc = nlp(comment)\n",
        "        for token in doc:\n",
        "            if token.lemma_ not in stop_words:\n",
        "                if token.pos_ in target_poses:\n",
        "                    if token.lemma_ not in words_dict[token.pos_]:\n",
        "                        words_dict[token.pos_].update({token.lemma_: 1})\n",
        "                    else:\n",
        "                        words_dict[token.pos_][token.lemma_] += 1\n",
        "    return words_dict\n",
        "\n",
        "target_poses = ['PROPN', 'NOUN', 'VERB', 'ADJ', 'ADV']\n",
        "stop_words = ['こと', '\\r\\n', 'ため', '思う', 'いる', 'ある', 'する', 'なる']\n",
        "words_dict = count_lemma3(assesment_df, 'comment', target_poses, stop_words)\n",
        "\n",
        "for pos in target_poses:\n",
        "    print('pos = ', pos)\n",
        "    words_count[pos] = collections.Counter(words_dict[pos])\n",
        "    print(words_count[pos].most_common(10))\n"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "kQbe0mc5NYOr"
      },
      "source": [
        "### case 4: 分かち書き, 原形処理 + ストップワード + 手動類義語処理 + 品詞別カウント\n",
        "名詞別カウントを眺めてみると「授業,44回」「講義,31回」とあるが、これらは同一単語としてカウントしたほうが良いだろう。しかしながら直接spacyでそのように処理することは出来ない。ここではまとめてしまいたい単語群（類義語）とその代表語を手動で用意し、類義語が出現したら代表語に置き換えてしまうことで対処してみよう。"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 11,
      "metadata": {
        "id": "hSRPn8l1NYOr",
        "outputId": "53ffeec1-88df-41bb-e7b6-eacd26bd0198",
        "colab": {
          "base_uri": "https://localhost:8080/"
        }
      },
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "pos =  PROPN\n",
            "[('webclass', 5), ('和田', 2), ('沖縄', 1), ('工学部', 1), ('當間', 1), ('アルゴリズム', 1), ('解決策', 1), ('クソゲー', 1), ('キャンパス', 1), ('github', 1)]\n",
            "pos =  NOUN\n",
            "[('授業', 75), ('課題', 39), ('試験', 38), ('内容', 22), ('問題', 20), ('説明', 19), ('なし', 18), ('資料', 16), ('先生', 15), ('お', 14)]\n",
            "pos =  VERB\n",
            "[('わかる', 27), ('いう', 21), ('学ぶ', 20), ('できる', 18), ('出す', 17), ('書く', 16), ('ござる', 13), ('つく', 13), ('理解', 12), ('見る', 11)]\n",
            "pos =  ADJ\n",
            "[('良い', 55), ('ない', 24), ('多い', 19), ('難しい', 13), ('楽しい', 11), ('非常', 10), ('新しい', 6), ('大変', 5), ('必要', 4), ('面白い', 4)]\n",
            "pos =  ADV\n",
            "[('とても', 50), ('少し', 14), ('どう', 8), ('今後', 6), ('すぐ', 6), ('もう', 4), ('まだ', 4), ('初めて', 4), ('あまり', 4), ('しっかり', 4)]\n"
          ]
        }
      ],
      "source": [
        "# case 4: 分かち書き, 原形処理 + ストップワード + 手動類義語処理 + 品詞別カウント\n",
        "\n",
        "def reverse_dict(dict_with_list):\n",
        "    result = {}\n",
        "    for k, v_list in dict_with_list.items():\n",
        "        for v in v_list:\n",
        "            result[v] = k\n",
        "    return result\n",
        "\n",
        "def count_lemma4(df, column, target_poses, stop_words, similar_words):\n",
        "    '''分かち書き4：原形処理し、ストップワードを除き、類義語を代表語に置き換え、品詞別にカウント。\n",
        "    args:\n",
        "      df (pd.DataFrame): 読み込み対象データフレーム。\n",
        "      column (str): データフレーム内の読み込み対象列名。\n",
        "      target_poses ([str]): カウント対象となる品詞名のリスト。\n",
        "      stop_words ([str]): 削除したい単語のリスト。\n",
        "      similar_words ({similar_word1:representive_word1, similar_word2:representive_word1,,}):\n",
        "        類義語辞書。keyをvalueに置き換える。\n",
        "    return\n",
        "      words_dict ({pos1:{token1.lemma_:i, token2.lemma_:j},\n",
        "                   pos2:{token3.lemma_:k, token4.lemma_:l}}): 品詞(pos)別に、単語をカウント。\n",
        "    '''\n",
        "    words_dict = {}\n",
        "    for pos in target_poses:\n",
        "        words_dict[pos] = {}\n",
        "\n",
        "    for comment in df[column]:\n",
        "        doc = nlp(comment)\n",
        "        for token in doc:\n",
        "            if token.lemma_ not in stop_words:\n",
        "                if token.lemma_ in similar_words.keys():\n",
        "                    word = similar_words[token.lemma_]\n",
        "                else:\n",
        "                    word = token.lemma_\n",
        "\n",
        "                if token.pos_ in target_poses:\n",
        "                    if word not in words_dict[token.pos_]:\n",
        "                        words_dict[token.pos_].update({word: 1})\n",
        "                    else:\n",
        "                        words_dict[token.pos_][word] += 1\n",
        "    return words_dict\n",
        "\n",
        "target_poses = ['PROPN', 'NOUN', 'VERB', 'ADJ', 'ADV']\n",
        "stop_words = ['こと', '\\r\\n', 'ため', '思う', 'いる', 'ある', 'する', 'なる']\n",
        "similar_words = {'授業':['講義'], '良い':['よい', 'いい'], 'とても':['特に']}\n",
        "similar_words = reverse_dict(similar_words)\n",
        "words_dict = count_lemma4(assesment_df, 'comment', target_poses, stop_words, similar_words)\n",
        "\n",
        "for pos in target_poses:\n",
        "    print('pos = ', pos)\n",
        "    words_count[pos] = collections.Counter(words_dict[pos])\n",
        "    print(words_count[pos].most_common(10))\n"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "d3mFs-rNNYOr"
      },
      "source": [
        "### 授業別単語頻出傾向の観察\n",
        "全コメントを対象とした頻出語は確認できたが、授業毎の違いはないのだろうか。固有名詞(PROPN)と名詞(NOUN)に限定して、授業毎にカウント＆積み上げ棒グラフとして描画してみよう。全体の流れは以下の通りである。\n",
        "\n",
        "- 頻出語上位20件を用意。\n",
        "- 授業毎に頻出語が出現した回数をカウント。数えた結果を「単語x授業行列(pd.DataFrame形式)」として整形する。\n",
        "- pd.DataFrameをplotlyで描画する。"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "XO3dTFYlNYOr"
      },
      "source": [
        "#### 頻出語上位20件を用意。"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 12,
      "metadata": {
        "id": "8dUwxPkpNYOr",
        "outputId": "7a93b2e3-31d3-45c0-f0e3-adf61f7befc7",
        "colab": {
          "base_uri": "https://localhost:8080/"
        }
      },
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "10 426 435\n"
          ]
        },
        {
          "output_type": "execute_result",
          "data": {
            "text/plain": [
              "[('授業', 75),\n",
              " ('課題', 39),\n",
              " ('試験', 38),\n",
              " ('内容', 22),\n",
              " ('問題', 20),\n",
              " ('説明', 19),\n",
              " ('なし', 18),\n",
              " ('資料', 16),\n",
              " ('先生', 15),\n",
              " ('お', 14),\n",
              " ('難易度', 12),\n",
              " ('解答', 11),\n",
              " ('実際', 11),\n",
              " ('方', 10),\n",
              " ('テスト', 10),\n",
              " ('知識', 9),\n",
              " ('機会', 9),\n",
              " ('生徒', 9),\n",
              " ('中間', 9),\n",
              " ('期末', 9)]"
            ]
          },
          "metadata": {},
          "execution_count": 12
        }
      ],
      "source": [
        "# 講義名のユニーク名一覧\n",
        "titles = assesment_df['title'].unique()\n",
        "\n",
        "# 固有名詞＋名詞の上位20単語一覧\n",
        "top_n = 20\n",
        "total_words = {**words_dict['PROPN'], **words_dict['NOUN']}\n",
        "print(len(words_dict['PROPN']), len(words_dict['NOUN']), len(total_words))\n",
        "top_n_words = collections.Counter(total_words).most_common(top_n)\n",
        "top_n_words"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "jm7n1zRHNYOr"
      },
      "source": [
        "#### 授業毎に頻出語が出現した回数をカウント。"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 13,
      "metadata": {
        "id": "HsSAy_SFNYOs",
        "outputId": "41e55c72-1e79-445f-93e5-d67f36735f8a",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 1000
        }
      },
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "text/plain": [
              "     工業数学Ⅰ  技術者の倫理  工学基礎演習  プログラミングⅠ  プログラミング演習Ⅰ  アルゴリズムとデータ構造  情報ネットワークⅠ  \\\n",
              "授業       3       3       2         0           1             2          1   \n",
              "課題       2       0       0         6           3             0          0   \n",
              "試験       0       0       0         0           0             3          0   \n",
              "内容       0       2       0         1           0             2          0   \n",
              "問題       1       0       0         0           0             4          0   \n",
              "説明       2       0       0         2           0             3          0   \n",
              "なし       3       4       4         4           3             0          0   \n",
              "資料       0       0       0         0           0             3          1   \n",
              "先生       0       3       0         1           0             1          0   \n",
              "お        1       2       0         2           1             0          3   \n",
              "難易度      0       0       0         1           0             0          0   \n",
              "解答       0       0       0         0           1             0          0   \n",
              "実際       0       0       0         0           1             0          1   \n",
              "方        0       0       1         0           1             0          2   \n",
              "テスト      0       0       0         0           0             1          1   \n",
              "知識       0       1       0         1           1             0          0   \n",
              "機会       0       0       3         0           0             0          1   \n",
              "生徒       0       0       0         0           0             1          0   \n",
              "中間       0       0       0         0           0             0          2   \n",
              "期末       0       0       0         0           0             0          0   \n",
              "\n",
              "     コンピュータシステム  データサイエンス基礎  ディジタル回路  情報処理技術概論  プロジェクトデザイン  キャリアデザイン  \\\n",
              "授業           19           4        1         2           5         0   \n",
              "課題           23           3        0         0           1         0   \n",
              "試験           29           4        0         2           0         0   \n",
              "内容           12           4        0         0           1         0   \n",
              "問題           12           2        0         1           0         0   \n",
              "説明            7           2        1         1           0         0   \n",
              "なし            0           0        0         0           0         0   \n",
              "資料            8           0        1         2           1         0   \n",
              "先生            6           2        0         1           0         1   \n",
              "お             4           1        0         0           0         0   \n",
              "難易度           8           2        0         1           0         0   \n",
              "解答            7           3        0         0           0         0   \n",
              "実際            3           1        0         3           2         0   \n",
              "方             0           2        0         2           2         0   \n",
              "テスト           6           0        0         2           0         0   \n",
              "知識            2           4        0         0           0         0   \n",
              "機会            0           0        0         0           5         0   \n",
              "生徒            8           0        0         0           0         0   \n",
              "中間            7           0        0         0           0         0   \n",
              "期末            6           0        0         3           0         0   \n",
              "\n",
              "     データマイニング  ICT実践英語Ⅰ  知能情報実験Ⅲ  \n",
              "授業          0         0        1  \n",
              "課題          1         0        0  \n",
              "試験          0         0        0  \n",
              "内容          0         0        0  \n",
              "問題          0         0        0  \n",
              "説明          0         0        1  \n",
              "なし          0         0        0  \n",
              "資料          0         0        0  \n",
              "先生          0         0        0  \n",
              "お           0         0        0  \n",
              "難易度         0         0        0  \n",
              "解答          0         0        0  \n",
              "実際          0         0        0  \n",
              "方           0         0        0  \n",
              "テスト         0         0        0  \n",
              "知識          0         0        0  \n",
              "機会          0         0        0  \n",
              "生徒          0         0        0  \n",
              "中間          0         0        0  \n",
              "期末          0         0        0  "
            ],
            "text/html": [
              "\n",
              "  <div id=\"df-6f93532e-7228-40bc-9cb1-89e945fd9e94\" 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>工業数学Ⅰ</th>\n",
              "      <th>技術者の倫理</th>\n",
              "      <th>工学基礎演習</th>\n",
              "      <th>プログラミングⅠ</th>\n",
              "      <th>プログラミング演習Ⅰ</th>\n",
              "      <th>アルゴリズムとデータ構造</th>\n",
              "      <th>情報ネットワークⅠ</th>\n",
              "      <th>コンピュータシステム</th>\n",
              "      <th>データサイエンス基礎</th>\n",
              "      <th>ディジタル回路</th>\n",
              "      <th>情報処理技術概論</th>\n",
              "      <th>プロジェクトデザイン</th>\n",
              "      <th>キャリアデザイン</th>\n",
              "      <th>データマイニング</th>\n",
              "      <th>ICT実践英語Ⅰ</th>\n",
              "      <th>知能情報実験Ⅲ</th>\n",
              "    </tr>\n",
              "  </thead>\n",
              "  <tbody>\n",
              "    <tr>\n",
              "      <th>授業</th>\n",
              "      <td>3</td>\n",
              "      <td>3</td>\n",
              "      <td>2</td>\n",
              "      <td>0</td>\n",
              "      <td>1</td>\n",
              "      <td>2</td>\n",
              "      <td>1</td>\n",
              "      <td>19</td>\n",
              "      <td>4</td>\n",
              "      <td>1</td>\n",
              "      <td>2</td>\n",
              "      <td>5</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>1</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>課題</th>\n",
              "      <td>2</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>6</td>\n",
              "      <td>3</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>23</td>\n",
              "      <td>3</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>1</td>\n",
              "      <td>0</td>\n",
              "      <td>1</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>試験</th>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>3</td>\n",
              "      <td>0</td>\n",
              "      <td>29</td>\n",
              "      <td>4</td>\n",
              "      <td>0</td>\n",
              "      <td>2</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>内容</th>\n",
              "      <td>0</td>\n",
              "      <td>2</td>\n",
              "      <td>0</td>\n",
              "      <td>1</td>\n",
              "      <td>0</td>\n",
              "      <td>2</td>\n",
              "      <td>0</td>\n",
              "      <td>12</td>\n",
              "      <td>4</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>1</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>問題</th>\n",
              "      <td>1</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>4</td>\n",
              "      <td>0</td>\n",
              "      <td>12</td>\n",
              "      <td>2</td>\n",
              "      <td>0</td>\n",
              "      <td>1</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>説明</th>\n",
              "      <td>2</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>2</td>\n",
              "      <td>0</td>\n",
              "      <td>3</td>\n",
              "      <td>0</td>\n",
              "      <td>7</td>\n",
              "      <td>2</td>\n",
              "      <td>1</td>\n",
              "      <td>1</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>1</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>なし</th>\n",
              "      <td>3</td>\n",
              "      <td>4</td>\n",
              "      <td>4</td>\n",
              "      <td>4</td>\n",
              "      <td>3</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>資料</th>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>3</td>\n",
              "      <td>1</td>\n",
              "      <td>8</td>\n",
              "      <td>0</td>\n",
              "      <td>1</td>\n",
              "      <td>2</td>\n",
              "      <td>1</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>先生</th>\n",
              "      <td>0</td>\n",
              "      <td>3</td>\n",
              "      <td>0</td>\n",
              "      <td>1</td>\n",
              "      <td>0</td>\n",
              "      <td>1</td>\n",
              "      <td>0</td>\n",
              "      <td>6</td>\n",
              "      <td>2</td>\n",
              "      <td>0</td>\n",
              "      <td>1</td>\n",
              "      <td>0</td>\n",
              "      <td>1</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>お</th>\n",
              "      <td>1</td>\n",
              "      <td>2</td>\n",
              "      <td>0</td>\n",
              "      <td>2</td>\n",
              "      <td>1</td>\n",
              "      <td>0</td>\n",
              "      <td>3</td>\n",
              "      <td>4</td>\n",
              "      <td>1</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>難易度</th>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>1</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>8</td>\n",
              "      <td>2</td>\n",
              "      <td>0</td>\n",
              "      <td>1</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>解答</th>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>1</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>7</td>\n",
              "      <td>3</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>実際</th>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>1</td>\n",
              "      <td>0</td>\n",
              "      <td>1</td>\n",
              "      <td>3</td>\n",
              "      <td>1</td>\n",
              "      <td>0</td>\n",
              "      <td>3</td>\n",
              "      <td>2</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>方</th>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>1</td>\n",
              "      <td>0</td>\n",
              "      <td>1</td>\n",
              "      <td>0</td>\n",
              "      <td>2</td>\n",
              "      <td>0</td>\n",
              "      <td>2</td>\n",
              "      <td>0</td>\n",
              "      <td>2</td>\n",
              "      <td>2</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>テスト</th>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>1</td>\n",
              "      <td>1</td>\n",
              "      <td>6</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>2</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>知識</th>\n",
              "      <td>0</td>\n",
              "      <td>1</td>\n",
              "      <td>0</td>\n",
              "      <td>1</td>\n",
              "      <td>1</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>2</td>\n",
              "      <td>4</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>機会</th>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>3</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>1</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>5</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>生徒</th>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>1</td>\n",
              "      <td>0</td>\n",
              "      <td>8</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>中間</th>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>2</td>\n",
              "      <td>7</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>期末</th>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>6</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>3</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</td>\n",
              "      <td>0</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-6f93532e-7228-40bc-9cb1-89e945fd9e94')\"\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-6f93532e-7228-40bc-9cb1-89e945fd9e94 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-6f93532e-7228-40bc-9cb1-89e945fd9e94');\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-8551ccd8-eb6c-4bb4-994c-921f08f6dea3\">\n",
              "  <button class=\"colab-df-quickchart\" onclick=\"quickchart('df-8551ccd8-eb6c-4bb4-994c-921f08f6dea3')\"\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-8551ccd8-eb6c-4bb4-994c-921f08f6dea3 button');\n",
              "      quickchartButtonEl.style.display =\n",
              "        google.colab.kernel.accessAllowed ? 'block' : 'none';\n",
              "    })();\n",
              "  </script>\n",
              "</div>\n",
              "\n",
              "  <div id=\"id_be2a4762-40af-4a2d-afc9-7cc4b4a6f862\">\n",
              "    <style>\n",
              "      .colab-df-generate {\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-generate: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",
              "      [theme=dark] .colab-df-generate {\n",
              "        background-color: #3B4455;\n",
              "        fill: #D2E3FC;\n",
              "      }\n",
              "\n",
              "      [theme=dark] .colab-df-generate: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",
              "    <button class=\"colab-df-generate\" onclick=\"generateWithVariable('df_title_vs_word')\"\n",
              "            title=\"Generate code using this dataframe.\"\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",
              "    <path d=\"M7,19H8.4L18.45,9,17,7.55,7,17.6ZM5,21V16.75L18.45,3.32a2,2,0,0,1,2.83,0l1.4,1.43a1.91,1.91,0,0,1,.58,1.4,1.91,1.91,0,0,1-.58,1.4L9.25,21ZM18.45,9,17,7.55Zm-12,3A5.31,5.31,0,0,0,4.9,8.1,5.31,5.31,0,0,0,1,6.5,5.31,5.31,0,0,0,4.9,4.9,5.31,5.31,0,0,0,6.5,1,5.31,5.31,0,0,0,8.1,4.9,5.31,5.31,0,0,0,12,6.5,5.46,5.46,0,0,0,6.5,12Z\"/>\n",
              "  </svg>\n",
              "    </button>\n",
              "    <script>\n",
              "      (() => {\n",
              "      const buttonEl =\n",
              "        document.querySelector('#id_be2a4762-40af-4a2d-afc9-7cc4b4a6f862 button.colab-df-generate');\n",
              "      buttonEl.style.display =\n",
              "        google.colab.kernel.accessAllowed ? 'block' : 'none';\n",
              "\n",
              "      buttonEl.onclick = () => {\n",
              "        google.colab.notebook.generateWithVariable('df_title_vs_word');\n",
              "      }\n",
              "      })();\n",
              "    </script>\n",
              "  </div>\n",
              "\n",
              "    </div>\n",
              "  </div>\n"
            ],
            "application/vnd.google.colaboratory.intrinsic+json": {
              "type": "dataframe",
              "variable_name": "df_title_vs_word",
              "summary": "{\n  \"name\": \"df_title_vs_word\",\n  \"rows\": 20,\n  \"fields\": [\n    {\n      \"column\": \"\\u5de5\\u696d\\u6570\\u5b66\\u2160\",\n      \"properties\": {\n        \"dtype\": \"number\",\n        \"std\": 1,\n        \"min\": 0,\n        \"max\": 3,\n        \"num_unique_values\": 4,\n        \"samples\": [\n          2,\n          1,\n          3\n        ],\n        \"semantic_type\": \"\",\n        \"description\": \"\"\n      }\n    },\n    {\n      \"column\": \"\\u6280\\u8853\\u8005\\u306e\\u502b\\u7406\",\n      \"properties\": {\n        \"dtype\": \"number\",\n        \"std\": 1,\n        \"min\": 0,\n        \"max\": 4,\n        \"num_unique_values\": 5,\n        \"samples\": [\n          0,\n          1,\n          2\n        ],\n        \"semantic_type\": \"\",\n        \"description\": \"\"\n      }\n    },\n    {\n      \"column\": \"\\u5de5\\u5b66\\u57fa\\u790e\\u6f14\\u7fd2\",\n      \"properties\": {\n        \"dtype\": \"number\",\n        \"std\": 1,\n        \"min\": 0,\n        \"max\": 4,\n        \"num_unique_values\": 5,\n        \"samples\": [\n          0,\n          3,\n          4\n        ],\n        \"semantic_type\": \"\",\n        \"description\": \"\"\n      }\n    },\n    {\n      \"column\": \"\\u30d7\\u30ed\\u30b0\\u30e9\\u30df\\u30f3\\u30b0\\u2160\",\n      \"properties\": {\n        \"dtype\": \"number\",\n        \"std\": 1,\n        \"min\": 0,\n        \"max\": 6,\n        \"num_unique_values\": 5,\n        \"samples\": [\n          6,\n          4,\n          1\n        ],\n        \"semantic_type\": \"\",\n        \"description\": \"\"\n      }\n    },\n    {\n      \"column\": \"\\u30d7\\u30ed\\u30b0\\u30e9\\u30df\\u30f3\\u30b0\\u6f14\\u7fd2\\u2160\",\n      \"properties\": {\n        \"dtype\": \"number\",\n        \"std\": 0,\n        \"min\": 0,\n        \"max\": 3,\n        \"num_unique_values\": 3,\n        \"samples\": [\n          1,\n          3,\n          0\n        ],\n        \"semantic_type\": \"\",\n        \"description\": \"\"\n      }\n    },\n    {\n      \"column\": \"\\u30a2\\u30eb\\u30b4\\u30ea\\u30ba\\u30e0\\u3068\\u30c7\\u30fc\\u30bf\\u69cb\\u9020\",\n      \"properties\": {\n        \"dtype\": \"number\",\n        \"std\": 1,\n        \"min\": 0,\n        \"max\": 4,\n        \"num_unique_values\": 5,\n        \"samples\": [\n          0,\n          1,\n          3\n        ],\n        \"semantic_type\": \"\",\n        \"description\": \"\"\n      }\n    },\n    {\n      \"column\": \"\\u60c5\\u5831\\u30cd\\u30c3\\u30c8\\u30ef\\u30fc\\u30af\\u2160\",\n      \"properties\": {\n        \"dtype\": \"number\",\n        \"std\": 0,\n        \"min\": 0,\n        \"max\": 3,\n        \"num_unique_values\": 4,\n        \"samples\": [\n          0,\n          2,\n          1\n        ],\n        \"semantic_type\": \"\",\n        \"description\": \"\"\n      }\n    },\n    {\n      \"column\": \"\\u30b3\\u30f3\\u30d4\\u30e5\\u30fc\\u30bf\\u30b7\\u30b9\\u30c6\\u30e0\",\n      \"properties\": {\n        \"dtype\": \"number\",\n        \"std\": 7,\n        \"min\": 0,\n        \"max\": 29,\n        \"num_unique_values\": 11,\n        \"samples\": [\n          0,\n          19,\n          3\n        ],\n        \"semantic_type\": \"\",\n        \"description\": \"\"\n      }\n    },\n    {\n      \"column\": \"\\u30c7\\u30fc\\u30bf\\u30b5\\u30a4\\u30a8\\u30f3\\u30b9\\u57fa\\u790e\",\n      \"properties\": {\n        \"dtype\": \"number\",\n        \"std\": 1,\n        \"min\": 0,\n        \"max\": 4,\n        \"num_unique_values\": 5,\n        \"samples\": [\n          3,\n          1,\n          2\n        ],\n        \"semantic_type\": \"\",\n        \"description\": \"\"\n      }\n    },\n    {\n      \"column\": \"\\u30c7\\u30a3\\u30b8\\u30bf\\u30eb\\u56de\\u8def\",\n      \"properties\": {\n        \"dtype\": \"number\",\n        \"std\": 0,\n        \"min\": 0,\n        \"max\": 1,\n        \"num_unique_values\": 2,\n        \"samples\": [\n          0,\n          1\n        ],\n        \"semantic_type\": \"\",\n        \"description\": \"\"\n      }\n    },\n    {\n      \"column\": \"\\u60c5\\u5831\\u51e6\\u7406\\u6280\\u8853\\u6982\\u8ad6\",\n      \"properties\": {\n        \"dtype\": \"number\",\n        \"std\": 1,\n        \"min\": 0,\n        \"max\": 3,\n        \"num_unique_values\": 4,\n        \"samples\": [\n          0,\n          3\n        ],\n        \"semantic_type\": \"\",\n        \"description\": \"\"\n      }\n    },\n    {\n      \"column\": \"\\u30d7\\u30ed\\u30b8\\u30a7\\u30af\\u30c8\\u30c7\\u30b6\\u30a4\\u30f3\",\n      \"properties\": {\n        \"dtype\": \"number\",\n        \"std\": 1,\n        \"min\": 0,\n        \"max\": 5,\n        \"num_unique_values\": 4,\n        \"samples\": [\n          1,\n          2\n        ],\n        \"semantic_type\": \"\",\n        \"description\": \"\"\n      }\n    },\n    {\n      \"column\": \"\\u30ad\\u30e3\\u30ea\\u30a2\\u30c7\\u30b6\\u30a4\\u30f3\",\n      \"properties\": {\n        \"dtype\": \"number\",\n        \"std\": 0,\n        \"min\": 0,\n        \"max\": 1,\n        \"num_unique_values\": 2,\n        \"samples\": [\n          1,\n          0\n        ],\n        \"semantic_type\": \"\",\n        \"description\": \"\"\n      }\n    },\n    {\n      \"column\": \"\\u30c7\\u30fc\\u30bf\\u30de\\u30a4\\u30cb\\u30f3\\u30b0\",\n      \"properties\": {\n        \"dtype\": \"number\",\n        \"std\": 0,\n        \"min\": 0,\n        \"max\": 1,\n        \"num_unique_values\": 2,\n        \"samples\": [\n          1,\n          0\n        ],\n        \"semantic_type\": \"\",\n        \"description\": \"\"\n      }\n    },\n    {\n      \"column\": \"ICT\\u5b9f\\u8df5\\u82f1\\u8a9e\\u2160\",\n      \"properties\": {\n        \"dtype\": \"number\",\n        \"std\": 0,\n        \"min\": 0,\n        \"max\": 0,\n        \"num_unique_values\": 1,\n        \"samples\": [\n          0\n        ],\n        \"semantic_type\": \"\",\n        \"description\": \"\"\n      }\n    },\n    {\n      \"column\": \"\\u77e5\\u80fd\\u60c5\\u5831\\u5b9f\\u9a13\\u2162\",\n      \"properties\": {\n        \"dtype\": \"number\",\n        \"std\": 0,\n        \"min\": 0,\n        \"max\": 1,\n        \"num_unique_values\": 2,\n        \"samples\": [\n          0\n        ],\n        \"semantic_type\": \"\",\n        \"description\": \"\"\n      }\n    }\n  ]\n}"
            }
          },
          "metadata": {},
          "execution_count": 13
        }
      ],
      "source": [
        "# 授業別に top_n_words が出現した回数をカウント\n",
        "words = [k for k,v in top_n_words]\n",
        "zero_matrix = np.zeros((len(words), len(titles)), dtype=int)\n",
        "df_title_vs_word = pd.DataFrame(zero_matrix, columns=titles, index=words)\n",
        "\n",
        "# 授業別にコメントを前処理しておく\n",
        "title_comments = {}\n",
        "for title in titles:\n",
        "    comments = assesment_df[assesment_df['title'] == title]['comment']\n",
        "    tokens = []\n",
        "    comments = ' '.join(comments)\n",
        "    doc = nlp(comments)\n",
        "    for token in doc:\n",
        "        if token.pos_ == 'PROPN' or token.pos_ == 'NOUN':\n",
        "            if token.lemma_ in words:\n",
        "                df_title_vs_word.loc[token.lemma_, title] += 1\n",
        "\n",
        "df_title_vs_word"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "m30gRLbPNYOs"
      },
      "source": [
        "#### 積み上げ棒グラフ1"
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "import plotly.express as px\n",
        "\n",
        "# df_title_vs_word のインデックス・カラムから Plotly のスタック棒グラフを作成するため\n",
        "# melt して縦長形式に変換\n",
        "df_melted = df_title_vs_word.reset_index().melt(\n",
        "    id_vars='index',\n",
        "    var_name='授業一覧',\n",
        "    value_name='出現回数'\n",
        ")\n",
        "\n",
        "# Plotly Express で積み上げ棒グラフを作成（barmode='stack'）\n",
        "fig = px.bar(\n",
        "    df_melted,\n",
        "    x='授業一覧',\n",
        "    y='出現回数',\n",
        "    color='index',\n",
        "    title=f'授業別高頻度単語(top_n={top_n})の内訳（出現回数）',\n",
        "    barmode='stack'\n",
        ")\n",
        "\n",
        "# グラフのサイズやラベルなどのレイアウトを調整\n",
        "fig.update_layout(\n",
        "    xaxis_title='授業一覧',\n",
        "    yaxis_title='出現回数'\n",
        ")\n",
        "\n",
        "fig.show()\n"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 542
        },
        "id": "tc8In3p4xK5X",
        "outputId": "3200680a-db58-4dbf-9938-58c5c3664d5f"
      },
      "execution_count": 14,
      "outputs": [
        {
          "output_type": "display_data",
          "data": {
            "text/html": [
              "<html>\n",
              "<head><meta charset=\"utf-8\" /></head>\n",
              "<body>\n",
              "    <div>            <script src=\"https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_SVG\"></script><script type=\"text/javascript\">if (window.MathJax && window.MathJax.Hub && window.MathJax.Hub.Config) {window.MathJax.Hub.Config({SVG: {font: \"STIX-Web\"}});}</script>                <script type=\"text/javascript\">window.PlotlyConfig = {MathJaxConfig: 'local'};</script>\n",
              "        <script charset=\"utf-8\" src=\"https://cdn.plot.ly/plotly-2.35.2.min.js\"></script>                <div id=\"2869e2ab-38d9-4202-b204-67b8fe699409\" class=\"plotly-graph-div\" style=\"height:525px; width:100%;\"></div>            <script type=\"text/javascript\">                                    window.PLOTLYENV=window.PLOTLYENV || {};                                    if (document.getElementById(\"2869e2ab-38d9-4202-b204-67b8fe699409\")) {                    Plotly.newPlot(                        \"2869e2ab-38d9-4202-b204-67b8fe699409\",                        [{\"alignmentgroup\":\"True\",\"hovertemplate\":\"index=授業\\u003cbr\\u003e授業一覧=%{x}\\u003cbr\\u003e出現回数=%{y}\\u003cextra\\u003e\\u003c\\u002fextra\\u003e\",\"legendgroup\":\"授業\",\"marker\":{\"color\":\"#636efa\",\"pattern\":{\"shape\":\"\"}},\"name\":\"授業\",\"offsetgroup\":\"授業\",\"orientation\":\"v\",\"showlegend\":true,\"textposition\":\"auto\",\"x\":[\"工業数学Ⅰ\",\"技術者の倫理\",\"工学基礎演習\",\"プログラミングⅠ\",\"プログラミング演習Ⅰ\",\"アルゴリズムとデータ構造\",\"情報ネットワークⅠ\",\"コンピュータシステム\",\"データサイエンス基礎\",\"ディジタル回路\",\"情報処理技術概論\",\"プロジェクトデザイン\",\"キャリアデザイン\",\"データマイニング\",\"ICT実践英語Ⅰ\",\"知能情報実験Ⅲ\"],\"xaxis\":\"x\",\"y\":[3,3,2,0,1,2,1,19,4,1,2,5,0,0,0,1],\"yaxis\":\"y\",\"type\":\"bar\"},{\"alignmentgroup\":\"True\",\"hovertemplate\":\"index=課題\\u003cbr\\u003e授業一覧=%{x}\\u003cbr\\u003e出現回数=%{y}\\u003cextra\\u003e\\u003c\\u002fextra\\u003e\",\"legendgroup\":\"課題\",\"marker\":{\"color\":\"#EF553B\",\"pattern\":{\"shape\":\"\"}},\"name\":\"課題\",\"offsetgroup\":\"課題\",\"orientation\":\"v\",\"showlegend\":true,\"textposition\":\"auto\",\"x\":[\"工業数学Ⅰ\",\"技術者の倫理\",\"工学基礎演習\",\"プログラミングⅠ\",\"プログラミング演習Ⅰ\",\"アルゴリズムとデータ構造\",\"情報ネットワークⅠ\",\"コンピュータシステム\",\"データサイエンス基礎\",\"ディジタル回路\",\"情報処理技術概論\",\"プロジェクトデザイン\",\"キャリアデザイン\",\"データマイニング\",\"ICT実践英語Ⅰ\",\"知能情報実験Ⅲ\"],\"xaxis\":\"x\",\"y\":[2,0,0,6,3,0,0,23,3,0,0,1,0,1,0,0],\"yaxis\":\"y\",\"type\":\"bar\"},{\"alignmentgroup\":\"True\",\"hovertemplate\":\"index=試験\\u003cbr\\u003e授業一覧=%{x}\\u003cbr\\u003e出現回数=%{y}\\u003cextra\\u003e\\u003c\\u002fextra\\u003e\",\"legendgroup\":\"試験\",\"marker\":{\"color\":\"#00cc96\",\"pattern\":{\"shape\":\"\"}},\"name\":\"試験\",\"offsetgroup\":\"試験\",\"orientation\":\"v\",\"showlegend\":true,\"textposition\":\"auto\",\"x\":[\"工業数学Ⅰ\",\"技術者の倫理\",\"工学基礎演習\",\"プログラミングⅠ\",\"プログラミング演習Ⅰ\",\"アルゴリズムとデータ構造\",\"情報ネットワークⅠ\",\"コンピュータシステム\",\"データサイエンス基礎\",\"ディジタル回路\",\"情報処理技術概論\",\"プロジェクトデザイン\",\"キャリアデザイン\",\"データマイニング\",\"ICT実践英語Ⅰ\",\"知能情報実験Ⅲ\"],\"xaxis\":\"x\",\"y\":[0,0,0,0,0,3,0,29,4,0,2,0,0,0,0,0],\"yaxis\":\"y\",\"type\":\"bar\"},{\"alignmentgroup\":\"True\",\"hovertemplate\":\"index=内容\\u003cbr\\u003e授業一覧=%{x}\\u003cbr\\u003e出現回数=%{y}\\u003cextra\\u003e\\u003c\\u002fextra\\u003e\",\"legendgroup\":\"内容\",\"marker\":{\"color\":\"#ab63fa\",\"pattern\":{\"shape\":\"\"}},\"name\":\"内容\",\"offsetgroup\":\"内容\",\"orientation\":\"v\",\"showlegend\":true,\"textposition\":\"auto\",\"x\":[\"工業数学Ⅰ\",\"技術者の倫理\",\"工学基礎演習\",\"プログラミングⅠ\",\"プログラミング演習Ⅰ\",\"アルゴリズムとデータ構造\",\"情報ネットワークⅠ\",\"コンピュータシステム\",\"データサイエンス基礎\",\"ディジタル回路\",\"情報処理技術概論\",\"プロジェクトデザイン\",\"キャリアデザイン\",\"データマイニング\",\"ICT実践英語Ⅰ\",\"知能情報実験Ⅲ\"],\"xaxis\":\"x\",\"y\":[0,2,0,1,0,2,0,12,4,0,0,1,0,0,0,0],\"yaxis\":\"y\",\"type\":\"bar\"},{\"alignmentgroup\":\"True\",\"hovertemplate\":\"index=問題\\u003cbr\\u003e授業一覧=%{x}\\u003cbr\\u003e出現回数=%{y}\\u003cextra\\u003e\\u003c\\u002fextra\\u003e\",\"legendgroup\":\"問題\",\"marker\":{\"color\":\"#FFA15A\",\"pattern\":{\"shape\":\"\"}},\"name\":\"問題\",\"offsetgroup\":\"問題\",\"orientation\":\"v\",\"showlegend\":true,\"textposition\":\"auto\",\"x\":[\"工業数学Ⅰ\",\"技術者の倫理\",\"工学基礎演習\",\"プログラミングⅠ\",\"プログラミング演習Ⅰ\",\"アルゴリズムとデータ構造\",\"情報ネットワークⅠ\",\"コンピュータシステム\",\"データサイエンス基礎\",\"ディジタル回路\",\"情報処理技術概論\",\"プロジェクトデザイン\",\"キャリアデザイン\",\"データマイニング\",\"ICT実践英語Ⅰ\",\"知能情報実験Ⅲ\"],\"xaxis\":\"x\",\"y\":[1,0,0,0,0,4,0,12,2,0,1,0,0,0,0,0],\"yaxis\":\"y\",\"type\":\"bar\"},{\"alignmentgroup\":\"True\",\"hovertemplate\":\"index=説明\\u003cbr\\u003e授業一覧=%{x}\\u003cbr\\u003e出現回数=%{y}\\u003cextra\\u003e\\u003c\\u002fextra\\u003e\",\"legendgroup\":\"説明\",\"marker\":{\"color\":\"#19d3f3\",\"pattern\":{\"shape\":\"\"}},\"name\":\"説明\",\"offsetgroup\":\"説明\",\"orientation\":\"v\",\"showlegend\":true,\"textposition\":\"auto\",\"x\":[\"工業数学Ⅰ\",\"技術者の倫理\",\"工学基礎演習\",\"プログラミングⅠ\",\"プログラミング演習Ⅰ\",\"アルゴリズムとデータ構造\",\"情報ネットワークⅠ\",\"コンピュータシステム\",\"データサイエンス基礎\",\"ディジタル回路\",\"情報処理技術概論\",\"プロジェクトデザイン\",\"キャリアデザイン\",\"データマイニング\",\"ICT実践英語Ⅰ\",\"知能情報実験Ⅲ\"],\"xaxis\":\"x\",\"y\":[2,0,0,2,0,3,0,7,2,1,1,0,0,0,0,1],\"yaxis\":\"y\",\"type\":\"bar\"},{\"alignmentgroup\":\"True\",\"hovertemplate\":\"index=なし\\u003cbr\\u003e授業一覧=%{x}\\u003cbr\\u003e出現回数=%{y}\\u003cextra\\u003e\\u003c\\u002fextra\\u003e\",\"legendgroup\":\"なし\",\"marker\":{\"color\":\"#FF6692\",\"pattern\":{\"shape\":\"\"}},\"name\":\"なし\",\"offsetgroup\":\"なし\",\"orientation\":\"v\",\"showlegend\":true,\"textposition\":\"auto\",\"x\":[\"工業数学Ⅰ\",\"技術者の倫理\",\"工学基礎演習\",\"プログラミングⅠ\",\"プログラミング演習Ⅰ\",\"アルゴリズムとデータ構造\",\"情報ネットワークⅠ\",\"コンピュータシステム\",\"データサイエンス基礎\",\"ディジタル回路\",\"情報処理技術概論\",\"プロジェクトデザイン\",\"キャリアデザイン\",\"データマイニング\",\"ICT実践英語Ⅰ\",\"知能情報実験Ⅲ\"],\"xaxis\":\"x\",\"y\":[3,4,4,4,3,0,0,0,0,0,0,0,0,0,0,0],\"yaxis\":\"y\",\"type\":\"bar\"},{\"alignmentgroup\":\"True\",\"hovertemplate\":\"index=資料\\u003cbr\\u003e授業一覧=%{x}\\u003cbr\\u003e出現回数=%{y}\\u003cextra\\u003e\\u003c\\u002fextra\\u003e\",\"legendgroup\":\"資料\",\"marker\":{\"color\":\"#B6E880\",\"pattern\":{\"shape\":\"\"}},\"name\":\"資料\",\"offsetgroup\":\"資料\",\"orientation\":\"v\",\"showlegend\":true,\"textposition\":\"auto\",\"x\":[\"工業数学Ⅰ\",\"技術者の倫理\",\"工学基礎演習\",\"プログラミングⅠ\",\"プログラミング演習Ⅰ\",\"アルゴリズムとデータ構造\",\"情報ネットワークⅠ\",\"コンピュータシステム\",\"データサイエンス基礎\",\"ディジタル回路\",\"情報処理技術概論\",\"プロジェクトデザイン\",\"キャリアデザイン\",\"データマイニング\",\"ICT実践英語Ⅰ\",\"知能情報実験Ⅲ\"],\"xaxis\":\"x\",\"y\":[0,0,0,0,0,3,1,8,0,1,2,1,0,0,0,0],\"yaxis\":\"y\",\"type\":\"bar\"},{\"alignmentgroup\":\"True\",\"hovertemplate\":\"index=先生\\u003cbr\\u003e授業一覧=%{x}\\u003cbr\\u003e出現回数=%{y}\\u003cextra\\u003e\\u003c\\u002fextra\\u003e\",\"legendgroup\":\"先生\",\"marker\":{\"color\":\"#FF97FF\",\"pattern\":{\"shape\":\"\"}},\"name\":\"先生\",\"offsetgroup\":\"先生\",\"orientation\":\"v\",\"showlegend\":true,\"textposition\":\"auto\",\"x\":[\"工業数学Ⅰ\",\"技術者の倫理\",\"工学基礎演習\",\"プログラミングⅠ\",\"プログラミング演習Ⅰ\",\"アルゴリズムとデータ構造\",\"情報ネットワークⅠ\",\"コンピュータシステム\",\"データサイエンス基礎\",\"ディジタル回路\",\"情報処理技術概論\",\"プロジェクトデザイン\",\"キャリアデザイン\",\"データマイニング\",\"ICT実践英語Ⅰ\",\"知能情報実験Ⅲ\"],\"xaxis\":\"x\",\"y\":[0,3,0,1,0,1,0,6,2,0,1,0,1,0,0,0],\"yaxis\":\"y\",\"type\":\"bar\"},{\"alignmentgroup\":\"True\",\"hovertemplate\":\"index=お\\u003cbr\\u003e授業一覧=%{x}\\u003cbr\\u003e出現回数=%{y}\\u003cextra\\u003e\\u003c\\u002fextra\\u003e\",\"legendgroup\":\"お\",\"marker\":{\"color\":\"#FECB52\",\"pattern\":{\"shape\":\"\"}},\"name\":\"お\",\"offsetgroup\":\"お\",\"orientation\":\"v\",\"showlegend\":true,\"textposition\":\"auto\",\"x\":[\"工業数学Ⅰ\",\"技術者の倫理\",\"工学基礎演習\",\"プログラミングⅠ\",\"プログラミング演習Ⅰ\",\"アルゴリズムとデータ構造\",\"情報ネットワークⅠ\",\"コンピュータシステム\",\"データサイエンス基礎\",\"ディジタル回路\",\"情報処理技術概論\",\"プロジェクトデザイン\",\"キャリアデザイン\",\"データマイニング\",\"ICT実践英語Ⅰ\",\"知能情報実験Ⅲ\"],\"xaxis\":\"x\",\"y\":[1,2,0,2,1,0,3,4,1,0,0,0,0,0,0,0],\"yaxis\":\"y\",\"type\":\"bar\"},{\"alignmentgroup\":\"True\",\"hovertemplate\":\"index=難易度\\u003cbr\\u003e授業一覧=%{x}\\u003cbr\\u003e出現回数=%{y}\\u003cextra\\u003e\\u003c\\u002fextra\\u003e\",\"legendgroup\":\"難易度\",\"marker\":{\"color\":\"#636efa\",\"pattern\":{\"shape\":\"\"}},\"name\":\"難易度\",\"offsetgroup\":\"難易度\",\"orientation\":\"v\",\"showlegend\":true,\"textposition\":\"auto\",\"x\":[\"工業数学Ⅰ\",\"技術者の倫理\",\"工学基礎演習\",\"プログラミングⅠ\",\"プログラミング演習Ⅰ\",\"アルゴリズムとデータ構造\",\"情報ネットワークⅠ\",\"コンピュータシステム\",\"データサイエンス基礎\",\"ディジタル回路\",\"情報処理技術概論\",\"プロジェクトデザイン\",\"キャリアデザイン\",\"データマイニング\",\"ICT実践英語Ⅰ\",\"知能情報実験Ⅲ\"],\"xaxis\":\"x\",\"y\":[0,0,0,1,0,0,0,8,2,0,1,0,0,0,0,0],\"yaxis\":\"y\",\"type\":\"bar\"},{\"alignmentgroup\":\"True\",\"hovertemplate\":\"index=解答\\u003cbr\\u003e授業一覧=%{x}\\u003cbr\\u003e出現回数=%{y}\\u003cextra\\u003e\\u003c\\u002fextra\\u003e\",\"legendgroup\":\"解答\",\"marker\":{\"color\":\"#EF553B\",\"pattern\":{\"shape\":\"\"}},\"name\":\"解答\",\"offsetgroup\":\"解答\",\"orientation\":\"v\",\"showlegend\":true,\"textposition\":\"auto\",\"x\":[\"工業数学Ⅰ\",\"技術者の倫理\",\"工学基礎演習\",\"プログラミングⅠ\",\"プログラミング演習Ⅰ\",\"アルゴリズムとデータ構造\",\"情報ネットワークⅠ\",\"コンピュータシステム\",\"データサイエンス基礎\",\"ディジタル回路\",\"情報処理技術概論\",\"プロジェクトデザイン\",\"キャリアデザイン\",\"データマイニング\",\"ICT実践英語Ⅰ\",\"知能情報実験Ⅲ\"],\"xaxis\":\"x\",\"y\":[0,0,0,0,1,0,0,7,3,0,0,0,0,0,0,0],\"yaxis\":\"y\",\"type\":\"bar\"},{\"alignmentgroup\":\"True\",\"hovertemplate\":\"index=実際\\u003cbr\\u003e授業一覧=%{x}\\u003cbr\\u003e出現回数=%{y}\\u003cextra\\u003e\\u003c\\u002fextra\\u003e\",\"legendgroup\":\"実際\",\"marker\":{\"color\":\"#00cc96\",\"pattern\":{\"shape\":\"\"}},\"name\":\"実際\",\"offsetgroup\":\"実際\",\"orientation\":\"v\",\"showlegend\":true,\"textposition\":\"auto\",\"x\":[\"工業数学Ⅰ\",\"技術者の倫理\",\"工学基礎演習\",\"プログラミングⅠ\",\"プログラミング演習Ⅰ\",\"アルゴリズムとデータ構造\",\"情報ネットワークⅠ\",\"コンピュータシステム\",\"データサイエンス基礎\",\"ディジタル回路\",\"情報処理技術概論\",\"プロジェクトデザイン\",\"キャリアデザイン\",\"データマイニング\",\"ICT実践英語Ⅰ\",\"知能情報実験Ⅲ\"],\"xaxis\":\"x\",\"y\":[0,0,0,0,1,0,1,3,1,0,3,2,0,0,0,0],\"yaxis\":\"y\",\"type\":\"bar\"},{\"alignmentgroup\":\"True\",\"hovertemplate\":\"index=方\\u003cbr\\u003e授業一覧=%{x}\\u003cbr\\u003e出現回数=%{y}\\u003cextra\\u003e\\u003c\\u002fextra\\u003e\",\"legendgroup\":\"方\",\"marker\":{\"color\":\"#ab63fa\",\"pattern\":{\"shape\":\"\"}},\"name\":\"方\",\"offsetgroup\":\"方\",\"orientation\":\"v\",\"showlegend\":true,\"textposition\":\"auto\",\"x\":[\"工業数学Ⅰ\",\"技術者の倫理\",\"工学基礎演習\",\"プログラミングⅠ\",\"プログラミング演習Ⅰ\",\"アルゴリズムとデータ構造\",\"情報ネットワークⅠ\",\"コンピュータシステム\",\"データサイエンス基礎\",\"ディジタル回路\",\"情報処理技術概論\",\"プロジェクトデザイン\",\"キャリアデザイン\",\"データマイニング\",\"ICT実践英語Ⅰ\",\"知能情報実験Ⅲ\"],\"xaxis\":\"x\",\"y\":[0,0,1,0,1,0,2,0,2,0,2,2,0,0,0,0],\"yaxis\":\"y\",\"type\":\"bar\"},{\"alignmentgroup\":\"True\",\"hovertemplate\":\"index=テスト\\u003cbr\\u003e授業一覧=%{x}\\u003cbr\\u003e出現回数=%{y}\\u003cextra\\u003e\\u003c\\u002fextra\\u003e\",\"legendgroup\":\"テスト\",\"marker\":{\"color\":\"#FFA15A\",\"pattern\":{\"shape\":\"\"}},\"name\":\"テスト\",\"offsetgroup\":\"テスト\",\"orientation\":\"v\",\"showlegend\":true,\"textposition\":\"auto\",\"x\":[\"工業数学Ⅰ\",\"技術者の倫理\",\"工学基礎演習\",\"プログラミングⅠ\",\"プログラミング演習Ⅰ\",\"アルゴリズムとデータ構造\",\"情報ネットワークⅠ\",\"コンピュータシステム\",\"データサイエンス基礎\",\"ディジタル回路\",\"情報処理技術概論\",\"プロジェクトデザイン\",\"キャリアデザイン\",\"データマイニング\",\"ICT実践英語Ⅰ\",\"知能情報実験Ⅲ\"],\"xaxis\":\"x\",\"y\":[0,0,0,0,0,1,1,6,0,0,2,0,0,0,0,0],\"yaxis\":\"y\",\"type\":\"bar\"},{\"alignmentgroup\":\"True\",\"hovertemplate\":\"index=知識\\u003cbr\\u003e授業一覧=%{x}\\u003cbr\\u003e出現回数=%{y}\\u003cextra\\u003e\\u003c\\u002fextra\\u003e\",\"legendgroup\":\"知識\",\"marker\":{\"color\":\"#19d3f3\",\"pattern\":{\"shape\":\"\"}},\"name\":\"知識\",\"offsetgroup\":\"知識\",\"orientation\":\"v\",\"showlegend\":true,\"textposition\":\"auto\",\"x\":[\"工業数学Ⅰ\",\"技術者の倫理\",\"工学基礎演習\",\"プログラミングⅠ\",\"プログラミング演習Ⅰ\",\"アルゴリズムとデータ構造\",\"情報ネットワークⅠ\",\"コンピュータシステム\",\"データサイエンス基礎\",\"ディジタル回路\",\"情報処理技術概論\",\"プロジェクトデザイン\",\"キャリアデザイン\",\"データマイニング\",\"ICT実践英語Ⅰ\",\"知能情報実験Ⅲ\"],\"xaxis\":\"x\",\"y\":[0,1,0,1,1,0,0,2,4,0,0,0,0,0,0,0],\"yaxis\":\"y\",\"type\":\"bar\"},{\"alignmentgroup\":\"True\",\"hovertemplate\":\"index=機会\\u003cbr\\u003e授業一覧=%{x}\\u003cbr\\u003e出現回数=%{y}\\u003cextra\\u003e\\u003c\\u002fextra\\u003e\",\"legendgroup\":\"機会\",\"marker\":{\"color\":\"#FF6692\",\"pattern\":{\"shape\":\"\"}},\"name\":\"機会\",\"offsetgroup\":\"機会\",\"orientation\":\"v\",\"showlegend\":true,\"textposition\":\"auto\",\"x\":[\"工業数学Ⅰ\",\"技術者の倫理\",\"工学基礎演習\",\"プログラミングⅠ\",\"プログラミング演習Ⅰ\",\"アルゴリズムとデータ構造\",\"情報ネットワークⅠ\",\"コンピュータシステム\",\"データサイエンス基礎\",\"ディジタル回路\",\"情報処理技術概論\",\"プロジェクトデザイン\",\"キャリアデザイン\",\"データマイニング\",\"ICT実践英語Ⅰ\",\"知能情報実験Ⅲ\"],\"xaxis\":\"x\",\"y\":[0,0,3,0,0,0,1,0,0,0,0,5,0,0,0,0],\"yaxis\":\"y\",\"type\":\"bar\"},{\"alignmentgroup\":\"True\",\"hovertemplate\":\"index=生徒\\u003cbr\\u003e授業一覧=%{x}\\u003cbr\\u003e出現回数=%{y}\\u003cextra\\u003e\\u003c\\u002fextra\\u003e\",\"legendgroup\":\"生徒\",\"marker\":{\"color\":\"#B6E880\",\"pattern\":{\"shape\":\"\"}},\"name\":\"生徒\",\"offsetgroup\":\"生徒\",\"orientation\":\"v\",\"showlegend\":true,\"textposition\":\"auto\",\"x\":[\"工業数学Ⅰ\",\"技術者の倫理\",\"工学基礎演習\",\"プログラミングⅠ\",\"プログラミング演習Ⅰ\",\"アルゴリズムとデータ構造\",\"情報ネットワークⅠ\",\"コンピュータシステム\",\"データサイエンス基礎\",\"ディジタル回路\",\"情報処理技術概論\",\"プロジェクトデザイン\",\"キャリアデザイン\",\"データマイニング\",\"ICT実践英語Ⅰ\",\"知能情報実験Ⅲ\"],\"xaxis\":\"x\",\"y\":[0,0,0,0,0,1,0,8,0,0,0,0,0,0,0,0],\"yaxis\":\"y\",\"type\":\"bar\"},{\"alignmentgroup\":\"True\",\"hovertemplate\":\"index=中間\\u003cbr\\u003e授業一覧=%{x}\\u003cbr\\u003e出現回数=%{y}\\u003cextra\\u003e\\u003c\\u002fextra\\u003e\",\"legendgroup\":\"中間\",\"marker\":{\"color\":\"#FF97FF\",\"pattern\":{\"shape\":\"\"}},\"name\":\"中間\",\"offsetgroup\":\"中間\",\"orientation\":\"v\",\"showlegend\":true,\"textposition\":\"auto\",\"x\":[\"工業数学Ⅰ\",\"技術者の倫理\",\"工学基礎演習\",\"プログラミングⅠ\",\"プログラミング演習Ⅰ\",\"アルゴリズムとデータ構造\",\"情報ネットワークⅠ\",\"コンピュータシステム\",\"データサイエンス基礎\",\"ディジタル回路\",\"情報処理技術概論\",\"プロジェクトデザイン\",\"キャリアデザイン\",\"データマイニング\",\"ICT実践英語Ⅰ\",\"知能情報実験Ⅲ\"],\"xaxis\":\"x\",\"y\":[0,0,0,0,0,0,2,7,0,0,0,0,0,0,0,0],\"yaxis\":\"y\",\"type\":\"bar\"},{\"alignmentgroup\":\"True\",\"hovertemplate\":\"index=期末\\u003cbr\\u003e授業一覧=%{x}\\u003cbr\\u003e出現回数=%{y}\\u003cextra\\u003e\\u003c\\u002fextra\\u003e\",\"legendgroup\":\"期末\",\"marker\":{\"color\":\"#FECB52\",\"pattern\":{\"shape\":\"\"}},\"name\":\"期末\",\"offsetgroup\":\"期末\",\"orientation\":\"v\",\"showlegend\":true,\"textposition\":\"auto\",\"x\":[\"工業数学Ⅰ\",\"技術者の倫理\",\"工学基礎演習\",\"プログラミングⅠ\",\"プログラミング演習Ⅰ\",\"アルゴリズムとデータ構造\",\"情報ネットワークⅠ\",\"コンピュータシステム\",\"データサイエンス基礎\",\"ディジタル回路\",\"情報処理技術概論\",\"プロジェクトデザイン\",\"キャリアデザイン\",\"データマイニング\",\"ICT実践英語Ⅰ\",\"知能情報実験Ⅲ\"],\"xaxis\":\"x\",\"y\":[0,0,0,0,0,0,0,6,0,0,3,0,0,0,0,0],\"yaxis\":\"y\",\"type\":\"bar\"}],                        {\"template\":{\"data\":{\"histogram2dcontour\":[{\"type\":\"histogram2dcontour\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"},\"colorscale\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]]}],\"choropleth\":[{\"type\":\"choropleth\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}],\"histogram2d\":[{\"type\":\"histogram2d\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"},\"colorscale\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]]}],\"heatmap\":[{\"type\":\"heatmap\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"},\"colorscale\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]]}],\"heatmapgl\":[{\"type\":\"heatmapgl\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"},\"colorscale\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]]}],\"contourcarpet\":[{\"type\":\"contourcarpet\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}],\"contour\":[{\"type\":\"contour\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"},\"colorscale\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]]}],\"surface\":[{\"type\":\"surface\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"},\"colorscale\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]]}],\"mesh3d\":[{\"type\":\"mesh3d\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}],\"scatter\":[{\"fillpattern\":{\"fillmode\":\"overlay\",\"size\":10,\"solidity\":0.2},\"type\":\"scatter\"}],\"parcoords\":[{\"type\":\"parcoords\",\"line\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"scatterpolargl\":[{\"type\":\"scatterpolargl\",\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"bar\":[{\"error_x\":{\"color\":\"#2a3f5f\"},\"error_y\":{\"color\":\"#2a3f5f\"},\"marker\":{\"line\":{\"color\":\"#E5ECF6\",\"width\":0.5},\"pattern\":{\"fillmode\":\"overlay\",\"size\":10,\"solidity\":0.2}},\"type\":\"bar\"}],\"scattergeo\":[{\"type\":\"scattergeo\",\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"scatterpolar\":[{\"type\":\"scatterpolar\",\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"histogram\":[{\"marker\":{\"pattern\":{\"fillmode\":\"overlay\",\"size\":10,\"solidity\":0.2}},\"type\":\"histogram\"}],\"scattergl\":[{\"type\":\"scattergl\",\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"scatter3d\":[{\"type\":\"scatter3d\",\"line\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}},\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"scattermapbox\":[{\"type\":\"scattermapbox\",\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"scatterternary\":[{\"type\":\"scatterternary\",\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"scattercarpet\":[{\"type\":\"scattercarpet\",\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"carpet\":[{\"aaxis\":{\"endlinecolor\":\"#2a3f5f\",\"gridcolor\":\"white\",\"linecolor\":\"white\",\"minorgridcolor\":\"white\",\"startlinecolor\":\"#2a3f5f\"},\"baxis\":{\"endlinecolor\":\"#2a3f5f\",\"gridcolor\":\"white\",\"linecolor\":\"white\",\"minorgridcolor\":\"white\",\"startlinecolor\":\"#2a3f5f\"},\"type\":\"carpet\"}],\"table\":[{\"cells\":{\"fill\":{\"color\":\"#EBF0F8\"},\"line\":{\"color\":\"white\"}},\"header\":{\"fill\":{\"color\":\"#C8D4E3\"},\"line\":{\"color\":\"white\"}},\"type\":\"table\"}],\"barpolar\":[{\"marker\":{\"line\":{\"color\":\"#E5ECF6\",\"width\":0.5},\"pattern\":{\"fillmode\":\"overlay\",\"size\":10,\"solidity\":0.2}},\"type\":\"barpolar\"}],\"pie\":[{\"automargin\":true,\"type\":\"pie\"}]},\"layout\":{\"autotypenumbers\":\"strict\",\"colorway\":[\"#636efa\",\"#EF553B\",\"#00cc96\",\"#ab63fa\",\"#FFA15A\",\"#19d3f3\",\"#FF6692\",\"#B6E880\",\"#FF97FF\",\"#FECB52\"],\"font\":{\"color\":\"#2a3f5f\"},\"hovermode\":\"closest\",\"hoverlabel\":{\"align\":\"left\"},\"paper_bgcolor\":\"white\",\"plot_bgcolor\":\"#E5ECF6\",\"polar\":{\"bgcolor\":\"#E5ECF6\",\"angularaxis\":{\"gridcolor\":\"white\",\"linecolor\":\"white\",\"ticks\":\"\"},\"radialaxis\":{\"gridcolor\":\"white\",\"linecolor\":\"white\",\"ticks\":\"\"}},\"ternary\":{\"bgcolor\":\"#E5ECF6\",\"aaxis\":{\"gridcolor\":\"white\",\"linecolor\":\"white\",\"ticks\":\"\"},\"baxis\":{\"gridcolor\":\"white\",\"linecolor\":\"white\",\"ticks\":\"\"},\"caxis\":{\"gridcolor\":\"white\",\"linecolor\":\"white\",\"ticks\":\"\"}},\"coloraxis\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}},\"colorscale\":{\"sequential\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]],\"sequentialminus\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]],\"diverging\":[[0,\"#8e0152\"],[0.1,\"#c51b7d\"],[0.2,\"#de77ae\"],[0.3,\"#f1b6da\"],[0.4,\"#fde0ef\"],[0.5,\"#f7f7f7\"],[0.6,\"#e6f5d0\"],[0.7,\"#b8e186\"],[0.8,\"#7fbc41\"],[0.9,\"#4d9221\"],[1,\"#276419\"]]},\"xaxis\":{\"gridcolor\":\"white\",\"linecolor\":\"white\",\"ticks\":\"\",\"title\":{\"standoff\":15},\"zerolinecolor\":\"white\",\"automargin\":true,\"zerolinewidth\":2},\"yaxis\":{\"gridcolor\":\"white\",\"linecolor\":\"white\",\"ticks\":\"\",\"title\":{\"standoff\":15},\"zerolinecolor\":\"white\",\"automargin\":true,\"zerolinewidth\":2},\"scene\":{\"xaxis\":{\"backgroundcolor\":\"#E5ECF6\",\"gridcolor\":\"white\",\"linecolor\":\"white\",\"showbackground\":true,\"ticks\":\"\",\"zerolinecolor\":\"white\",\"gridwidth\":2},\"yaxis\":{\"backgroundcolor\":\"#E5ECF6\",\"gridcolor\":\"white\",\"linecolor\":\"white\",\"showbackground\":true,\"ticks\":\"\",\"zerolinecolor\":\"white\",\"gridwidth\":2},\"zaxis\":{\"backgroundcolor\":\"#E5ECF6\",\"gridcolor\":\"white\",\"linecolor\":\"white\",\"showbackground\":true,\"ticks\":\"\",\"zerolinecolor\":\"white\",\"gridwidth\":2}},\"shapedefaults\":{\"line\":{\"color\":\"#2a3f5f\"}},\"annotationdefaults\":{\"arrowcolor\":\"#2a3f5f\",\"arrowhead\":0,\"arrowwidth\":1},\"geo\":{\"bgcolor\":\"white\",\"landcolor\":\"#E5ECF6\",\"subunitcolor\":\"white\",\"showland\":true,\"showlakes\":true,\"lakecolor\":\"white\"},\"title\":{\"x\":0.05},\"mapbox\":{\"style\":\"light\"}}},\"xaxis\":{\"anchor\":\"y\",\"domain\":[0.0,1.0],\"title\":{\"text\":\"授業一覧\"}},\"yaxis\":{\"anchor\":\"x\",\"domain\":[0.0,1.0],\"title\":{\"text\":\"出現回数\"}},\"legend\":{\"title\":{\"text\":\"index\"},\"tracegroupgap\":0},\"title\":{\"text\":\"授業別高頻度単語(top_n=20)の内訳（出現回数）\"},\"barmode\":\"stack\"},                        {\"responsive\": true}                    ).then(function(){\n",
              "                            \n",
              "var gd = document.getElementById('2869e2ab-38d9-4202-b204-67b8fe699409');\n",
              "var x = new MutationObserver(function (mutations, observer) {{\n",
              "        var display = window.getComputedStyle(gd).display;\n",
              "        if (!display || display === 'none') {{\n",
              "            console.log([gd, 'removed!']);\n",
              "            Plotly.purge(gd);\n",
              "            observer.disconnect();\n",
              "        }}\n",
              "}});\n",
              "\n",
              "// Listen for the removal of the full notebook cells\n",
              "var notebookContainer = gd.closest('#notebook-container');\n",
              "if (notebookContainer) {{\n",
              "    x.observe(notebookContainer, {childList: true});\n",
              "}}\n",
              "\n",
              "// Listen for the clearing of the current output cell\n",
              "var outputEl = gd.closest('.output');\n",
              "if (outputEl) {{\n",
              "    x.observe(outputEl, {childList: true});\n",
              "}}\n",
              "\n",
              "                        })                };                            </script>        </div>\n",
              "</body>\n",
              "</html>"
            ]
          },
          "metadata": {}
        }
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "JLlU3NFENYOs"
      },
      "source": [
        "#### 積み上げ棒グラフ2（横）\n",
        "縦に積み上げる形式だと確認しづらいので、横方向に積み上げよう。"
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "import plotly.express as px\n",
        "\n",
        "# df_title_vs_word の「列名」をカテゴリとして横軸に値を積み上げるために「縦長形式」に変換\n",
        "df_melted = df_title_vs_word.copy().T.reset_index()\n",
        "# ここで 'index' 列は元の df_title_vs_word.columns に相当\n",
        "# 積み上げの色分けには「元の行名」を利用するため、melt で展開する\n",
        "df_melted = df_melted.melt(\n",
        "    id_vars='index',    # 変換後の 'index' 列はカテゴリ（y 軸）になる\n",
        "    var_name='row_idx', # もとの df_title_vs_word.index（積み上げ単位）\n",
        "    value_name='value'  # 実際にバーの幅になる数値\n",
        ")\n",
        "\n",
        "# Plotly Express の bar で「横向き」の積み上げ棒グラフを描画（orientation='h', barmode='stack'）\n",
        "fig = px.bar(\n",
        "    df_melted,\n",
        "    x='value',      # バーの長さ（積み上げの合計）\n",
        "    y='index',      # カテゴリ（元の df_title_vs_word.columns）\n",
        "    color='row_idx',# 積み上げごとに色分け（元の df_title_vs_word.index）\n",
        "    orientation='h',\n",
        "    barmode='stack',\n",
        "    title=f'授業別高頻度単語(top_n={top_n})の内訳（出現回数）'\n",
        ")\n",
        "\n",
        "# 軸タイトル設定\n",
        "fig.update_layout(\n",
        "    xaxis_title='出現回数',\n",
        "    yaxis_title='授業一覧'\n",
        ")\n",
        "\n",
        "fig.show()\n"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 542
        },
        "id": "l8daEDMLxqeJ",
        "outputId": "aaa74f3d-d0cc-4a49-9029-90ac8c8738ff"
      },
      "execution_count": 15,
      "outputs": [
        {
          "output_type": "display_data",
          "data": {
            "text/html": [
              "<html>\n",
              "<head><meta charset=\"utf-8\" /></head>\n",
              "<body>\n",
              "    <div>            <script src=\"https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_SVG\"></script><script type=\"text/javascript\">if (window.MathJax && window.MathJax.Hub && window.MathJax.Hub.Config) {window.MathJax.Hub.Config({SVG: {font: \"STIX-Web\"}});}</script>                <script type=\"text/javascript\">window.PlotlyConfig = {MathJaxConfig: 'local'};</script>\n",
              "        <script charset=\"utf-8\" src=\"https://cdn.plot.ly/plotly-2.35.2.min.js\"></script>                <div id=\"1864ef33-db2b-4550-91d7-6f275e00ca70\" class=\"plotly-graph-div\" style=\"height:525px; width:100%;\"></div>            <script type=\"text/javascript\">                                    window.PLOTLYENV=window.PLOTLYENV || {};                                    if (document.getElementById(\"1864ef33-db2b-4550-91d7-6f275e00ca70\")) {                    Plotly.newPlot(                        \"1864ef33-db2b-4550-91d7-6f275e00ca70\",                        [{\"alignmentgroup\":\"True\",\"hovertemplate\":\"row_idx=授業\\u003cbr\\u003evalue=%{x}\\u003cbr\\u003eindex=%{y}\\u003cextra\\u003e\\u003c\\u002fextra\\u003e\",\"legendgroup\":\"授業\",\"marker\":{\"color\":\"#636efa\",\"pattern\":{\"shape\":\"\"}},\"name\":\"授業\",\"offsetgroup\":\"授業\",\"orientation\":\"h\",\"showlegend\":true,\"textposition\":\"auto\",\"x\":[3,3,2,0,1,2,1,19,4,1,2,5,0,0,0,1],\"xaxis\":\"x\",\"y\":[\"工業数学Ⅰ\",\"技術者の倫理\",\"工学基礎演習\",\"プログラミングⅠ\",\"プログラミング演習Ⅰ\",\"アルゴリズムとデータ構造\",\"情報ネットワークⅠ\",\"コンピュータシステム\",\"データサイエンス基礎\",\"ディジタル回路\",\"情報処理技術概論\",\"プロジェクトデザイン\",\"キャリアデザイン\",\"データマイニング\",\"ICT実践英語Ⅰ\",\"知能情報実験Ⅲ\"],\"yaxis\":\"y\",\"type\":\"bar\"},{\"alignmentgroup\":\"True\",\"hovertemplate\":\"row_idx=課題\\u003cbr\\u003evalue=%{x}\\u003cbr\\u003eindex=%{y}\\u003cextra\\u003e\\u003c\\u002fextra\\u003e\",\"legendgroup\":\"課題\",\"marker\":{\"color\":\"#EF553B\",\"pattern\":{\"shape\":\"\"}},\"name\":\"課題\",\"offsetgroup\":\"課題\",\"orientation\":\"h\",\"showlegend\":true,\"textposition\":\"auto\",\"x\":[2,0,0,6,3,0,0,23,3,0,0,1,0,1,0,0],\"xaxis\":\"x\",\"y\":[\"工業数学Ⅰ\",\"技術者の倫理\",\"工学基礎演習\",\"プログラミングⅠ\",\"プログラミング演習Ⅰ\",\"アルゴリズムとデータ構造\",\"情報ネットワークⅠ\",\"コンピュータシステム\",\"データサイエンス基礎\",\"ディジタル回路\",\"情報処理技術概論\",\"プロジェクトデザイン\",\"キャリアデザイン\",\"データマイニング\",\"ICT実践英語Ⅰ\",\"知能情報実験Ⅲ\"],\"yaxis\":\"y\",\"type\":\"bar\"},{\"alignmentgroup\":\"True\",\"hovertemplate\":\"row_idx=試験\\u003cbr\\u003evalue=%{x}\\u003cbr\\u003eindex=%{y}\\u003cextra\\u003e\\u003c\\u002fextra\\u003e\",\"legendgroup\":\"試験\",\"marker\":{\"color\":\"#00cc96\",\"pattern\":{\"shape\":\"\"}},\"name\":\"試験\",\"offsetgroup\":\"試験\",\"orientation\":\"h\",\"showlegend\":true,\"textposition\":\"auto\",\"x\":[0,0,0,0,0,3,0,29,4,0,2,0,0,0,0,0],\"xaxis\":\"x\",\"y\":[\"工業数学Ⅰ\",\"技術者の倫理\",\"工学基礎演習\",\"プログラミングⅠ\",\"プログラミング演習Ⅰ\",\"アルゴリズムとデータ構造\",\"情報ネットワークⅠ\",\"コンピュータシステム\",\"データサイエンス基礎\",\"ディジタル回路\",\"情報処理技術概論\",\"プロジェクトデザイン\",\"キャリアデザイン\",\"データマイニング\",\"ICT実践英語Ⅰ\",\"知能情報実験Ⅲ\"],\"yaxis\":\"y\",\"type\":\"bar\"},{\"alignmentgroup\":\"True\",\"hovertemplate\":\"row_idx=内容\\u003cbr\\u003evalue=%{x}\\u003cbr\\u003eindex=%{y}\\u003cextra\\u003e\\u003c\\u002fextra\\u003e\",\"legendgroup\":\"内容\",\"marker\":{\"color\":\"#ab63fa\",\"pattern\":{\"shape\":\"\"}},\"name\":\"内容\",\"offsetgroup\":\"内容\",\"orientation\":\"h\",\"showlegend\":true,\"textposition\":\"auto\",\"x\":[0,2,0,1,0,2,0,12,4,0,0,1,0,0,0,0],\"xaxis\":\"x\",\"y\":[\"工業数学Ⅰ\",\"技術者の倫理\",\"工学基礎演習\",\"プログラミングⅠ\",\"プログラミング演習Ⅰ\",\"アルゴリズムとデータ構造\",\"情報ネットワークⅠ\",\"コンピュータシステム\",\"データサイエンス基礎\",\"ディジタル回路\",\"情報処理技術概論\",\"プロジェクトデザイン\",\"キャリアデザイン\",\"データマイニング\",\"ICT実践英語Ⅰ\",\"知能情報実験Ⅲ\"],\"yaxis\":\"y\",\"type\":\"bar\"},{\"alignmentgroup\":\"True\",\"hovertemplate\":\"row_idx=問題\\u003cbr\\u003evalue=%{x}\\u003cbr\\u003eindex=%{y}\\u003cextra\\u003e\\u003c\\u002fextra\\u003e\",\"legendgroup\":\"問題\",\"marker\":{\"color\":\"#FFA15A\",\"pattern\":{\"shape\":\"\"}},\"name\":\"問題\",\"offsetgroup\":\"問題\",\"orientation\":\"h\",\"showlegend\":true,\"textposition\":\"auto\",\"x\":[1,0,0,0,0,4,0,12,2,0,1,0,0,0,0,0],\"xaxis\":\"x\",\"y\":[\"工業数学Ⅰ\",\"技術者の倫理\",\"工学基礎演習\",\"プログラミングⅠ\",\"プログラミング演習Ⅰ\",\"アルゴリズムとデータ構造\",\"情報ネットワークⅠ\",\"コンピュータシステム\",\"データサイエンス基礎\",\"ディジタル回路\",\"情報処理技術概論\",\"プロジェクトデザイン\",\"キャリアデザイン\",\"データマイニング\",\"ICT実践英語Ⅰ\",\"知能情報実験Ⅲ\"],\"yaxis\":\"y\",\"type\":\"bar\"},{\"alignmentgroup\":\"True\",\"hovertemplate\":\"row_idx=説明\\u003cbr\\u003evalue=%{x}\\u003cbr\\u003eindex=%{y}\\u003cextra\\u003e\\u003c\\u002fextra\\u003e\",\"legendgroup\":\"説明\",\"marker\":{\"color\":\"#19d3f3\",\"pattern\":{\"shape\":\"\"}},\"name\":\"説明\",\"offsetgroup\":\"説明\",\"orientation\":\"h\",\"showlegend\":true,\"textposition\":\"auto\",\"x\":[2,0,0,2,0,3,0,7,2,1,1,0,0,0,0,1],\"xaxis\":\"x\",\"y\":[\"工業数学Ⅰ\",\"技術者の倫理\",\"工学基礎演習\",\"プログラミングⅠ\",\"プログラミング演習Ⅰ\",\"アルゴリズムとデータ構造\",\"情報ネットワークⅠ\",\"コンピュータシステム\",\"データサイエンス基礎\",\"ディジタル回路\",\"情報処理技術概論\",\"プロジェクトデザイン\",\"キャリアデザイン\",\"データマイニング\",\"ICT実践英語Ⅰ\",\"知能情報実験Ⅲ\"],\"yaxis\":\"y\",\"type\":\"bar\"},{\"alignmentgroup\":\"True\",\"hovertemplate\":\"row_idx=なし\\u003cbr\\u003evalue=%{x}\\u003cbr\\u003eindex=%{y}\\u003cextra\\u003e\\u003c\\u002fextra\\u003e\",\"legendgroup\":\"なし\",\"marker\":{\"color\":\"#FF6692\",\"pattern\":{\"shape\":\"\"}},\"name\":\"なし\",\"offsetgroup\":\"なし\",\"orientation\":\"h\",\"showlegend\":true,\"textposition\":\"auto\",\"x\":[3,4,4,4,3,0,0,0,0,0,0,0,0,0,0,0],\"xaxis\":\"x\",\"y\":[\"工業数学Ⅰ\",\"技術者の倫理\",\"工学基礎演習\",\"プログラミングⅠ\",\"プログラミング演習Ⅰ\",\"アルゴリズムとデータ構造\",\"情報ネットワークⅠ\",\"コンピュータシステム\",\"データサイエンス基礎\",\"ディジタル回路\",\"情報処理技術概論\",\"プロジェクトデザイン\",\"キャリアデザイン\",\"データマイニング\",\"ICT実践英語Ⅰ\",\"知能情報実験Ⅲ\"],\"yaxis\":\"y\",\"type\":\"bar\"},{\"alignmentgroup\":\"True\",\"hovertemplate\":\"row_idx=資料\\u003cbr\\u003evalue=%{x}\\u003cbr\\u003eindex=%{y}\\u003cextra\\u003e\\u003c\\u002fextra\\u003e\",\"legendgroup\":\"資料\",\"marker\":{\"color\":\"#B6E880\",\"pattern\":{\"shape\":\"\"}},\"name\":\"資料\",\"offsetgroup\":\"資料\",\"orientation\":\"h\",\"showlegend\":true,\"textposition\":\"auto\",\"x\":[0,0,0,0,0,3,1,8,0,1,2,1,0,0,0,0],\"xaxis\":\"x\",\"y\":[\"工業数学Ⅰ\",\"技術者の倫理\",\"工学基礎演習\",\"プログラミングⅠ\",\"プログラミング演習Ⅰ\",\"アルゴリズムとデータ構造\",\"情報ネットワークⅠ\",\"コンピュータシステム\",\"データサイエンス基礎\",\"ディジタル回路\",\"情報処理技術概論\",\"プロジェクトデザイン\",\"キャリアデザイン\",\"データマイニング\",\"ICT実践英語Ⅰ\",\"知能情報実験Ⅲ\"],\"yaxis\":\"y\",\"type\":\"bar\"},{\"alignmentgroup\":\"True\",\"hovertemplate\":\"row_idx=先生\\u003cbr\\u003evalue=%{x}\\u003cbr\\u003eindex=%{y}\\u003cextra\\u003e\\u003c\\u002fextra\\u003e\",\"legendgroup\":\"先生\",\"marker\":{\"color\":\"#FF97FF\",\"pattern\":{\"shape\":\"\"}},\"name\":\"先生\",\"offsetgroup\":\"先生\",\"orientation\":\"h\",\"showlegend\":true,\"textposition\":\"auto\",\"x\":[0,3,0,1,0,1,0,6,2,0,1,0,1,0,0,0],\"xaxis\":\"x\",\"y\":[\"工業数学Ⅰ\",\"技術者の倫理\",\"工学基礎演習\",\"プログラミングⅠ\",\"プログラミング演習Ⅰ\",\"アルゴリズムとデータ構造\",\"情報ネットワークⅠ\",\"コンピュータシステム\",\"データサイエンス基礎\",\"ディジタル回路\",\"情報処理技術概論\",\"プロジェクトデザイン\",\"キャリアデザイン\",\"データマイニング\",\"ICT実践英語Ⅰ\",\"知能情報実験Ⅲ\"],\"yaxis\":\"y\",\"type\":\"bar\"},{\"alignmentgroup\":\"True\",\"hovertemplate\":\"row_idx=お\\u003cbr\\u003evalue=%{x}\\u003cbr\\u003eindex=%{y}\\u003cextra\\u003e\\u003c\\u002fextra\\u003e\",\"legendgroup\":\"お\",\"marker\":{\"color\":\"#FECB52\",\"pattern\":{\"shape\":\"\"}},\"name\":\"お\",\"offsetgroup\":\"お\",\"orientation\":\"h\",\"showlegend\":true,\"textposition\":\"auto\",\"x\":[1,2,0,2,1,0,3,4,1,0,0,0,0,0,0,0],\"xaxis\":\"x\",\"y\":[\"工業数学Ⅰ\",\"技術者の倫理\",\"工学基礎演習\",\"プログラミングⅠ\",\"プログラミング演習Ⅰ\",\"アルゴリズムとデータ構造\",\"情報ネットワークⅠ\",\"コンピュータシステム\",\"データサイエンス基礎\",\"ディジタル回路\",\"情報処理技術概論\",\"プロジェクトデザイン\",\"キャリアデザイン\",\"データマイニング\",\"ICT実践英語Ⅰ\",\"知能情報実験Ⅲ\"],\"yaxis\":\"y\",\"type\":\"bar\"},{\"alignmentgroup\":\"True\",\"hovertemplate\":\"row_idx=難易度\\u003cbr\\u003evalue=%{x}\\u003cbr\\u003eindex=%{y}\\u003cextra\\u003e\\u003c\\u002fextra\\u003e\",\"legendgroup\":\"難易度\",\"marker\":{\"color\":\"#636efa\",\"pattern\":{\"shape\":\"\"}},\"name\":\"難易度\",\"offsetgroup\":\"難易度\",\"orientation\":\"h\",\"showlegend\":true,\"textposition\":\"auto\",\"x\":[0,0,0,1,0,0,0,8,2,0,1,0,0,0,0,0],\"xaxis\":\"x\",\"y\":[\"工業数学Ⅰ\",\"技術者の倫理\",\"工学基礎演習\",\"プログラミングⅠ\",\"プログラミング演習Ⅰ\",\"アルゴリズムとデータ構造\",\"情報ネットワークⅠ\",\"コンピュータシステム\",\"データサイエンス基礎\",\"ディジタル回路\",\"情報処理技術概論\",\"プロジェクトデザイン\",\"キャリアデザイン\",\"データマイニング\",\"ICT実践英語Ⅰ\",\"知能情報実験Ⅲ\"],\"yaxis\":\"y\",\"type\":\"bar\"},{\"alignmentgroup\":\"True\",\"hovertemplate\":\"row_idx=解答\\u003cbr\\u003evalue=%{x}\\u003cbr\\u003eindex=%{y}\\u003cextra\\u003e\\u003c\\u002fextra\\u003e\",\"legendgroup\":\"解答\",\"marker\":{\"color\":\"#EF553B\",\"pattern\":{\"shape\":\"\"}},\"name\":\"解答\",\"offsetgroup\":\"解答\",\"orientation\":\"h\",\"showlegend\":true,\"textposition\":\"auto\",\"x\":[0,0,0,0,1,0,0,7,3,0,0,0,0,0,0,0],\"xaxis\":\"x\",\"y\":[\"工業数学Ⅰ\",\"技術者の倫理\",\"工学基礎演習\",\"プログラミングⅠ\",\"プログラミング演習Ⅰ\",\"アルゴリズムとデータ構造\",\"情報ネットワークⅠ\",\"コンピュータシステム\",\"データサイエンス基礎\",\"ディジタル回路\",\"情報処理技術概論\",\"プロジェクトデザイン\",\"キャリアデザイン\",\"データマイニング\",\"ICT実践英語Ⅰ\",\"知能情報実験Ⅲ\"],\"yaxis\":\"y\",\"type\":\"bar\"},{\"alignmentgroup\":\"True\",\"hovertemplate\":\"row_idx=実際\\u003cbr\\u003evalue=%{x}\\u003cbr\\u003eindex=%{y}\\u003cextra\\u003e\\u003c\\u002fextra\\u003e\",\"legendgroup\":\"実際\",\"marker\":{\"color\":\"#00cc96\",\"pattern\":{\"shape\":\"\"}},\"name\":\"実際\",\"offsetgroup\":\"実際\",\"orientation\":\"h\",\"showlegend\":true,\"textposition\":\"auto\",\"x\":[0,0,0,0,1,0,1,3,1,0,3,2,0,0,0,0],\"xaxis\":\"x\",\"y\":[\"工業数学Ⅰ\",\"技術者の倫理\",\"工学基礎演習\",\"プログラミングⅠ\",\"プログラミング演習Ⅰ\",\"アルゴリズムとデータ構造\",\"情報ネットワークⅠ\",\"コンピュータシステム\",\"データサイエンス基礎\",\"ディジタル回路\",\"情報処理技術概論\",\"プロジェクトデザイン\",\"キャリアデザイン\",\"データマイニング\",\"ICT実践英語Ⅰ\",\"知能情報実験Ⅲ\"],\"yaxis\":\"y\",\"type\":\"bar\"},{\"alignmentgroup\":\"True\",\"hovertemplate\":\"row_idx=方\\u003cbr\\u003evalue=%{x}\\u003cbr\\u003eindex=%{y}\\u003cextra\\u003e\\u003c\\u002fextra\\u003e\",\"legendgroup\":\"方\",\"marker\":{\"color\":\"#ab63fa\",\"pattern\":{\"shape\":\"\"}},\"name\":\"方\",\"offsetgroup\":\"方\",\"orientation\":\"h\",\"showlegend\":true,\"textposition\":\"auto\",\"x\":[0,0,1,0,1,0,2,0,2,0,2,2,0,0,0,0],\"xaxis\":\"x\",\"y\":[\"工業数学Ⅰ\",\"技術者の倫理\",\"工学基礎演習\",\"プログラミングⅠ\",\"プログラミング演習Ⅰ\",\"アルゴリズムとデータ構造\",\"情報ネットワークⅠ\",\"コンピュータシステム\",\"データサイエンス基礎\",\"ディジタル回路\",\"情報処理技術概論\",\"プロジェクトデザイン\",\"キャリアデザイン\",\"データマイニング\",\"ICT実践英語Ⅰ\",\"知能情報実験Ⅲ\"],\"yaxis\":\"y\",\"type\":\"bar\"},{\"alignmentgroup\":\"True\",\"hovertemplate\":\"row_idx=テスト\\u003cbr\\u003evalue=%{x}\\u003cbr\\u003eindex=%{y}\\u003cextra\\u003e\\u003c\\u002fextra\\u003e\",\"legendgroup\":\"テスト\",\"marker\":{\"color\":\"#FFA15A\",\"pattern\":{\"shape\":\"\"}},\"name\":\"テスト\",\"offsetgroup\":\"テスト\",\"orientation\":\"h\",\"showlegend\":true,\"textposition\":\"auto\",\"x\":[0,0,0,0,0,1,1,6,0,0,2,0,0,0,0,0],\"xaxis\":\"x\",\"y\":[\"工業数学Ⅰ\",\"技術者の倫理\",\"工学基礎演習\",\"プログラミングⅠ\",\"プログラミング演習Ⅰ\",\"アルゴリズムとデータ構造\",\"情報ネットワークⅠ\",\"コンピュータシステム\",\"データサイエンス基礎\",\"ディジタル回路\",\"情報処理技術概論\",\"プロジェクトデザイン\",\"キャリアデザイン\",\"データマイニング\",\"ICT実践英語Ⅰ\",\"知能情報実験Ⅲ\"],\"yaxis\":\"y\",\"type\":\"bar\"},{\"alignmentgroup\":\"True\",\"hovertemplate\":\"row_idx=知識\\u003cbr\\u003evalue=%{x}\\u003cbr\\u003eindex=%{y}\\u003cextra\\u003e\\u003c\\u002fextra\\u003e\",\"legendgroup\":\"知識\",\"marker\":{\"color\":\"#19d3f3\",\"pattern\":{\"shape\":\"\"}},\"name\":\"知識\",\"offsetgroup\":\"知識\",\"orientation\":\"h\",\"showlegend\":true,\"textposition\":\"auto\",\"x\":[0,1,0,1,1,0,0,2,4,0,0,0,0,0,0,0],\"xaxis\":\"x\",\"y\":[\"工業数学Ⅰ\",\"技術者の倫理\",\"工学基礎演習\",\"プログラミングⅠ\",\"プログラミング演習Ⅰ\",\"アルゴリズムとデータ構造\",\"情報ネットワークⅠ\",\"コンピュータシステム\",\"データサイエンス基礎\",\"ディジタル回路\",\"情報処理技術概論\",\"プロジェクトデザイン\",\"キャリアデザイン\",\"データマイニング\",\"ICT実践英語Ⅰ\",\"知能情報実験Ⅲ\"],\"yaxis\":\"y\",\"type\":\"bar\"},{\"alignmentgroup\":\"True\",\"hovertemplate\":\"row_idx=機会\\u003cbr\\u003evalue=%{x}\\u003cbr\\u003eindex=%{y}\\u003cextra\\u003e\\u003c\\u002fextra\\u003e\",\"legendgroup\":\"機会\",\"marker\":{\"color\":\"#FF6692\",\"pattern\":{\"shape\":\"\"}},\"name\":\"機会\",\"offsetgroup\":\"機会\",\"orientation\":\"h\",\"showlegend\":true,\"textposition\":\"auto\",\"x\":[0,0,3,0,0,0,1,0,0,0,0,5,0,0,0,0],\"xaxis\":\"x\",\"y\":[\"工業数学Ⅰ\",\"技術者の倫理\",\"工学基礎演習\",\"プログラミングⅠ\",\"プログラミング演習Ⅰ\",\"アルゴリズムとデータ構造\",\"情報ネットワークⅠ\",\"コンピュータシステム\",\"データサイエンス基礎\",\"ディジタル回路\",\"情報処理技術概論\",\"プロジェクトデザイン\",\"キャリアデザイン\",\"データマイニング\",\"ICT実践英語Ⅰ\",\"知能情報実験Ⅲ\"],\"yaxis\":\"y\",\"type\":\"bar\"},{\"alignmentgroup\":\"True\",\"hovertemplate\":\"row_idx=生徒\\u003cbr\\u003evalue=%{x}\\u003cbr\\u003eindex=%{y}\\u003cextra\\u003e\\u003c\\u002fextra\\u003e\",\"legendgroup\":\"生徒\",\"marker\":{\"color\":\"#B6E880\",\"pattern\":{\"shape\":\"\"}},\"name\":\"生徒\",\"offsetgroup\":\"生徒\",\"orientation\":\"h\",\"showlegend\":true,\"textposition\":\"auto\",\"x\":[0,0,0,0,0,1,0,8,0,0,0,0,0,0,0,0],\"xaxis\":\"x\",\"y\":[\"工業数学Ⅰ\",\"技術者の倫理\",\"工学基礎演習\",\"プログラミングⅠ\",\"プログラミング演習Ⅰ\",\"アルゴリズムとデータ構造\",\"情報ネットワークⅠ\",\"コンピュータシステム\",\"データサイエンス基礎\",\"ディジタル回路\",\"情報処理技術概論\",\"プロジェクトデザイン\",\"キャリアデザイン\",\"データマイニング\",\"ICT実践英語Ⅰ\",\"知能情報実験Ⅲ\"],\"yaxis\":\"y\",\"type\":\"bar\"},{\"alignmentgroup\":\"True\",\"hovertemplate\":\"row_idx=中間\\u003cbr\\u003evalue=%{x}\\u003cbr\\u003eindex=%{y}\\u003cextra\\u003e\\u003c\\u002fextra\\u003e\",\"legendgroup\":\"中間\",\"marker\":{\"color\":\"#FF97FF\",\"pattern\":{\"shape\":\"\"}},\"name\":\"中間\",\"offsetgroup\":\"中間\",\"orientation\":\"h\",\"showlegend\":true,\"textposition\":\"auto\",\"x\":[0,0,0,0,0,0,2,7,0,0,0,0,0,0,0,0],\"xaxis\":\"x\",\"y\":[\"工業数学Ⅰ\",\"技術者の倫理\",\"工学基礎演習\",\"プログラミングⅠ\",\"プログラミング演習Ⅰ\",\"アルゴリズムとデータ構造\",\"情報ネットワークⅠ\",\"コンピュータシステム\",\"データサイエンス基礎\",\"ディジタル回路\",\"情報処理技術概論\",\"プロジェクトデザイン\",\"キャリアデザイン\",\"データマイニング\",\"ICT実践英語Ⅰ\",\"知能情報実験Ⅲ\"],\"yaxis\":\"y\",\"type\":\"bar\"},{\"alignmentgroup\":\"True\",\"hovertemplate\":\"row_idx=期末\\u003cbr\\u003evalue=%{x}\\u003cbr\\u003eindex=%{y}\\u003cextra\\u003e\\u003c\\u002fextra\\u003e\",\"legendgroup\":\"期末\",\"marker\":{\"color\":\"#FECB52\",\"pattern\":{\"shape\":\"\"}},\"name\":\"期末\",\"offsetgroup\":\"期末\",\"orientation\":\"h\",\"showlegend\":true,\"textposition\":\"auto\",\"x\":[0,0,0,0,0,0,0,6,0,0,3,0,0,0,0,0],\"xaxis\":\"x\",\"y\":[\"工業数学Ⅰ\",\"技術者の倫理\",\"工学基礎演習\",\"プログラミングⅠ\",\"プログラミング演習Ⅰ\",\"アルゴリズムとデータ構造\",\"情報ネットワークⅠ\",\"コンピュータシステム\",\"データサイエンス基礎\",\"ディジタル回路\",\"情報処理技術概論\",\"プロジェクトデザイン\",\"キャリアデザイン\",\"データマイニング\",\"ICT実践英語Ⅰ\",\"知能情報実験Ⅲ\"],\"yaxis\":\"y\",\"type\":\"bar\"}],                        {\"template\":{\"data\":{\"histogram2dcontour\":[{\"type\":\"histogram2dcontour\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"},\"colorscale\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]]}],\"choropleth\":[{\"type\":\"choropleth\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}],\"histogram2d\":[{\"type\":\"histogram2d\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"},\"colorscale\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]]}],\"heatmap\":[{\"type\":\"heatmap\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"},\"colorscale\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]]}],\"heatmapgl\":[{\"type\":\"heatmapgl\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"},\"colorscale\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]]}],\"contourcarpet\":[{\"type\":\"contourcarpet\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}],\"contour\":[{\"type\":\"contour\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"},\"colorscale\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]]}],\"surface\":[{\"type\":\"surface\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"},\"colorscale\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]]}],\"mesh3d\":[{\"type\":\"mesh3d\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}],\"scatter\":[{\"fillpattern\":{\"fillmode\":\"overlay\",\"size\":10,\"solidity\":0.2},\"type\":\"scatter\"}],\"parcoords\":[{\"type\":\"parcoords\",\"line\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"scatterpolargl\":[{\"type\":\"scatterpolargl\",\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"bar\":[{\"error_x\":{\"color\":\"#2a3f5f\"},\"error_y\":{\"color\":\"#2a3f5f\"},\"marker\":{\"line\":{\"color\":\"#E5ECF6\",\"width\":0.5},\"pattern\":{\"fillmode\":\"overlay\",\"size\":10,\"solidity\":0.2}},\"type\":\"bar\"}],\"scattergeo\":[{\"type\":\"scattergeo\",\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"scatterpolar\":[{\"type\":\"scatterpolar\",\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"histogram\":[{\"marker\":{\"pattern\":{\"fillmode\":\"overlay\",\"size\":10,\"solidity\":0.2}},\"type\":\"histogram\"}],\"scattergl\":[{\"type\":\"scattergl\",\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"scatter3d\":[{\"type\":\"scatter3d\",\"line\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}},\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"scattermapbox\":[{\"type\":\"scattermapbox\",\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"scatterternary\":[{\"type\":\"scatterternary\",\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"scattercarpet\":[{\"type\":\"scattercarpet\",\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"carpet\":[{\"aaxis\":{\"endlinecolor\":\"#2a3f5f\",\"gridcolor\":\"white\",\"linecolor\":\"white\",\"minorgridcolor\":\"white\",\"startlinecolor\":\"#2a3f5f\"},\"baxis\":{\"endlinecolor\":\"#2a3f5f\",\"gridcolor\":\"white\",\"linecolor\":\"white\",\"minorgridcolor\":\"white\",\"startlinecolor\":\"#2a3f5f\"},\"type\":\"carpet\"}],\"table\":[{\"cells\":{\"fill\":{\"color\":\"#EBF0F8\"},\"line\":{\"color\":\"white\"}},\"header\":{\"fill\":{\"color\":\"#C8D4E3\"},\"line\":{\"color\":\"white\"}},\"type\":\"table\"}],\"barpolar\":[{\"marker\":{\"line\":{\"color\":\"#E5ECF6\",\"width\":0.5},\"pattern\":{\"fillmode\":\"overlay\",\"size\":10,\"solidity\":0.2}},\"type\":\"barpolar\"}],\"pie\":[{\"automargin\":true,\"type\":\"pie\"}]},\"layout\":{\"autotypenumbers\":\"strict\",\"colorway\":[\"#636efa\",\"#EF553B\",\"#00cc96\",\"#ab63fa\",\"#FFA15A\",\"#19d3f3\",\"#FF6692\",\"#B6E880\",\"#FF97FF\",\"#FECB52\"],\"font\":{\"color\":\"#2a3f5f\"},\"hovermode\":\"closest\",\"hoverlabel\":{\"align\":\"left\"},\"paper_bgcolor\":\"white\",\"plot_bgcolor\":\"#E5ECF6\",\"polar\":{\"bgcolor\":\"#E5ECF6\",\"angularaxis\":{\"gridcolor\":\"white\",\"linecolor\":\"white\",\"ticks\":\"\"},\"radialaxis\":{\"gridcolor\":\"white\",\"linecolor\":\"white\",\"ticks\":\"\"}},\"ternary\":{\"bgcolor\":\"#E5ECF6\",\"aaxis\":{\"gridcolor\":\"white\",\"linecolor\":\"white\",\"ticks\":\"\"},\"baxis\":{\"gridcolor\":\"white\",\"linecolor\":\"white\",\"ticks\":\"\"},\"caxis\":{\"gridcolor\":\"white\",\"linecolor\":\"white\",\"ticks\":\"\"}},\"coloraxis\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}},\"colorscale\":{\"sequential\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]],\"sequentialminus\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]],\"diverging\":[[0,\"#8e0152\"],[0.1,\"#c51b7d\"],[0.2,\"#de77ae\"],[0.3,\"#f1b6da\"],[0.4,\"#fde0ef\"],[0.5,\"#f7f7f7\"],[0.6,\"#e6f5d0\"],[0.7,\"#b8e186\"],[0.8,\"#7fbc41\"],[0.9,\"#4d9221\"],[1,\"#276419\"]]},\"xaxis\":{\"gridcolor\":\"white\",\"linecolor\":\"white\",\"ticks\":\"\",\"title\":{\"standoff\":15},\"zerolinecolor\":\"white\",\"automargin\":true,\"zerolinewidth\":2},\"yaxis\":{\"gridcolor\":\"white\",\"linecolor\":\"white\",\"ticks\":\"\",\"title\":{\"standoff\":15},\"zerolinecolor\":\"white\",\"automargin\":true,\"zerolinewidth\":2},\"scene\":{\"xaxis\":{\"backgroundcolor\":\"#E5ECF6\",\"gridcolor\":\"white\",\"linecolor\":\"white\",\"showbackground\":true,\"ticks\":\"\",\"zerolinecolor\":\"white\",\"gridwidth\":2},\"yaxis\":{\"backgroundcolor\":\"#E5ECF6\",\"gridcolor\":\"white\",\"linecolor\":\"white\",\"showbackground\":true,\"ticks\":\"\",\"zerolinecolor\":\"white\",\"gridwidth\":2},\"zaxis\":{\"backgroundcolor\":\"#E5ECF6\",\"gridcolor\":\"white\",\"linecolor\":\"white\",\"showbackground\":true,\"ticks\":\"\",\"zerolinecolor\":\"white\",\"gridwidth\":2}},\"shapedefaults\":{\"line\":{\"color\":\"#2a3f5f\"}},\"annotationdefaults\":{\"arrowcolor\":\"#2a3f5f\",\"arrowhead\":0,\"arrowwidth\":1},\"geo\":{\"bgcolor\":\"white\",\"landcolor\":\"#E5ECF6\",\"subunitcolor\":\"white\",\"showland\":true,\"showlakes\":true,\"lakecolor\":\"white\"},\"title\":{\"x\":0.05},\"mapbox\":{\"style\":\"light\"}}},\"xaxis\":{\"anchor\":\"y\",\"domain\":[0.0,1.0],\"title\":{\"text\":\"出現回数\"}},\"yaxis\":{\"anchor\":\"x\",\"domain\":[0.0,1.0],\"title\":{\"text\":\"授業一覧\"}},\"legend\":{\"title\":{\"text\":\"row_idx\"},\"tracegroupgap\":0},\"title\":{\"text\":\"授業別高頻度単語(top_n=20)の内訳（出現回数）\"},\"barmode\":\"stack\"},                        {\"responsive\": true}                    ).then(function(){\n",
              "                            \n",
              "var gd = document.getElementById('1864ef33-db2b-4550-91d7-6f275e00ca70');\n",
              "var x = new MutationObserver(function (mutations, observer) {{\n",
              "        var display = window.getComputedStyle(gd).display;\n",
              "        if (!display || display === 'none') {{\n",
              "            console.log([gd, 'removed!']);\n",
              "            Plotly.purge(gd);\n",
              "            observer.disconnect();\n",
              "        }}\n",
              "}});\n",
              "\n",
              "// Listen for the removal of the full notebook cells\n",
              "var notebookContainer = gd.closest('#notebook-container');\n",
              "if (notebookContainer) {{\n",
              "    x.observe(notebookContainer, {childList: true});\n",
              "}}\n",
              "\n",
              "// Listen for the clearing of the current output cell\n",
              "var outputEl = gd.closest('.output');\n",
              "if (outputEl) {{\n",
              "    x.observe(outputEl, {childList: true});\n",
              "}}\n",
              "\n",
              "                        })                };                            </script>        </div>\n",
              "</body>\n",
              "</html>"
            ]
          },
          "metadata": {}
        }
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "OkUQjMrlNYOs"
      },
      "source": [
        "#### 積み上げ棒グラフ3（横+正規化）\n",
        "一部の授業が突出しているため他の傾向を掴みづらい。出現回数をそのまま扱うのではなく、授業毎の出現割合に変換してから描画してみよう。"
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "import plotly.express as px\n",
        "\n",
        "# もとの正規化処理\n",
        "normalize_df = df_title_vs_word.div(df_title_vs_word.sum(axis=0), axis=1)\n",
        "\n",
        "# Plotly で積み上げ横棒グラフを作るために melt で縦長形式に変換\n",
        "#   - 変換後の「index」列が、元の df_title_vs_word の「columns」に対応し、\n",
        "#     これが棒グラフの y 軸（カテゴリ）になる\n",
        "#   - 「row_idx」が元の行名（積み上げの区分）\n",
        "#   - 「value」が実際にバーの長さ（正規化された値）\n",
        "df_melted = normalize_df.copy().T.reset_index()\n",
        "df_melted = df_melted.melt(\n",
        "    id_vars='index',      # 横軸が数値、縦軸(y)がこのカテゴリ\n",
        "    var_name='row_idx',   # 積み上げの区分（色分け）\n",
        "    value_name='value'    # バーの長さ\n",
        ")\n",
        "\n",
        "# Plotly Express で横向き（orientation='h'）の積み上げ棒グラフ（barmode='stack'）を作成\n",
        "# text='row_idx' でセグメント内に元の行名を表示し、textposition='inside' でバー内部に配置します。\n",
        "fig = px.bar(\n",
        "    df_melted,\n",
        "    x='value',\n",
        "    y='index',\n",
        "    color='row_idx',\n",
        "    orientation='h',\n",
        "    barmode='stack',\n",
        "    text='row_idx',  # 棒の中に各区分（row_idx）の名前を入れる\n",
        "    title=f'授業別高頻度単語(top_n={top_n})の内訳（割合）'\n",
        ")\n",
        "\n",
        "# テキストの位置・フォントサイズなどを調整\n",
        "fig.update_traces(\n",
        "    textposition='inside',\n",
        "    textfont_size=20\n",
        ")\n",
        "\n",
        "# 軸ラベルやグラフサイズなどを元コードに合わせて設定\n",
        "# （横棒グラフでもあえて元コードのままのラベルにしています）\n",
        "fig.update_layout(\n",
        "    xaxis_title='出現割合',   # 横軸側のタイトル\n",
        "    yaxis_title='授業一覧'   # 縦軸側のタイトル\n",
        ")\n",
        "\n",
        "fig.show()\n"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 542
        },
        "id": "vclHTLa5ysDV",
        "outputId": "cfd3dfdb-2f88-46b0-9146-233ff4b51068"
      },
      "execution_count": 16,
      "outputs": [
        {
          "output_type": "display_data",
          "data": {
            "text/html": [
              "<html>\n",
              "<head><meta charset=\"utf-8\" /></head>\n",
              "<body>\n",
              "    <div>            <script src=\"https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_SVG\"></script><script type=\"text/javascript\">if (window.MathJax && window.MathJax.Hub && window.MathJax.Hub.Config) {window.MathJax.Hub.Config({SVG: {font: \"STIX-Web\"}});}</script>                <script type=\"text/javascript\">window.PlotlyConfig = {MathJaxConfig: 'local'};</script>\n",
              "        <script charset=\"utf-8\" src=\"https://cdn.plot.ly/plotly-2.35.2.min.js\"></script>                <div id=\"4291f4f1-4126-40b1-a478-a14a9c3f2696\" class=\"plotly-graph-div\" style=\"height:525px; width:100%;\"></div>            <script type=\"text/javascript\">                                    window.PLOTLYENV=window.PLOTLYENV || {};                                    if (document.getElementById(\"4291f4f1-4126-40b1-a478-a14a9c3f2696\")) {                    Plotly.newPlot(                        \"4291f4f1-4126-40b1-a478-a14a9c3f2696\",                        [{\"alignmentgroup\":\"True\",\"hovertemplate\":\"row_idx=%{text}\\u003cbr\\u003evalue=%{x}\\u003cbr\\u003eindex=%{y}\\u003cextra\\u003e\\u003c\\u002fextra\\u003e\",\"legendgroup\":\"授業\",\"marker\":{\"color\":\"#636efa\",\"pattern\":{\"shape\":\"\"}},\"name\":\"授業\",\"offsetgroup\":\"授業\",\"orientation\":\"h\",\"showlegend\":true,\"text\":[\"授業\",\"授業\",\"授業\",\"授業\",\"授業\",\"授業\",\"授業\",\"授業\",\"授業\",\"授業\",\"授業\",\"授業\",\"授業\",\"授業\",\"授業\",\"授業\"],\"textposition\":\"inside\",\"x\":[0.25,0.2,0.2,0.0,0.08333333333333333,0.1,0.08333333333333333,0.11377245508982035,0.11764705882352941,0.3333333333333333,0.1,0.29411764705882354,0.0,0.0,null,0.5],\"xaxis\":\"x\",\"y\":[\"工業数学Ⅰ\",\"技術者の倫理\",\"工学基礎演習\",\"プログラミングⅠ\",\"プログラミング演習Ⅰ\",\"アルゴリズムとデータ構造\",\"情報ネットワークⅠ\",\"コンピュータシステム\",\"データサイエンス基礎\",\"ディジタル回路\",\"情報処理技術概論\",\"プロジェクトデザイン\",\"キャリアデザイン\",\"データマイニング\",\"ICT実践英語Ⅰ\",\"知能情報実験Ⅲ\"],\"yaxis\":\"y\",\"type\":\"bar\",\"textfont\":{\"size\":20}},{\"alignmentgroup\":\"True\",\"hovertemplate\":\"row_idx=%{text}\\u003cbr\\u003evalue=%{x}\\u003cbr\\u003eindex=%{y}\\u003cextra\\u003e\\u003c\\u002fextra\\u003e\",\"legendgroup\":\"課題\",\"marker\":{\"color\":\"#EF553B\",\"pattern\":{\"shape\":\"\"}},\"name\":\"課題\",\"offsetgroup\":\"課題\",\"orientation\":\"h\",\"showlegend\":true,\"text\":[\"課題\",\"課題\",\"課題\",\"課題\",\"課題\",\"課題\",\"課題\",\"課題\",\"課題\",\"課題\",\"課題\",\"課題\",\"課題\",\"課題\",\"課題\",\"課題\"],\"textposition\":\"inside\",\"x\":[0.16666666666666666,0.0,0.0,0.3333333333333333,0.25,0.0,0.0,0.1377245508982036,0.08823529411764706,0.0,0.0,0.058823529411764705,0.0,1.0,null,0.0],\"xaxis\":\"x\",\"y\":[\"工業数学Ⅰ\",\"技術者の倫理\",\"工学基礎演習\",\"プログラミングⅠ\",\"プログラミング演習Ⅰ\",\"アルゴリズムとデータ構造\",\"情報ネットワークⅠ\",\"コンピュータシステム\",\"データサイエンス基礎\",\"ディジタル回路\",\"情報処理技術概論\",\"プロジェクトデザイン\",\"キャリアデザイン\",\"データマイニング\",\"ICT実践英語Ⅰ\",\"知能情報実験Ⅲ\"],\"yaxis\":\"y\",\"type\":\"bar\",\"textfont\":{\"size\":20}},{\"alignmentgroup\":\"True\",\"hovertemplate\":\"row_idx=%{text}\\u003cbr\\u003evalue=%{x}\\u003cbr\\u003eindex=%{y}\\u003cextra\\u003e\\u003c\\u002fextra\\u003e\",\"legendgroup\":\"試験\",\"marker\":{\"color\":\"#00cc96\",\"pattern\":{\"shape\":\"\"}},\"name\":\"試験\",\"offsetgroup\":\"試験\",\"orientation\":\"h\",\"showlegend\":true,\"text\":[\"試験\",\"試験\",\"試験\",\"試験\",\"試験\",\"試験\",\"試験\",\"試験\",\"試験\",\"試験\",\"試験\",\"試験\",\"試験\",\"試験\",\"試験\",\"試験\"],\"textposition\":\"inside\",\"x\":[0.0,0.0,0.0,0.0,0.0,0.15,0.0,0.17365269461077845,0.11764705882352941,0.0,0.1,0.0,0.0,0.0,null,0.0],\"xaxis\":\"x\",\"y\":[\"工業数学Ⅰ\",\"技術者の倫理\",\"工学基礎演習\",\"プログラミングⅠ\",\"プログラミング演習Ⅰ\",\"アルゴリズムとデータ構造\",\"情報ネットワークⅠ\",\"コンピュータシステム\",\"データサイエンス基礎\",\"ディジタル回路\",\"情報処理技術概論\",\"プロジェクトデザイン\",\"キャリアデザイン\",\"データマイニング\",\"ICT実践英語Ⅰ\",\"知能情報実験Ⅲ\"],\"yaxis\":\"y\",\"type\":\"bar\",\"textfont\":{\"size\":20}},{\"alignmentgroup\":\"True\",\"hovertemplate\":\"row_idx=%{text}\\u003cbr\\u003evalue=%{x}\\u003cbr\\u003eindex=%{y}\\u003cextra\\u003e\\u003c\\u002fextra\\u003e\",\"legendgroup\":\"内容\",\"marker\":{\"color\":\"#ab63fa\",\"pattern\":{\"shape\":\"\"}},\"name\":\"内容\",\"offsetgroup\":\"内容\",\"orientation\":\"h\",\"showlegend\":true,\"text\":[\"内容\",\"内容\",\"内容\",\"内容\",\"内容\",\"内容\",\"内容\",\"内容\",\"内容\",\"内容\",\"内容\",\"内容\",\"内容\",\"内容\",\"内容\",\"内容\"],\"textposition\":\"inside\",\"x\":[0.0,0.13333333333333333,0.0,0.05555555555555555,0.0,0.1,0.0,0.0718562874251497,0.11764705882352941,0.0,0.0,0.058823529411764705,0.0,0.0,null,0.0],\"xaxis\":\"x\",\"y\":[\"工業数学Ⅰ\",\"技術者の倫理\",\"工学基礎演習\",\"プログラミングⅠ\",\"プログラミング演習Ⅰ\",\"アルゴリズムとデータ構造\",\"情報ネットワークⅠ\",\"コンピュータシステム\",\"データサイエンス基礎\",\"ディジタル回路\",\"情報処理技術概論\",\"プロジェクトデザイン\",\"キャリアデザイン\",\"データマイニング\",\"ICT実践英語Ⅰ\",\"知能情報実験Ⅲ\"],\"yaxis\":\"y\",\"type\":\"bar\",\"textfont\":{\"size\":20}},{\"alignmentgroup\":\"True\",\"hovertemplate\":\"row_idx=%{text}\\u003cbr\\u003evalue=%{x}\\u003cbr\\u003eindex=%{y}\\u003cextra\\u003e\\u003c\\u002fextra\\u003e\",\"legendgroup\":\"問題\",\"marker\":{\"color\":\"#FFA15A\",\"pattern\":{\"shape\":\"\"}},\"name\":\"問題\",\"offsetgroup\":\"問題\",\"orientation\":\"h\",\"showlegend\":true,\"text\":[\"問題\",\"問題\",\"問題\",\"問題\",\"問題\",\"問題\",\"問題\",\"問題\",\"問題\",\"問題\",\"問題\",\"問題\",\"問題\",\"問題\",\"問題\",\"問題\"],\"textposition\":\"inside\",\"x\":[0.08333333333333333,0.0,0.0,0.0,0.0,0.2,0.0,0.0718562874251497,0.058823529411764705,0.0,0.05,0.0,0.0,0.0,null,0.0],\"xaxis\":\"x\",\"y\":[\"工業数学Ⅰ\",\"技術者の倫理\",\"工学基礎演習\",\"プログラミングⅠ\",\"プログラミング演習Ⅰ\",\"アルゴリズムとデータ構造\",\"情報ネットワークⅠ\",\"コンピュータシステム\",\"データサイエンス基礎\",\"ディジタル回路\",\"情報処理技術概論\",\"プロジェクトデザイン\",\"キャリアデザイン\",\"データマイニング\",\"ICT実践英語Ⅰ\",\"知能情報実験Ⅲ\"],\"yaxis\":\"y\",\"type\":\"bar\",\"textfont\":{\"size\":20}},{\"alignmentgroup\":\"True\",\"hovertemplate\":\"row_idx=%{text}\\u003cbr\\u003evalue=%{x}\\u003cbr\\u003eindex=%{y}\\u003cextra\\u003e\\u003c\\u002fextra\\u003e\",\"legendgroup\":\"説明\",\"marker\":{\"color\":\"#19d3f3\",\"pattern\":{\"shape\":\"\"}},\"name\":\"説明\",\"offsetgroup\":\"説明\",\"orientation\":\"h\",\"showlegend\":true,\"text\":[\"説明\",\"説明\",\"説明\",\"説明\",\"説明\",\"説明\",\"説明\",\"説明\",\"説明\",\"説明\",\"説明\",\"説明\",\"説明\",\"説明\",\"説明\",\"説明\"],\"textposition\":\"inside\",\"x\":[0.16666666666666666,0.0,0.0,0.1111111111111111,0.0,0.15,0.0,0.041916167664670656,0.058823529411764705,0.3333333333333333,0.05,0.0,0.0,0.0,null,0.5],\"xaxis\":\"x\",\"y\":[\"工業数学Ⅰ\",\"技術者の倫理\",\"工学基礎演習\",\"プログラミングⅠ\",\"プログラミング演習Ⅰ\",\"アルゴリズムとデータ構造\",\"情報ネットワークⅠ\",\"コンピュータシステム\",\"データサイエンス基礎\",\"ディジタル回路\",\"情報処理技術概論\",\"プロジェクトデザイン\",\"キャリアデザイン\",\"データマイニング\",\"ICT実践英語Ⅰ\",\"知能情報実験Ⅲ\"],\"yaxis\":\"y\",\"type\":\"bar\",\"textfont\":{\"size\":20}},{\"alignmentgroup\":\"True\",\"hovertemplate\":\"row_idx=%{text}\\u003cbr\\u003evalue=%{x}\\u003cbr\\u003eindex=%{y}\\u003cextra\\u003e\\u003c\\u002fextra\\u003e\",\"legendgroup\":\"なし\",\"marker\":{\"color\":\"#FF6692\",\"pattern\":{\"shape\":\"\"}},\"name\":\"なし\",\"offsetgroup\":\"なし\",\"orientation\":\"h\",\"showlegend\":true,\"text\":[\"なし\",\"なし\",\"なし\",\"なし\",\"なし\",\"なし\",\"なし\",\"なし\",\"なし\",\"なし\",\"なし\",\"なし\",\"なし\",\"なし\",\"なし\",\"なし\"],\"textposition\":\"inside\",\"x\":[0.25,0.26666666666666666,0.4,0.2222222222222222,0.25,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,null,0.0],\"xaxis\":\"x\",\"y\":[\"工業数学Ⅰ\",\"技術者の倫理\",\"工学基礎演習\",\"プログラミングⅠ\",\"プログラミング演習Ⅰ\",\"アルゴリズムとデータ構造\",\"情報ネットワークⅠ\",\"コンピュータシステム\",\"データサイエンス基礎\",\"ディジタル回路\",\"情報処理技術概論\",\"プロジェクトデザイン\",\"キャリアデザイン\",\"データマイニング\",\"ICT実践英語Ⅰ\",\"知能情報実験Ⅲ\"],\"yaxis\":\"y\",\"type\":\"bar\",\"textfont\":{\"size\":20}},{\"alignmentgroup\":\"True\",\"hovertemplate\":\"row_idx=%{text}\\u003cbr\\u003evalue=%{x}\\u003cbr\\u003eindex=%{y}\\u003cextra\\u003e\\u003c\\u002fextra\\u003e\",\"legendgroup\":\"資料\",\"marker\":{\"color\":\"#B6E880\",\"pattern\":{\"shape\":\"\"}},\"name\":\"資料\",\"offsetgroup\":\"資料\",\"orientation\":\"h\",\"showlegend\":true,\"text\":[\"資料\",\"資料\",\"資料\",\"資料\",\"資料\",\"資料\",\"資料\",\"資料\",\"資料\",\"資料\",\"資料\",\"資料\",\"資料\",\"資料\",\"資料\",\"資料\"],\"textposition\":\"inside\",\"x\":[0.0,0.0,0.0,0.0,0.0,0.15,0.08333333333333333,0.04790419161676647,0.0,0.3333333333333333,0.1,0.058823529411764705,0.0,0.0,null,0.0],\"xaxis\":\"x\",\"y\":[\"工業数学Ⅰ\",\"技術者の倫理\",\"工学基礎演習\",\"プログラミングⅠ\",\"プログラミング演習Ⅰ\",\"アルゴリズムとデータ構造\",\"情報ネットワークⅠ\",\"コンピュータシステム\",\"データサイエンス基礎\",\"ディジタル回路\",\"情報処理技術概論\",\"プロジェクトデザイン\",\"キャリアデザイン\",\"データマイニング\",\"ICT実践英語Ⅰ\",\"知能情報実験Ⅲ\"],\"yaxis\":\"y\",\"type\":\"bar\",\"textfont\":{\"size\":20}},{\"alignmentgroup\":\"True\",\"hovertemplate\":\"row_idx=%{text}\\u003cbr\\u003evalue=%{x}\\u003cbr\\u003eindex=%{y}\\u003cextra\\u003e\\u003c\\u002fextra\\u003e\",\"legendgroup\":\"先生\",\"marker\":{\"color\":\"#FF97FF\",\"pattern\":{\"shape\":\"\"}},\"name\":\"先生\",\"offsetgroup\":\"先生\",\"orientation\":\"h\",\"showlegend\":true,\"text\":[\"先生\",\"先生\",\"先生\",\"先生\",\"先生\",\"先生\",\"先生\",\"先生\",\"先生\",\"先生\",\"先生\",\"先生\",\"先生\",\"先生\",\"先生\",\"先生\"],\"textposition\":\"inside\",\"x\":[0.0,0.2,0.0,0.05555555555555555,0.0,0.05,0.0,0.03592814371257485,0.058823529411764705,0.0,0.05,0.0,1.0,0.0,null,0.0],\"xaxis\":\"x\",\"y\":[\"工業数学Ⅰ\",\"技術者の倫理\",\"工学基礎演習\",\"プログラミングⅠ\",\"プログラミング演習Ⅰ\",\"アルゴリズムとデータ構造\",\"情報ネットワークⅠ\",\"コンピュータシステム\",\"データサイエンス基礎\",\"ディジタル回路\",\"情報処理技術概論\",\"プロジェクトデザイン\",\"キャリアデザイン\",\"データマイニング\",\"ICT実践英語Ⅰ\",\"知能情報実験Ⅲ\"],\"yaxis\":\"y\",\"type\":\"bar\",\"textfont\":{\"size\":20}},{\"alignmentgroup\":\"True\",\"hovertemplate\":\"row_idx=%{text}\\u003cbr\\u003evalue=%{x}\\u003cbr\\u003eindex=%{y}\\u003cextra\\u003e\\u003c\\u002fextra\\u003e\",\"legendgroup\":\"お\",\"marker\":{\"color\":\"#FECB52\",\"pattern\":{\"shape\":\"\"}},\"name\":\"お\",\"offsetgroup\":\"お\",\"orientation\":\"h\",\"showlegend\":true,\"text\":[\"お\",\"お\",\"お\",\"お\",\"お\",\"お\",\"お\",\"お\",\"お\",\"お\",\"お\",\"お\",\"お\",\"お\",\"お\",\"お\"],\"textposition\":\"inside\",\"x\":[0.08333333333333333,0.13333333333333333,0.0,0.1111111111111111,0.08333333333333333,0.0,0.25,0.023952095808383235,0.029411764705882353,0.0,0.0,0.0,0.0,0.0,null,0.0],\"xaxis\":\"x\",\"y\":[\"工業数学Ⅰ\",\"技術者の倫理\",\"工学基礎演習\",\"プログラミングⅠ\",\"プログラミング演習Ⅰ\",\"アルゴリズムとデータ構造\",\"情報ネットワークⅠ\",\"コンピュータシステム\",\"データサイエンス基礎\",\"ディジタル回路\",\"情報処理技術概論\",\"プロジェクトデザイン\",\"キャリアデザイン\",\"データマイニング\",\"ICT実践英語Ⅰ\",\"知能情報実験Ⅲ\"],\"yaxis\":\"y\",\"type\":\"bar\",\"textfont\":{\"size\":20}},{\"alignmentgroup\":\"True\",\"hovertemplate\":\"row_idx=%{text}\\u003cbr\\u003evalue=%{x}\\u003cbr\\u003eindex=%{y}\\u003cextra\\u003e\\u003c\\u002fextra\\u003e\",\"legendgroup\":\"難易度\",\"marker\":{\"color\":\"#636efa\",\"pattern\":{\"shape\":\"\"}},\"name\":\"難易度\",\"offsetgroup\":\"難易度\",\"orientation\":\"h\",\"showlegend\":true,\"text\":[\"難易度\",\"難易度\",\"難易度\",\"難易度\",\"難易度\",\"難易度\",\"難易度\",\"難易度\",\"難易度\",\"難易度\",\"難易度\",\"難易度\",\"難易度\",\"難易度\",\"難易度\",\"難易度\"],\"textposition\":\"inside\",\"x\":[0.0,0.0,0.0,0.05555555555555555,0.0,0.0,0.0,0.04790419161676647,0.058823529411764705,0.0,0.05,0.0,0.0,0.0,null,0.0],\"xaxis\":\"x\",\"y\":[\"工業数学Ⅰ\",\"技術者の倫理\",\"工学基礎演習\",\"プログラミングⅠ\",\"プログラミング演習Ⅰ\",\"アルゴリズムとデータ構造\",\"情報ネットワークⅠ\",\"コンピュータシステム\",\"データサイエンス基礎\",\"ディジタル回路\",\"情報処理技術概論\",\"プロジェクトデザイン\",\"キャリアデザイン\",\"データマイニング\",\"ICT実践英語Ⅰ\",\"知能情報実験Ⅲ\"],\"yaxis\":\"y\",\"type\":\"bar\",\"textfont\":{\"size\":20}},{\"alignmentgroup\":\"True\",\"hovertemplate\":\"row_idx=%{text}\\u003cbr\\u003evalue=%{x}\\u003cbr\\u003eindex=%{y}\\u003cextra\\u003e\\u003c\\u002fextra\\u003e\",\"legendgroup\":\"解答\",\"marker\":{\"color\":\"#EF553B\",\"pattern\":{\"shape\":\"\"}},\"name\":\"解答\",\"offsetgroup\":\"解答\",\"orientation\":\"h\",\"showlegend\":true,\"text\":[\"解答\",\"解答\",\"解答\",\"解答\",\"解答\",\"解答\",\"解答\",\"解答\",\"解答\",\"解答\",\"解答\",\"解答\",\"解答\",\"解答\",\"解答\",\"解答\"],\"textposition\":\"inside\",\"x\":[0.0,0.0,0.0,0.0,0.08333333333333333,0.0,0.0,0.041916167664670656,0.08823529411764706,0.0,0.0,0.0,0.0,0.0,null,0.0],\"xaxis\":\"x\",\"y\":[\"工業数学Ⅰ\",\"技術者の倫理\",\"工学基礎演習\",\"プログラミングⅠ\",\"プログラミング演習Ⅰ\",\"アルゴリズムとデータ構造\",\"情報ネットワークⅠ\",\"コンピュータシステム\",\"データサイエンス基礎\",\"ディジタル回路\",\"情報処理技術概論\",\"プロジェクトデザイン\",\"キャリアデザイン\",\"データマイニング\",\"ICT実践英語Ⅰ\",\"知能情報実験Ⅲ\"],\"yaxis\":\"y\",\"type\":\"bar\",\"textfont\":{\"size\":20}},{\"alignmentgroup\":\"True\",\"hovertemplate\":\"row_idx=%{text}\\u003cbr\\u003evalue=%{x}\\u003cbr\\u003eindex=%{y}\\u003cextra\\u003e\\u003c\\u002fextra\\u003e\",\"legendgroup\":\"実際\",\"marker\":{\"color\":\"#00cc96\",\"pattern\":{\"shape\":\"\"}},\"name\":\"実際\",\"offsetgroup\":\"実際\",\"orientation\":\"h\",\"showlegend\":true,\"text\":[\"実際\",\"実際\",\"実際\",\"実際\",\"実際\",\"実際\",\"実際\",\"実際\",\"実際\",\"実際\",\"実際\",\"実際\",\"実際\",\"実際\",\"実際\",\"実際\"],\"textposition\":\"inside\",\"x\":[0.0,0.0,0.0,0.0,0.08333333333333333,0.0,0.08333333333333333,0.017964071856287425,0.029411764705882353,0.0,0.15,0.11764705882352941,0.0,0.0,null,0.0],\"xaxis\":\"x\",\"y\":[\"工業数学Ⅰ\",\"技術者の倫理\",\"工学基礎演習\",\"プログラミングⅠ\",\"プログラミング演習Ⅰ\",\"アルゴリズムとデータ構造\",\"情報ネットワークⅠ\",\"コンピュータシステム\",\"データサイエンス基礎\",\"ディジタル回路\",\"情報処理技術概論\",\"プロジェクトデザイン\",\"キャリアデザイン\",\"データマイニング\",\"ICT実践英語Ⅰ\",\"知能情報実験Ⅲ\"],\"yaxis\":\"y\",\"type\":\"bar\",\"textfont\":{\"size\":20}},{\"alignmentgroup\":\"True\",\"hovertemplate\":\"row_idx=%{text}\\u003cbr\\u003evalue=%{x}\\u003cbr\\u003eindex=%{y}\\u003cextra\\u003e\\u003c\\u002fextra\\u003e\",\"legendgroup\":\"方\",\"marker\":{\"color\":\"#ab63fa\",\"pattern\":{\"shape\":\"\"}},\"name\":\"方\",\"offsetgroup\":\"方\",\"orientation\":\"h\",\"showlegend\":true,\"text\":[\"方\",\"方\",\"方\",\"方\",\"方\",\"方\",\"方\",\"方\",\"方\",\"方\",\"方\",\"方\",\"方\",\"方\",\"方\",\"方\"],\"textposition\":\"inside\",\"x\":[0.0,0.0,0.1,0.0,0.08333333333333333,0.0,0.16666666666666666,0.0,0.058823529411764705,0.0,0.1,0.11764705882352941,0.0,0.0,null,0.0],\"xaxis\":\"x\",\"y\":[\"工業数学Ⅰ\",\"技術者の倫理\",\"工学基礎演習\",\"プログラミングⅠ\",\"プログラミング演習Ⅰ\",\"アルゴリズムとデータ構造\",\"情報ネットワークⅠ\",\"コンピュータシステム\",\"データサイエンス基礎\",\"ディジタル回路\",\"情報処理技術概論\",\"プロジェクトデザイン\",\"キャリアデザイン\",\"データマイニング\",\"ICT実践英語Ⅰ\",\"知能情報実験Ⅲ\"],\"yaxis\":\"y\",\"type\":\"bar\",\"textfont\":{\"size\":20}},{\"alignmentgroup\":\"True\",\"hovertemplate\":\"row_idx=%{text}\\u003cbr\\u003evalue=%{x}\\u003cbr\\u003eindex=%{y}\\u003cextra\\u003e\\u003c\\u002fextra\\u003e\",\"legendgroup\":\"テスト\",\"marker\":{\"color\":\"#FFA15A\",\"pattern\":{\"shape\":\"\"}},\"name\":\"テスト\",\"offsetgroup\":\"テスト\",\"orientation\":\"h\",\"showlegend\":true,\"text\":[\"テスト\",\"テスト\",\"テスト\",\"テスト\",\"テスト\",\"テスト\",\"テスト\",\"テスト\",\"テスト\",\"テスト\",\"テスト\",\"テスト\",\"テスト\",\"テスト\",\"テスト\",\"テスト\"],\"textposition\":\"inside\",\"x\":[0.0,0.0,0.0,0.0,0.0,0.05,0.08333333333333333,0.03592814371257485,0.0,0.0,0.1,0.0,0.0,0.0,null,0.0],\"xaxis\":\"x\",\"y\":[\"工業数学Ⅰ\",\"技術者の倫理\",\"工学基礎演習\",\"プログラミングⅠ\",\"プログラミング演習Ⅰ\",\"アルゴリズムとデータ構造\",\"情報ネットワークⅠ\",\"コンピュータシステム\",\"データサイエンス基礎\",\"ディジタル回路\",\"情報処理技術概論\",\"プロジェクトデザイン\",\"キャリアデザイン\",\"データマイニング\",\"ICT実践英語Ⅰ\",\"知能情報実験Ⅲ\"],\"yaxis\":\"y\",\"type\":\"bar\",\"textfont\":{\"size\":20}},{\"alignmentgroup\":\"True\",\"hovertemplate\":\"row_idx=%{text}\\u003cbr\\u003evalue=%{x}\\u003cbr\\u003eindex=%{y}\\u003cextra\\u003e\\u003c\\u002fextra\\u003e\",\"legendgroup\":\"知識\",\"marker\":{\"color\":\"#19d3f3\",\"pattern\":{\"shape\":\"\"}},\"name\":\"知識\",\"offsetgroup\":\"知識\",\"orientation\":\"h\",\"showlegend\":true,\"text\":[\"知識\",\"知識\",\"知識\",\"知識\",\"知識\",\"知識\",\"知識\",\"知識\",\"知識\",\"知識\",\"知識\",\"知識\",\"知識\",\"知識\",\"知識\",\"知識\"],\"textposition\":\"inside\",\"x\":[0.0,0.06666666666666667,0.0,0.05555555555555555,0.08333333333333333,0.0,0.0,0.011976047904191617,0.11764705882352941,0.0,0.0,0.0,0.0,0.0,null,0.0],\"xaxis\":\"x\",\"y\":[\"工業数学Ⅰ\",\"技術者の倫理\",\"工学基礎演習\",\"プログラミングⅠ\",\"プログラミング演習Ⅰ\",\"アルゴリズムとデータ構造\",\"情報ネットワークⅠ\",\"コンピュータシステム\",\"データサイエンス基礎\",\"ディジタル回路\",\"情報処理技術概論\",\"プロジェクトデザイン\",\"キャリアデザイン\",\"データマイニング\",\"ICT実践英語Ⅰ\",\"知能情報実験Ⅲ\"],\"yaxis\":\"y\",\"type\":\"bar\",\"textfont\":{\"size\":20}},{\"alignmentgroup\":\"True\",\"hovertemplate\":\"row_idx=%{text}\\u003cbr\\u003evalue=%{x}\\u003cbr\\u003eindex=%{y}\\u003cextra\\u003e\\u003c\\u002fextra\\u003e\",\"legendgroup\":\"機会\",\"marker\":{\"color\":\"#FF6692\",\"pattern\":{\"shape\":\"\"}},\"name\":\"機会\",\"offsetgroup\":\"機会\",\"orientation\":\"h\",\"showlegend\":true,\"text\":[\"機会\",\"機会\",\"機会\",\"機会\",\"機会\",\"機会\",\"機会\",\"機会\",\"機会\",\"機会\",\"機会\",\"機会\",\"機会\",\"機会\",\"機会\",\"機会\"],\"textposition\":\"inside\",\"x\":[0.0,0.0,0.3,0.0,0.0,0.0,0.08333333333333333,0.0,0.0,0.0,0.0,0.29411764705882354,0.0,0.0,null,0.0],\"xaxis\":\"x\",\"y\":[\"工業数学Ⅰ\",\"技術者の倫理\",\"工学基礎演習\",\"プログラミングⅠ\",\"プログラミング演習Ⅰ\",\"アルゴリズムとデータ構造\",\"情報ネットワークⅠ\",\"コンピュータシステム\",\"データサイエンス基礎\",\"ディジタル回路\",\"情報処理技術概論\",\"プロジェクトデザイン\",\"キャリアデザイン\",\"データマイニング\",\"ICT実践英語Ⅰ\",\"知能情報実験Ⅲ\"],\"yaxis\":\"y\",\"type\":\"bar\",\"textfont\":{\"size\":20}},{\"alignmentgroup\":\"True\",\"hovertemplate\":\"row_idx=%{text}\\u003cbr\\u003evalue=%{x}\\u003cbr\\u003eindex=%{y}\\u003cextra\\u003e\\u003c\\u002fextra\\u003e\",\"legendgroup\":\"生徒\",\"marker\":{\"color\":\"#B6E880\",\"pattern\":{\"shape\":\"\"}},\"name\":\"生徒\",\"offsetgroup\":\"生徒\",\"orientation\":\"h\",\"showlegend\":true,\"text\":[\"生徒\",\"生徒\",\"生徒\",\"生徒\",\"生徒\",\"生徒\",\"生徒\",\"生徒\",\"生徒\",\"生徒\",\"生徒\",\"生徒\",\"生徒\",\"生徒\",\"生徒\",\"生徒\"],\"textposition\":\"inside\",\"x\":[0.0,0.0,0.0,0.0,0.0,0.05,0.0,0.04790419161676647,0.0,0.0,0.0,0.0,0.0,0.0,null,0.0],\"xaxis\":\"x\",\"y\":[\"工業数学Ⅰ\",\"技術者の倫理\",\"工学基礎演習\",\"プログラミングⅠ\",\"プログラミング演習Ⅰ\",\"アルゴリズムとデータ構造\",\"情報ネットワークⅠ\",\"コンピュータシステム\",\"データサイエンス基礎\",\"ディジタル回路\",\"情報処理技術概論\",\"プロジェクトデザイン\",\"キャリアデザイン\",\"データマイニング\",\"ICT実践英語Ⅰ\",\"知能情報実験Ⅲ\"],\"yaxis\":\"y\",\"type\":\"bar\",\"textfont\":{\"size\":20}},{\"alignmentgroup\":\"True\",\"hovertemplate\":\"row_idx=%{text}\\u003cbr\\u003evalue=%{x}\\u003cbr\\u003eindex=%{y}\\u003cextra\\u003e\\u003c\\u002fextra\\u003e\",\"legendgroup\":\"中間\",\"marker\":{\"color\":\"#FF97FF\",\"pattern\":{\"shape\":\"\"}},\"name\":\"中間\",\"offsetgroup\":\"中間\",\"orientation\":\"h\",\"showlegend\":true,\"text\":[\"中間\",\"中間\",\"中間\",\"中間\",\"中間\",\"中間\",\"中間\",\"中間\",\"中間\",\"中間\",\"中間\",\"中間\",\"中間\",\"中間\",\"中間\",\"中間\"],\"textposition\":\"inside\",\"x\":[0.0,0.0,0.0,0.0,0.0,0.0,0.16666666666666666,0.041916167664670656,0.0,0.0,0.0,0.0,0.0,0.0,null,0.0],\"xaxis\":\"x\",\"y\":[\"工業数学Ⅰ\",\"技術者の倫理\",\"工学基礎演習\",\"プログラミングⅠ\",\"プログラミング演習Ⅰ\",\"アルゴリズムとデータ構造\",\"情報ネットワークⅠ\",\"コンピュータシステム\",\"データサイエンス基礎\",\"ディジタル回路\",\"情報処理技術概論\",\"プロジェクトデザイン\",\"キャリアデザイン\",\"データマイニング\",\"ICT実践英語Ⅰ\",\"知能情報実験Ⅲ\"],\"yaxis\":\"y\",\"type\":\"bar\",\"textfont\":{\"size\":20}},{\"alignmentgroup\":\"True\",\"hovertemplate\":\"row_idx=%{text}\\u003cbr\\u003evalue=%{x}\\u003cbr\\u003eindex=%{y}\\u003cextra\\u003e\\u003c\\u002fextra\\u003e\",\"legendgroup\":\"期末\",\"marker\":{\"color\":\"#FECB52\",\"pattern\":{\"shape\":\"\"}},\"name\":\"期末\",\"offsetgroup\":\"期末\",\"orientation\":\"h\",\"showlegend\":true,\"text\":[\"期末\",\"期末\",\"期末\",\"期末\",\"期末\",\"期末\",\"期末\",\"期末\",\"期末\",\"期末\",\"期末\",\"期末\",\"期末\",\"期末\",\"期末\",\"期末\"],\"textposition\":\"inside\",\"x\":[0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.03592814371257485,0.0,0.0,0.15,0.0,0.0,0.0,null,0.0],\"xaxis\":\"x\",\"y\":[\"工業数学Ⅰ\",\"技術者の倫理\",\"工学基礎演習\",\"プログラミングⅠ\",\"プログラミング演習Ⅰ\",\"アルゴリズムとデータ構造\",\"情報ネットワークⅠ\",\"コンピュータシステム\",\"データサイエンス基礎\",\"ディジタル回路\",\"情報処理技術概論\",\"プロジェクトデザイン\",\"キャリアデザイン\",\"データマイニング\",\"ICT実践英語Ⅰ\",\"知能情報実験Ⅲ\"],\"yaxis\":\"y\",\"type\":\"bar\",\"textfont\":{\"size\":20}}],                        {\"template\":{\"data\":{\"histogram2dcontour\":[{\"type\":\"histogram2dcontour\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"},\"colorscale\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]]}],\"choropleth\":[{\"type\":\"choropleth\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}],\"histogram2d\":[{\"type\":\"histogram2d\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"},\"colorscale\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]]}],\"heatmap\":[{\"type\":\"heatmap\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"},\"colorscale\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]]}],\"heatmapgl\":[{\"type\":\"heatmapgl\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"},\"colorscale\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]]}],\"contourcarpet\":[{\"type\":\"contourcarpet\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}],\"contour\":[{\"type\":\"contour\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"},\"colorscale\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]]}],\"surface\":[{\"type\":\"surface\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"},\"colorscale\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]]}],\"mesh3d\":[{\"type\":\"mesh3d\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}],\"scatter\":[{\"fillpattern\":{\"fillmode\":\"overlay\",\"size\":10,\"solidity\":0.2},\"type\":\"scatter\"}],\"parcoords\":[{\"type\":\"parcoords\",\"line\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"scatterpolargl\":[{\"type\":\"scatterpolargl\",\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"bar\":[{\"error_x\":{\"color\":\"#2a3f5f\"},\"error_y\":{\"color\":\"#2a3f5f\"},\"marker\":{\"line\":{\"color\":\"#E5ECF6\",\"width\":0.5},\"pattern\":{\"fillmode\":\"overlay\",\"size\":10,\"solidity\":0.2}},\"type\":\"bar\"}],\"scattergeo\":[{\"type\":\"scattergeo\",\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"scatterpolar\":[{\"type\":\"scatterpolar\",\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"histogram\":[{\"marker\":{\"pattern\":{\"fillmode\":\"overlay\",\"size\":10,\"solidity\":0.2}},\"type\":\"histogram\"}],\"scattergl\":[{\"type\":\"scattergl\",\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"scatter3d\":[{\"type\":\"scatter3d\",\"line\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}},\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"scattermapbox\":[{\"type\":\"scattermapbox\",\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"scatterternary\":[{\"type\":\"scatterternary\",\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"scattercarpet\":[{\"type\":\"scattercarpet\",\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"carpet\":[{\"aaxis\":{\"endlinecolor\":\"#2a3f5f\",\"gridcolor\":\"white\",\"linecolor\":\"white\",\"minorgridcolor\":\"white\",\"startlinecolor\":\"#2a3f5f\"},\"baxis\":{\"endlinecolor\":\"#2a3f5f\",\"gridcolor\":\"white\",\"linecolor\":\"white\",\"minorgridcolor\":\"white\",\"startlinecolor\":\"#2a3f5f\"},\"type\":\"carpet\"}],\"table\":[{\"cells\":{\"fill\":{\"color\":\"#EBF0F8\"},\"line\":{\"color\":\"white\"}},\"header\":{\"fill\":{\"color\":\"#C8D4E3\"},\"line\":{\"color\":\"white\"}},\"type\":\"table\"}],\"barpolar\":[{\"marker\":{\"line\":{\"color\":\"#E5ECF6\",\"width\":0.5},\"pattern\":{\"fillmode\":\"overlay\",\"size\":10,\"solidity\":0.2}},\"type\":\"barpolar\"}],\"pie\":[{\"automargin\":true,\"type\":\"pie\"}]},\"layout\":{\"autotypenumbers\":\"strict\",\"colorway\":[\"#636efa\",\"#EF553B\",\"#00cc96\",\"#ab63fa\",\"#FFA15A\",\"#19d3f3\",\"#FF6692\",\"#B6E880\",\"#FF97FF\",\"#FECB52\"],\"font\":{\"color\":\"#2a3f5f\"},\"hovermode\":\"closest\",\"hoverlabel\":{\"align\":\"left\"},\"paper_bgcolor\":\"white\",\"plot_bgcolor\":\"#E5ECF6\",\"polar\":{\"bgcolor\":\"#E5ECF6\",\"angularaxis\":{\"gridcolor\":\"white\",\"linecolor\":\"white\",\"ticks\":\"\"},\"radialaxis\":{\"gridcolor\":\"white\",\"linecolor\":\"white\",\"ticks\":\"\"}},\"ternary\":{\"bgcolor\":\"#E5ECF6\",\"aaxis\":{\"gridcolor\":\"white\",\"linecolor\":\"white\",\"ticks\":\"\"},\"baxis\":{\"gridcolor\":\"white\",\"linecolor\":\"white\",\"ticks\":\"\"},\"caxis\":{\"gridcolor\":\"white\",\"linecolor\":\"white\",\"ticks\":\"\"}},\"coloraxis\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}},\"colorscale\":{\"sequential\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]],\"sequentialminus\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]],\"diverging\":[[0,\"#8e0152\"],[0.1,\"#c51b7d\"],[0.2,\"#de77ae\"],[0.3,\"#f1b6da\"],[0.4,\"#fde0ef\"],[0.5,\"#f7f7f7\"],[0.6,\"#e6f5d0\"],[0.7,\"#b8e186\"],[0.8,\"#7fbc41\"],[0.9,\"#4d9221\"],[1,\"#276419\"]]},\"xaxis\":{\"gridcolor\":\"white\",\"linecolor\":\"white\",\"ticks\":\"\",\"title\":{\"standoff\":15},\"zerolinecolor\":\"white\",\"automargin\":true,\"zerolinewidth\":2},\"yaxis\":{\"gridcolor\":\"white\",\"linecolor\":\"white\",\"ticks\":\"\",\"title\":{\"standoff\":15},\"zerolinecolor\":\"white\",\"automargin\":true,\"zerolinewidth\":2},\"scene\":{\"xaxis\":{\"backgroundcolor\":\"#E5ECF6\",\"gridcolor\":\"white\",\"linecolor\":\"white\",\"showbackground\":true,\"ticks\":\"\",\"zerolinecolor\":\"white\",\"gridwidth\":2},\"yaxis\":{\"backgroundcolor\":\"#E5ECF6\",\"gridcolor\":\"white\",\"linecolor\":\"white\",\"showbackground\":true,\"ticks\":\"\",\"zerolinecolor\":\"white\",\"gridwidth\":2},\"zaxis\":{\"backgroundcolor\":\"#E5ECF6\",\"gridcolor\":\"white\",\"linecolor\":\"white\",\"showbackground\":true,\"ticks\":\"\",\"zerolinecolor\":\"white\",\"gridwidth\":2}},\"shapedefaults\":{\"line\":{\"color\":\"#2a3f5f\"}},\"annotationdefaults\":{\"arrowcolor\":\"#2a3f5f\",\"arrowhead\":0,\"arrowwidth\":1},\"geo\":{\"bgcolor\":\"white\",\"landcolor\":\"#E5ECF6\",\"subunitcolor\":\"white\",\"showland\":true,\"showlakes\":true,\"lakecolor\":\"white\"},\"title\":{\"x\":0.05},\"mapbox\":{\"style\":\"light\"}}},\"xaxis\":{\"anchor\":\"y\",\"domain\":[0.0,1.0],\"title\":{\"text\":\"出現割合\"}},\"yaxis\":{\"anchor\":\"x\",\"domain\":[0.0,1.0],\"title\":{\"text\":\"授業一覧\"}},\"legend\":{\"title\":{\"text\":\"row_idx\"},\"tracegroupgap\":0},\"title\":{\"text\":\"授業別高頻度単語(top_n=20)の内訳（割合）\"},\"barmode\":\"stack\"},                        {\"responsive\": true}                    ).then(function(){\n",
              "                            \n",
              "var gd = document.getElementById('4291f4f1-4126-40b1-a478-a14a9c3f2696');\n",
              "var x = new MutationObserver(function (mutations, observer) {{\n",
              "        var display = window.getComputedStyle(gd).display;\n",
              "        if (!display || display === 'none') {{\n",
              "            console.log([gd, 'removed!']);\n",
              "            Plotly.purge(gd);\n",
              "            observer.disconnect();\n",
              "        }}\n",
              "}});\n",
              "\n",
              "// Listen for the removal of the full notebook cells\n",
              "var notebookContainer = gd.closest('#notebook-container');\n",
              "if (notebookContainer) {{\n",
              "    x.observe(notebookContainer, {childList: true});\n",
              "}}\n",
              "\n",
              "// Listen for the clearing of the current output cell\n",
              "var outputEl = gd.closest('.output');\n",
              "if (outputEl) {{\n",
              "    x.observe(outputEl, {childList: true});\n",
              "}}\n",
              "\n",
              "                        })                };                            </script>        </div>\n",
              "</body>\n",
              "</html>"
            ]
          },
          "metadata": {}
        }
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "o0nKbTZcNYOs"
      },
      "source": [
        "#### 積み上げ棒グラフ（横＋正規化＋色調整）\n",
        "一部の色が被っていて誤解してしまう。標準では10色までしか用意されておらず、使い終えると再び同じ色が利用されるようだ。これを避けるために[カラースケール](https://plotly.com/python/builtin-colorscales/)を指定して色重複されないようにしよう。"
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "import plotly.express as px\n",
        "\n",
        "# もとの正規化処理（変更なし）\n",
        "normalize_df = df_title_vs_word.div(df_title_vs_word.sum(axis=0), axis=1)\n",
        "\n",
        "# Plotly で積み上げ横棒グラフを作るために melt で縦長形式に変換\n",
        "df_melted = normalize_df.copy().T.reset_index()\n",
        "df_melted = df_melted.melt(\n",
        "    id_vars='index',      # 横軸が数値、縦軸(y)がこのカテゴリ\n",
        "    var_name='row_idx',   # 積み上げの区分（色分け）\n",
        "    value_name='value'    # バーの長さ\n",
        ")\n",
        "\n",
        "# Dark24 カラーマップから最初の20色を利用\n",
        "colors_20 = px.colors.qualitative.Dark24[:20]\n",
        "\n",
        "fig = px.bar(\n",
        "    df_melted,\n",
        "    x='value',\n",
        "    y='index',\n",
        "    color='row_idx',\n",
        "    orientation='h',\n",
        "    barmode='stack',\n",
        "    text='row_idx',\n",
        "    color_discrete_sequence=colors_20,  # ここで20色を指定\n",
        "    title=f'授業別高頻度単語(top_n={top_n})の内訳（割合）'\n",
        ")\n",
        "\n",
        "fig.update_traces(\n",
        "    textposition='inside',\n",
        "    textfont_size=20\n",
        ")\n",
        "\n",
        "fig.update_layout(\n",
        "    xaxis_title='出現割合',\n",
        "    yaxis_title='授業一覧'\n",
        ")\n",
        "\n",
        "fig.show()\n"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 542
        },
        "id": "HVSOlPzBzh-W",
        "outputId": "b86d8d1c-cc77-4e48-85f8-3631624c2569"
      },
      "execution_count": 17,
      "outputs": [
        {
          "output_type": "display_data",
          "data": {
            "text/html": [
              "<html>\n",
              "<head><meta charset=\"utf-8\" /></head>\n",
              "<body>\n",
              "    <div>            <script src=\"https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_SVG\"></script><script type=\"text/javascript\">if (window.MathJax && window.MathJax.Hub && window.MathJax.Hub.Config) {window.MathJax.Hub.Config({SVG: {font: \"STIX-Web\"}});}</script>                <script type=\"text/javascript\">window.PlotlyConfig = {MathJaxConfig: 'local'};</script>\n",
              "        <script charset=\"utf-8\" src=\"https://cdn.plot.ly/plotly-2.35.2.min.js\"></script>                <div id=\"9fe96259-b6eb-44e9-bf29-c6bf067f2c7d\" class=\"plotly-graph-div\" style=\"height:525px; width:100%;\"></div>            <script type=\"text/javascript\">                                    window.PLOTLYENV=window.PLOTLYENV || {};                                    if (document.getElementById(\"9fe96259-b6eb-44e9-bf29-c6bf067f2c7d\")) {                    Plotly.newPlot(                        \"9fe96259-b6eb-44e9-bf29-c6bf067f2c7d\",                        [{\"alignmentgroup\":\"True\",\"hovertemplate\":\"row_idx=%{text}\\u003cbr\\u003evalue=%{x}\\u003cbr\\u003eindex=%{y}\\u003cextra\\u003e\\u003c\\u002fextra\\u003e\",\"legendgroup\":\"授業\",\"marker\":{\"color\":\"#2E91E5\",\"pattern\":{\"shape\":\"\"}},\"name\":\"授業\",\"offsetgroup\":\"授業\",\"orientation\":\"h\",\"showlegend\":true,\"text\":[\"授業\",\"授業\",\"授業\",\"授業\",\"授業\",\"授業\",\"授業\",\"授業\",\"授業\",\"授業\",\"授業\",\"授業\",\"授業\",\"授業\",\"授業\",\"授業\"],\"textposition\":\"inside\",\"x\":[0.25,0.2,0.2,0.0,0.08333333333333333,0.1,0.08333333333333333,0.11377245508982035,0.11764705882352941,0.3333333333333333,0.1,0.29411764705882354,0.0,0.0,null,0.5],\"xaxis\":\"x\",\"y\":[\"工業数学Ⅰ\",\"技術者の倫理\",\"工学基礎演習\",\"プログラミングⅠ\",\"プログラミング演習Ⅰ\",\"アルゴリズムとデータ構造\",\"情報ネットワークⅠ\",\"コンピュータシステム\",\"データサイエンス基礎\",\"ディジタル回路\",\"情報処理技術概論\",\"プロジェクトデザイン\",\"キャリアデザイン\",\"データマイニング\",\"ICT実践英語Ⅰ\",\"知能情報実験Ⅲ\"],\"yaxis\":\"y\",\"type\":\"bar\",\"textfont\":{\"size\":20}},{\"alignmentgroup\":\"True\",\"hovertemplate\":\"row_idx=%{text}\\u003cbr\\u003evalue=%{x}\\u003cbr\\u003eindex=%{y}\\u003cextra\\u003e\\u003c\\u002fextra\\u003e\",\"legendgroup\":\"課題\",\"marker\":{\"color\":\"#E15F99\",\"pattern\":{\"shape\":\"\"}},\"name\":\"課題\",\"offsetgroup\":\"課題\",\"orientation\":\"h\",\"showlegend\":true,\"text\":[\"課題\",\"課題\",\"課題\",\"課題\",\"課題\",\"課題\",\"課題\",\"課題\",\"課題\",\"課題\",\"課題\",\"課題\",\"課題\",\"課題\",\"課題\",\"課題\"],\"textposition\":\"inside\",\"x\":[0.16666666666666666,0.0,0.0,0.3333333333333333,0.25,0.0,0.0,0.1377245508982036,0.08823529411764706,0.0,0.0,0.058823529411764705,0.0,1.0,null,0.0],\"xaxis\":\"x\",\"y\":[\"工業数学Ⅰ\",\"技術者の倫理\",\"工学基礎演習\",\"プログラミングⅠ\",\"プログラミング演習Ⅰ\",\"アルゴリズムとデータ構造\",\"情報ネットワークⅠ\",\"コンピュータシステム\",\"データサイエンス基礎\",\"ディジタル回路\",\"情報処理技術概論\",\"プロジェクトデザイン\",\"キャリアデザイン\",\"データマイニング\",\"ICT実践英語Ⅰ\",\"知能情報実験Ⅲ\"],\"yaxis\":\"y\",\"type\":\"bar\",\"textfont\":{\"size\":20}},{\"alignmentgroup\":\"True\",\"hovertemplate\":\"row_idx=%{text}\\u003cbr\\u003evalue=%{x}\\u003cbr\\u003eindex=%{y}\\u003cextra\\u003e\\u003c\\u002fextra\\u003e\",\"legendgroup\":\"試験\",\"marker\":{\"color\":\"#1CA71C\",\"pattern\":{\"shape\":\"\"}},\"name\":\"試験\",\"offsetgroup\":\"試験\",\"orientation\":\"h\",\"showlegend\":true,\"text\":[\"試験\",\"試験\",\"試験\",\"試験\",\"試験\",\"試験\",\"試験\",\"試験\",\"試験\",\"試験\",\"試験\",\"試験\",\"試験\",\"試験\",\"試験\",\"試験\"],\"textposition\":\"inside\",\"x\":[0.0,0.0,0.0,0.0,0.0,0.15,0.0,0.17365269461077845,0.11764705882352941,0.0,0.1,0.0,0.0,0.0,null,0.0],\"xaxis\":\"x\",\"y\":[\"工業数学Ⅰ\",\"技術者の倫理\",\"工学基礎演習\",\"プログラミングⅠ\",\"プログラミング演習Ⅰ\",\"アルゴリズムとデータ構造\",\"情報ネットワークⅠ\",\"コンピュータシステム\",\"データサイエンス基礎\",\"ディジタル回路\",\"情報処理技術概論\",\"プロジェクトデザイン\",\"キャリアデザイン\",\"データマイニング\",\"ICT実践英語Ⅰ\",\"知能情報実験Ⅲ\"],\"yaxis\":\"y\",\"type\":\"bar\",\"textfont\":{\"size\":20}},{\"alignmentgroup\":\"True\",\"hovertemplate\":\"row_idx=%{text}\\u003cbr\\u003evalue=%{x}\\u003cbr\\u003eindex=%{y}\\u003cextra\\u003e\\u003c\\u002fextra\\u003e\",\"legendgroup\":\"内容\",\"marker\":{\"color\":\"#FB0D0D\",\"pattern\":{\"shape\":\"\"}},\"name\":\"内容\",\"offsetgroup\":\"内容\",\"orientation\":\"h\",\"showlegend\":true,\"text\":[\"内容\",\"内容\",\"内容\",\"内容\",\"内容\",\"内容\",\"内容\",\"内容\",\"内容\",\"内容\",\"内容\",\"内容\",\"内容\",\"内容\",\"内容\",\"内容\"],\"textposition\":\"inside\",\"x\":[0.0,0.13333333333333333,0.0,0.05555555555555555,0.0,0.1,0.0,0.0718562874251497,0.11764705882352941,0.0,0.0,0.058823529411764705,0.0,0.0,null,0.0],\"xaxis\":\"x\",\"y\":[\"工業数学Ⅰ\",\"技術者の倫理\",\"工学基礎演習\",\"プログラミングⅠ\",\"プログラミング演習Ⅰ\",\"アルゴリズムとデータ構造\",\"情報ネットワークⅠ\",\"コンピュータシステム\",\"データサイエンス基礎\",\"ディジタル回路\",\"情報処理技術概論\",\"プロジェクトデザイン\",\"キャリアデザイン\",\"データマイニング\",\"ICT実践英語Ⅰ\",\"知能情報実験Ⅲ\"],\"yaxis\":\"y\",\"type\":\"bar\",\"textfont\":{\"size\":20}},{\"alignmentgroup\":\"True\",\"hovertemplate\":\"row_idx=%{text}\\u003cbr\\u003evalue=%{x}\\u003cbr\\u003eindex=%{y}\\u003cextra\\u003e\\u003c\\u002fextra\\u003e\",\"legendgroup\":\"問題\",\"marker\":{\"color\":\"#DA16FF\",\"pattern\":{\"shape\":\"\"}},\"name\":\"問題\",\"offsetgroup\":\"問題\",\"orientation\":\"h\",\"showlegend\":true,\"text\":[\"問題\",\"問題\",\"問題\",\"問題\",\"問題\",\"問題\",\"問題\",\"問題\",\"問題\",\"問題\",\"問題\",\"問題\",\"問題\",\"問題\",\"問題\",\"問題\"],\"textposition\":\"inside\",\"x\":[0.08333333333333333,0.0,0.0,0.0,0.0,0.2,0.0,0.0718562874251497,0.058823529411764705,0.0,0.05,0.0,0.0,0.0,null,0.0],\"xaxis\":\"x\",\"y\":[\"工業数学Ⅰ\",\"技術者の倫理\",\"工学基礎演習\",\"プログラミングⅠ\",\"プログラミング演習Ⅰ\",\"アルゴリズムとデータ構造\",\"情報ネットワークⅠ\",\"コンピュータシステム\",\"データサイエンス基礎\",\"ディジタル回路\",\"情報処理技術概論\",\"プロジェクトデザイン\",\"キャリアデザイン\",\"データマイニング\",\"ICT実践英語Ⅰ\",\"知能情報実験Ⅲ\"],\"yaxis\":\"y\",\"type\":\"bar\",\"textfont\":{\"size\":20}},{\"alignmentgroup\":\"True\",\"hovertemplate\":\"row_idx=%{text}\\u003cbr\\u003evalue=%{x}\\u003cbr\\u003eindex=%{y}\\u003cextra\\u003e\\u003c\\u002fextra\\u003e\",\"legendgroup\":\"説明\",\"marker\":{\"color\":\"#222A2A\",\"pattern\":{\"shape\":\"\"}},\"name\":\"説明\",\"offsetgroup\":\"説明\",\"orientation\":\"h\",\"showlegend\":true,\"text\":[\"説明\",\"説明\",\"説明\",\"説明\",\"説明\",\"説明\",\"説明\",\"説明\",\"説明\",\"説明\",\"説明\",\"説明\",\"説明\",\"説明\",\"説明\",\"説明\"],\"textposition\":\"inside\",\"x\":[0.16666666666666666,0.0,0.0,0.1111111111111111,0.0,0.15,0.0,0.041916167664670656,0.058823529411764705,0.3333333333333333,0.05,0.0,0.0,0.0,null,0.5],\"xaxis\":\"x\",\"y\":[\"工業数学Ⅰ\",\"技術者の倫理\",\"工学基礎演習\",\"プログラミングⅠ\",\"プログラミング演習Ⅰ\",\"アルゴリズムとデータ構造\",\"情報ネットワークⅠ\",\"コンピュータシステム\",\"データサイエンス基礎\",\"ディジタル回路\",\"情報処理技術概論\",\"プロジェクトデザイン\",\"キャリアデザイン\",\"データマイニング\",\"ICT実践英語Ⅰ\",\"知能情報実験Ⅲ\"],\"yaxis\":\"y\",\"type\":\"bar\",\"textfont\":{\"size\":20}},{\"alignmentgroup\":\"True\",\"hovertemplate\":\"row_idx=%{text}\\u003cbr\\u003evalue=%{x}\\u003cbr\\u003eindex=%{y}\\u003cextra\\u003e\\u003c\\u002fextra\\u003e\",\"legendgroup\":\"なし\",\"marker\":{\"color\":\"#B68100\",\"pattern\":{\"shape\":\"\"}},\"name\":\"なし\",\"offsetgroup\":\"なし\",\"orientation\":\"h\",\"showlegend\":true,\"text\":[\"なし\",\"なし\",\"なし\",\"なし\",\"なし\",\"なし\",\"なし\",\"なし\",\"なし\",\"なし\",\"なし\",\"なし\",\"なし\",\"なし\",\"なし\",\"なし\"],\"textposition\":\"inside\",\"x\":[0.25,0.26666666666666666,0.4,0.2222222222222222,0.25,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,null,0.0],\"xaxis\":\"x\",\"y\":[\"工業数学Ⅰ\",\"技術者の倫理\",\"工学基礎演習\",\"プログラミングⅠ\",\"プログラミング演習Ⅰ\",\"アルゴリズムとデータ構造\",\"情報ネットワークⅠ\",\"コンピュータシステム\",\"データサイエンス基礎\",\"ディジタル回路\",\"情報処理技術概論\",\"プロジェクトデザイン\",\"キャリアデザイン\",\"データマイニング\",\"ICT実践英語Ⅰ\",\"知能情報実験Ⅲ\"],\"yaxis\":\"y\",\"type\":\"bar\",\"textfont\":{\"size\":20}},{\"alignmentgroup\":\"True\",\"hovertemplate\":\"row_idx=%{text}\\u003cbr\\u003evalue=%{x}\\u003cbr\\u003eindex=%{y}\\u003cextra\\u003e\\u003c\\u002fextra\\u003e\",\"legendgroup\":\"資料\",\"marker\":{\"color\":\"#750D86\",\"pattern\":{\"shape\":\"\"}},\"name\":\"資料\",\"offsetgroup\":\"資料\",\"orientation\":\"h\",\"showlegend\":true,\"text\":[\"資料\",\"資料\",\"資料\",\"資料\",\"資料\",\"資料\",\"資料\",\"資料\",\"資料\",\"資料\",\"資料\",\"資料\",\"資料\",\"資料\",\"資料\",\"資料\"],\"textposition\":\"inside\",\"x\":[0.0,0.0,0.0,0.0,0.0,0.15,0.08333333333333333,0.04790419161676647,0.0,0.3333333333333333,0.1,0.058823529411764705,0.0,0.0,null,0.0],\"xaxis\":\"x\",\"y\":[\"工業数学Ⅰ\",\"技術者の倫理\",\"工学基礎演習\",\"プログラミングⅠ\",\"プログラミング演習Ⅰ\",\"アルゴリズムとデータ構造\",\"情報ネットワークⅠ\",\"コンピュータシステム\",\"データサイエンス基礎\",\"ディジタル回路\",\"情報処理技術概論\",\"プロジェクトデザイン\",\"キャリアデザイン\",\"データマイニング\",\"ICT実践英語Ⅰ\",\"知能情報実験Ⅲ\"],\"yaxis\":\"y\",\"type\":\"bar\",\"textfont\":{\"size\":20}},{\"alignmentgroup\":\"True\",\"hovertemplate\":\"row_idx=%{text}\\u003cbr\\u003evalue=%{x}\\u003cbr\\u003eindex=%{y}\\u003cextra\\u003e\\u003c\\u002fextra\\u003e\",\"legendgroup\":\"先生\",\"marker\":{\"color\":\"#EB663B\",\"pattern\":{\"shape\":\"\"}},\"name\":\"先生\",\"offsetgroup\":\"先生\",\"orientation\":\"h\",\"showlegend\":true,\"text\":[\"先生\",\"先生\",\"先生\",\"先生\",\"先生\",\"先生\",\"先生\",\"先生\",\"先生\",\"先生\",\"先生\",\"先生\",\"先生\",\"先生\",\"先生\",\"先生\"],\"textposition\":\"inside\",\"x\":[0.0,0.2,0.0,0.05555555555555555,0.0,0.05,0.0,0.03592814371257485,0.058823529411764705,0.0,0.05,0.0,1.0,0.0,null,0.0],\"xaxis\":\"x\",\"y\":[\"工業数学Ⅰ\",\"技術者の倫理\",\"工学基礎演習\",\"プログラミングⅠ\",\"プログラミング演習Ⅰ\",\"アルゴリズムとデータ構造\",\"情報ネットワークⅠ\",\"コンピュータシステム\",\"データサイエンス基礎\",\"ディジタル回路\",\"情報処理技術概論\",\"プロジェクトデザイン\",\"キャリアデザイン\",\"データマイニング\",\"ICT実践英語Ⅰ\",\"知能情報実験Ⅲ\"],\"yaxis\":\"y\",\"type\":\"bar\",\"textfont\":{\"size\":20}},{\"alignmentgroup\":\"True\",\"hovertemplate\":\"row_idx=%{text}\\u003cbr\\u003evalue=%{x}\\u003cbr\\u003eindex=%{y}\\u003cextra\\u003e\\u003c\\u002fextra\\u003e\",\"legendgroup\":\"お\",\"marker\":{\"color\":\"#511CFB\",\"pattern\":{\"shape\":\"\"}},\"name\":\"お\",\"offsetgroup\":\"お\",\"orientation\":\"h\",\"showlegend\":true,\"text\":[\"お\",\"お\",\"お\",\"お\",\"お\",\"お\",\"お\",\"お\",\"お\",\"お\",\"お\",\"お\",\"お\",\"お\",\"お\",\"お\"],\"textposition\":\"inside\",\"x\":[0.08333333333333333,0.13333333333333333,0.0,0.1111111111111111,0.08333333333333333,0.0,0.25,0.023952095808383235,0.029411764705882353,0.0,0.0,0.0,0.0,0.0,null,0.0],\"xaxis\":\"x\",\"y\":[\"工業数学Ⅰ\",\"技術者の倫理\",\"工学基礎演習\",\"プログラミングⅠ\",\"プログラミング演習Ⅰ\",\"アルゴリズムとデータ構造\",\"情報ネットワークⅠ\",\"コンピュータシステム\",\"データサイエンス基礎\",\"ディジタル回路\",\"情報処理技術概論\",\"プロジェクトデザイン\",\"キャリアデザイン\",\"データマイニング\",\"ICT実践英語Ⅰ\",\"知能情報実験Ⅲ\"],\"yaxis\":\"y\",\"type\":\"bar\",\"textfont\":{\"size\":20}},{\"alignmentgroup\":\"True\",\"hovertemplate\":\"row_idx=%{text}\\u003cbr\\u003evalue=%{x}\\u003cbr\\u003eindex=%{y}\\u003cextra\\u003e\\u003c\\u002fextra\\u003e\",\"legendgroup\":\"難易度\",\"marker\":{\"color\":\"#00A08B\",\"pattern\":{\"shape\":\"\"}},\"name\":\"難易度\",\"offsetgroup\":\"難易度\",\"orientation\":\"h\",\"showlegend\":true,\"text\":[\"難易度\",\"難易度\",\"難易度\",\"難易度\",\"難易度\",\"難易度\",\"難易度\",\"難易度\",\"難易度\",\"難易度\",\"難易度\",\"難易度\",\"難易度\",\"難易度\",\"難易度\",\"難易度\"],\"textposition\":\"inside\",\"x\":[0.0,0.0,0.0,0.05555555555555555,0.0,0.0,0.0,0.04790419161676647,0.058823529411764705,0.0,0.05,0.0,0.0,0.0,null,0.0],\"xaxis\":\"x\",\"y\":[\"工業数学Ⅰ\",\"技術者の倫理\",\"工学基礎演習\",\"プログラミングⅠ\",\"プログラミング演習Ⅰ\",\"アルゴリズムとデータ構造\",\"情報ネットワークⅠ\",\"コンピュータシステム\",\"データサイエンス基礎\",\"ディジタル回路\",\"情報処理技術概論\",\"プロジェクトデザイン\",\"キャリアデザイン\",\"データマイニング\",\"ICT実践英語Ⅰ\",\"知能情報実験Ⅲ\"],\"yaxis\":\"y\",\"type\":\"bar\",\"textfont\":{\"size\":20}},{\"alignmentgroup\":\"True\",\"hovertemplate\":\"row_idx=%{text}\\u003cbr\\u003evalue=%{x}\\u003cbr\\u003eindex=%{y}\\u003cextra\\u003e\\u003c\\u002fextra\\u003e\",\"legendgroup\":\"解答\",\"marker\":{\"color\":\"#FB00D1\",\"pattern\":{\"shape\":\"\"}},\"name\":\"解答\",\"offsetgroup\":\"解答\",\"orientation\":\"h\",\"showlegend\":true,\"text\":[\"解答\",\"解答\",\"解答\",\"解答\",\"解答\",\"解答\",\"解答\",\"解答\",\"解答\",\"解答\",\"解答\",\"解答\",\"解答\",\"解答\",\"解答\",\"解答\"],\"textposition\":\"inside\",\"x\":[0.0,0.0,0.0,0.0,0.08333333333333333,0.0,0.0,0.041916167664670656,0.08823529411764706,0.0,0.0,0.0,0.0,0.0,null,0.0],\"xaxis\":\"x\",\"y\":[\"工業数学Ⅰ\",\"技術者の倫理\",\"工学基礎演習\",\"プログラミングⅠ\",\"プログラミング演習Ⅰ\",\"アルゴリズムとデータ構造\",\"情報ネットワークⅠ\",\"コンピュータシステム\",\"データサイエンス基礎\",\"ディジタル回路\",\"情報処理技術概論\",\"プロジェクトデザイン\",\"キャリアデザイン\",\"データマイニング\",\"ICT実践英語Ⅰ\",\"知能情報実験Ⅲ\"],\"yaxis\":\"y\",\"type\":\"bar\",\"textfont\":{\"size\":20}},{\"alignmentgroup\":\"True\",\"hovertemplate\":\"row_idx=%{text}\\u003cbr\\u003evalue=%{x}\\u003cbr\\u003eindex=%{y}\\u003cextra\\u003e\\u003c\\u002fextra\\u003e\",\"legendgroup\":\"実際\",\"marker\":{\"color\":\"#FC0080\",\"pattern\":{\"shape\":\"\"}},\"name\":\"実際\",\"offsetgroup\":\"実際\",\"orientation\":\"h\",\"showlegend\":true,\"text\":[\"実際\",\"実際\",\"実際\",\"実際\",\"実際\",\"実際\",\"実際\",\"実際\",\"実際\",\"実際\",\"実際\",\"実際\",\"実際\",\"実際\",\"実際\",\"実際\"],\"textposition\":\"inside\",\"x\":[0.0,0.0,0.0,0.0,0.08333333333333333,0.0,0.08333333333333333,0.017964071856287425,0.029411764705882353,0.0,0.15,0.11764705882352941,0.0,0.0,null,0.0],\"xaxis\":\"x\",\"y\":[\"工業数学Ⅰ\",\"技術者の倫理\",\"工学基礎演習\",\"プログラミングⅠ\",\"プログラミング演習Ⅰ\",\"アルゴリズムとデータ構造\",\"情報ネットワークⅠ\",\"コンピュータシステム\",\"データサイエンス基礎\",\"ディジタル回路\",\"情報処理技術概論\",\"プロジェクトデザイン\",\"キャリアデザイン\",\"データマイニング\",\"ICT実践英語Ⅰ\",\"知能情報実験Ⅲ\"],\"yaxis\":\"y\",\"type\":\"bar\",\"textfont\":{\"size\":20}},{\"alignmentgroup\":\"True\",\"hovertemplate\":\"row_idx=%{text}\\u003cbr\\u003evalue=%{x}\\u003cbr\\u003eindex=%{y}\\u003cextra\\u003e\\u003c\\u002fextra\\u003e\",\"legendgroup\":\"方\",\"marker\":{\"color\":\"#B2828D\",\"pattern\":{\"shape\":\"\"}},\"name\":\"方\",\"offsetgroup\":\"方\",\"orientation\":\"h\",\"showlegend\":true,\"text\":[\"方\",\"方\",\"方\",\"方\",\"方\",\"方\",\"方\",\"方\",\"方\",\"方\",\"方\",\"方\",\"方\",\"方\",\"方\",\"方\"],\"textposition\":\"inside\",\"x\":[0.0,0.0,0.1,0.0,0.08333333333333333,0.0,0.16666666666666666,0.0,0.058823529411764705,0.0,0.1,0.11764705882352941,0.0,0.0,null,0.0],\"xaxis\":\"x\",\"y\":[\"工業数学Ⅰ\",\"技術者の倫理\",\"工学基礎演習\",\"プログラミングⅠ\",\"プログラミング演習Ⅰ\",\"アルゴリズムとデータ構造\",\"情報ネットワークⅠ\",\"コンピュータシステム\",\"データサイエンス基礎\",\"ディジタル回路\",\"情報処理技術概論\",\"プロジェクトデザイン\",\"キャリアデザイン\",\"データマイニング\",\"ICT実践英語Ⅰ\",\"知能情報実験Ⅲ\"],\"yaxis\":\"y\",\"type\":\"bar\",\"textfont\":{\"size\":20}},{\"alignmentgroup\":\"True\",\"hovertemplate\":\"row_idx=%{text}\\u003cbr\\u003evalue=%{x}\\u003cbr\\u003eindex=%{y}\\u003cextra\\u003e\\u003c\\u002fextra\\u003e\",\"legendgroup\":\"テスト\",\"marker\":{\"color\":\"#6C7C32\",\"pattern\":{\"shape\":\"\"}},\"name\":\"テスト\",\"offsetgroup\":\"テスト\",\"orientation\":\"h\",\"showlegend\":true,\"text\":[\"テスト\",\"テスト\",\"テスト\",\"テスト\",\"テスト\",\"テスト\",\"テスト\",\"テスト\",\"テスト\",\"テスト\",\"テスト\",\"テスト\",\"テスト\",\"テスト\",\"テスト\",\"テスト\"],\"textposition\":\"inside\",\"x\":[0.0,0.0,0.0,0.0,0.0,0.05,0.08333333333333333,0.03592814371257485,0.0,0.0,0.1,0.0,0.0,0.0,null,0.0],\"xaxis\":\"x\",\"y\":[\"工業数学Ⅰ\",\"技術者の倫理\",\"工学基礎演習\",\"プログラミングⅠ\",\"プログラミング演習Ⅰ\",\"アルゴリズムとデータ構造\",\"情報ネットワークⅠ\",\"コンピュータシステム\",\"データサイエンス基礎\",\"ディジタル回路\",\"情報処理技術概論\",\"プロジェクトデザイン\",\"キャリアデザイン\",\"データマイニング\",\"ICT実践英語Ⅰ\",\"知能情報実験Ⅲ\"],\"yaxis\":\"y\",\"type\":\"bar\",\"textfont\":{\"size\":20}},{\"alignmentgroup\":\"True\",\"hovertemplate\":\"row_idx=%{text}\\u003cbr\\u003evalue=%{x}\\u003cbr\\u003eindex=%{y}\\u003cextra\\u003e\\u003c\\u002fextra\\u003e\",\"legendgroup\":\"知識\",\"marker\":{\"color\":\"#778AAE\",\"pattern\":{\"shape\":\"\"}},\"name\":\"知識\",\"offsetgroup\":\"知識\",\"orientation\":\"h\",\"showlegend\":true,\"text\":[\"知識\",\"知識\",\"知識\",\"知識\",\"知識\",\"知識\",\"知識\",\"知識\",\"知識\",\"知識\",\"知識\",\"知識\",\"知識\",\"知識\",\"知識\",\"知識\"],\"textposition\":\"inside\",\"x\":[0.0,0.06666666666666667,0.0,0.05555555555555555,0.08333333333333333,0.0,0.0,0.011976047904191617,0.11764705882352941,0.0,0.0,0.0,0.0,0.0,null,0.0],\"xaxis\":\"x\",\"y\":[\"工業数学Ⅰ\",\"技術者の倫理\",\"工学基礎演習\",\"プログラミングⅠ\",\"プログラミング演習Ⅰ\",\"アルゴリズムとデータ構造\",\"情報ネットワークⅠ\",\"コンピュータシステム\",\"データサイエンス基礎\",\"ディジタル回路\",\"情報処理技術概論\",\"プロジェクトデザイン\",\"キャリアデザイン\",\"データマイニング\",\"ICT実践英語Ⅰ\",\"知能情報実験Ⅲ\"],\"yaxis\":\"y\",\"type\":\"bar\",\"textfont\":{\"size\":20}},{\"alignmentgroup\":\"True\",\"hovertemplate\":\"row_idx=%{text}\\u003cbr\\u003evalue=%{x}\\u003cbr\\u003eindex=%{y}\\u003cextra\\u003e\\u003c\\u002fextra\\u003e\",\"legendgroup\":\"機会\",\"marker\":{\"color\":\"#862A16\",\"pattern\":{\"shape\":\"\"}},\"name\":\"機会\",\"offsetgroup\":\"機会\",\"orientation\":\"h\",\"showlegend\":true,\"text\":[\"機会\",\"機会\",\"機会\",\"機会\",\"機会\",\"機会\",\"機会\",\"機会\",\"機会\",\"機会\",\"機会\",\"機会\",\"機会\",\"機会\",\"機会\",\"機会\"],\"textposition\":\"inside\",\"x\":[0.0,0.0,0.3,0.0,0.0,0.0,0.08333333333333333,0.0,0.0,0.0,0.0,0.29411764705882354,0.0,0.0,null,0.0],\"xaxis\":\"x\",\"y\":[\"工業数学Ⅰ\",\"技術者の倫理\",\"工学基礎演習\",\"プログラミングⅠ\",\"プログラミング演習Ⅰ\",\"アルゴリズムとデータ構造\",\"情報ネットワークⅠ\",\"コンピュータシステム\",\"データサイエンス基礎\",\"ディジタル回路\",\"情報処理技術概論\",\"プロジェクトデザイン\",\"キャリアデザイン\",\"データマイニング\",\"ICT実践英語Ⅰ\",\"知能情報実験Ⅲ\"],\"yaxis\":\"y\",\"type\":\"bar\",\"textfont\":{\"size\":20}},{\"alignmentgroup\":\"True\",\"hovertemplate\":\"row_idx=%{text}\\u003cbr\\u003evalue=%{x}\\u003cbr\\u003eindex=%{y}\\u003cextra\\u003e\\u003c\\u002fextra\\u003e\",\"legendgroup\":\"生徒\",\"marker\":{\"color\":\"#A777F1\",\"pattern\":{\"shape\":\"\"}},\"name\":\"生徒\",\"offsetgroup\":\"生徒\",\"orientation\":\"h\",\"showlegend\":true,\"text\":[\"生徒\",\"生徒\",\"生徒\",\"生徒\",\"生徒\",\"生徒\",\"生徒\",\"生徒\",\"生徒\",\"生徒\",\"生徒\",\"生徒\",\"生徒\",\"生徒\",\"生徒\",\"生徒\"],\"textposition\":\"inside\",\"x\":[0.0,0.0,0.0,0.0,0.0,0.05,0.0,0.04790419161676647,0.0,0.0,0.0,0.0,0.0,0.0,null,0.0],\"xaxis\":\"x\",\"y\":[\"工業数学Ⅰ\",\"技術者の倫理\",\"工学基礎演習\",\"プログラミングⅠ\",\"プログラミング演習Ⅰ\",\"アルゴリズムとデータ構造\",\"情報ネットワークⅠ\",\"コンピュータシステム\",\"データサイエンス基礎\",\"ディジタル回路\",\"情報処理技術概論\",\"プロジェクトデザイン\",\"キャリアデザイン\",\"データマイニング\",\"ICT実践英語Ⅰ\",\"知能情報実験Ⅲ\"],\"yaxis\":\"y\",\"type\":\"bar\",\"textfont\":{\"size\":20}},{\"alignmentgroup\":\"True\",\"hovertemplate\":\"row_idx=%{text}\\u003cbr\\u003evalue=%{x}\\u003cbr\\u003eindex=%{y}\\u003cextra\\u003e\\u003c\\u002fextra\\u003e\",\"legendgroup\":\"中間\",\"marker\":{\"color\":\"#620042\",\"pattern\":{\"shape\":\"\"}},\"name\":\"中間\",\"offsetgroup\":\"中間\",\"orientation\":\"h\",\"showlegend\":true,\"text\":[\"中間\",\"中間\",\"中間\",\"中間\",\"中間\",\"中間\",\"中間\",\"中間\",\"中間\",\"中間\",\"中間\",\"中間\",\"中間\",\"中間\",\"中間\",\"中間\"],\"textposition\":\"inside\",\"x\":[0.0,0.0,0.0,0.0,0.0,0.0,0.16666666666666666,0.041916167664670656,0.0,0.0,0.0,0.0,0.0,0.0,null,0.0],\"xaxis\":\"x\",\"y\":[\"工業数学Ⅰ\",\"技術者の倫理\",\"工学基礎演習\",\"プログラミングⅠ\",\"プログラミング演習Ⅰ\",\"アルゴリズムとデータ構造\",\"情報ネットワークⅠ\",\"コンピュータシステム\",\"データサイエンス基礎\",\"ディジタル回路\",\"情報処理技術概論\",\"プロジェクトデザイン\",\"キャリアデザイン\",\"データマイニング\",\"ICT実践英語Ⅰ\",\"知能情報実験Ⅲ\"],\"yaxis\":\"y\",\"type\":\"bar\",\"textfont\":{\"size\":20}},{\"alignmentgroup\":\"True\",\"hovertemplate\":\"row_idx=%{text}\\u003cbr\\u003evalue=%{x}\\u003cbr\\u003eindex=%{y}\\u003cextra\\u003e\\u003c\\u002fextra\\u003e\",\"legendgroup\":\"期末\",\"marker\":{\"color\":\"#1616A7\",\"pattern\":{\"shape\":\"\"}},\"name\":\"期末\",\"offsetgroup\":\"期末\",\"orientation\":\"h\",\"showlegend\":true,\"text\":[\"期末\",\"期末\",\"期末\",\"期末\",\"期末\",\"期末\",\"期末\",\"期末\",\"期末\",\"期末\",\"期末\",\"期末\",\"期末\",\"期末\",\"期末\",\"期末\"],\"textposition\":\"inside\",\"x\":[0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.03592814371257485,0.0,0.0,0.15,0.0,0.0,0.0,null,0.0],\"xaxis\":\"x\",\"y\":[\"工業数学Ⅰ\",\"技術者の倫理\",\"工学基礎演習\",\"プログラミングⅠ\",\"プログラミング演習Ⅰ\",\"アルゴリズムとデータ構造\",\"情報ネットワークⅠ\",\"コンピュータシステム\",\"データサイエンス基礎\",\"ディジタル回路\",\"情報処理技術概論\",\"プロジェクトデザイン\",\"キャリアデザイン\",\"データマイニング\",\"ICT実践英語Ⅰ\",\"知能情報実験Ⅲ\"],\"yaxis\":\"y\",\"type\":\"bar\",\"textfont\":{\"size\":20}}],                        {\"template\":{\"data\":{\"histogram2dcontour\":[{\"type\":\"histogram2dcontour\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"},\"colorscale\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]]}],\"choropleth\":[{\"type\":\"choropleth\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}],\"histogram2d\":[{\"type\":\"histogram2d\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"},\"colorscale\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]]}],\"heatmap\":[{\"type\":\"heatmap\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"},\"colorscale\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]]}],\"heatmapgl\":[{\"type\":\"heatmapgl\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"},\"colorscale\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]]}],\"contourcarpet\":[{\"type\":\"contourcarpet\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}],\"contour\":[{\"type\":\"contour\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"},\"colorscale\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]]}],\"surface\":[{\"type\":\"surface\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"},\"colorscale\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]]}],\"mesh3d\":[{\"type\":\"mesh3d\",\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}],\"scatter\":[{\"fillpattern\":{\"fillmode\":\"overlay\",\"size\":10,\"solidity\":0.2},\"type\":\"scatter\"}],\"parcoords\":[{\"type\":\"parcoords\",\"line\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"scatterpolargl\":[{\"type\":\"scatterpolargl\",\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"bar\":[{\"error_x\":{\"color\":\"#2a3f5f\"},\"error_y\":{\"color\":\"#2a3f5f\"},\"marker\":{\"line\":{\"color\":\"#E5ECF6\",\"width\":0.5},\"pattern\":{\"fillmode\":\"overlay\",\"size\":10,\"solidity\":0.2}},\"type\":\"bar\"}],\"scattergeo\":[{\"type\":\"scattergeo\",\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"scatterpolar\":[{\"type\":\"scatterpolar\",\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"histogram\":[{\"marker\":{\"pattern\":{\"fillmode\":\"overlay\",\"size\":10,\"solidity\":0.2}},\"type\":\"histogram\"}],\"scattergl\":[{\"type\":\"scattergl\",\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"scatter3d\":[{\"type\":\"scatter3d\",\"line\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}},\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"scattermapbox\":[{\"type\":\"scattermapbox\",\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"scatterternary\":[{\"type\":\"scatterternary\",\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"scattercarpet\":[{\"type\":\"scattercarpet\",\"marker\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}}}],\"carpet\":[{\"aaxis\":{\"endlinecolor\":\"#2a3f5f\",\"gridcolor\":\"white\",\"linecolor\":\"white\",\"minorgridcolor\":\"white\",\"startlinecolor\":\"#2a3f5f\"},\"baxis\":{\"endlinecolor\":\"#2a3f5f\",\"gridcolor\":\"white\",\"linecolor\":\"white\",\"minorgridcolor\":\"white\",\"startlinecolor\":\"#2a3f5f\"},\"type\":\"carpet\"}],\"table\":[{\"cells\":{\"fill\":{\"color\":\"#EBF0F8\"},\"line\":{\"color\":\"white\"}},\"header\":{\"fill\":{\"color\":\"#C8D4E3\"},\"line\":{\"color\":\"white\"}},\"type\":\"table\"}],\"barpolar\":[{\"marker\":{\"line\":{\"color\":\"#E5ECF6\",\"width\":0.5},\"pattern\":{\"fillmode\":\"overlay\",\"size\":10,\"solidity\":0.2}},\"type\":\"barpolar\"}],\"pie\":[{\"automargin\":true,\"type\":\"pie\"}]},\"layout\":{\"autotypenumbers\":\"strict\",\"colorway\":[\"#636efa\",\"#EF553B\",\"#00cc96\",\"#ab63fa\",\"#FFA15A\",\"#19d3f3\",\"#FF6692\",\"#B6E880\",\"#FF97FF\",\"#FECB52\"],\"font\":{\"color\":\"#2a3f5f\"},\"hovermode\":\"closest\",\"hoverlabel\":{\"align\":\"left\"},\"paper_bgcolor\":\"white\",\"plot_bgcolor\":\"#E5ECF6\",\"polar\":{\"bgcolor\":\"#E5ECF6\",\"angularaxis\":{\"gridcolor\":\"white\",\"linecolor\":\"white\",\"ticks\":\"\"},\"radialaxis\":{\"gridcolor\":\"white\",\"linecolor\":\"white\",\"ticks\":\"\"}},\"ternary\":{\"bgcolor\":\"#E5ECF6\",\"aaxis\":{\"gridcolor\":\"white\",\"linecolor\":\"white\",\"ticks\":\"\"},\"baxis\":{\"gridcolor\":\"white\",\"linecolor\":\"white\",\"ticks\":\"\"},\"caxis\":{\"gridcolor\":\"white\",\"linecolor\":\"white\",\"ticks\":\"\"}},\"coloraxis\":{\"colorbar\":{\"outlinewidth\":0,\"ticks\":\"\"}},\"colorscale\":{\"sequential\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]],\"sequentialminus\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]],\"diverging\":[[0,\"#8e0152\"],[0.1,\"#c51b7d\"],[0.2,\"#de77ae\"],[0.3,\"#f1b6da\"],[0.4,\"#fde0ef\"],[0.5,\"#f7f7f7\"],[0.6,\"#e6f5d0\"],[0.7,\"#b8e186\"],[0.8,\"#7fbc41\"],[0.9,\"#4d9221\"],[1,\"#276419\"]]},\"xaxis\":{\"gridcolor\":\"white\",\"linecolor\":\"white\",\"ticks\":\"\",\"title\":{\"standoff\":15},\"zerolinecolor\":\"white\",\"automargin\":true,\"zerolinewidth\":2},\"yaxis\":{\"gridcolor\":\"white\",\"linecolor\":\"white\",\"ticks\":\"\",\"title\":{\"standoff\":15},\"zerolinecolor\":\"white\",\"automargin\":true,\"zerolinewidth\":2},\"scene\":{\"xaxis\":{\"backgroundcolor\":\"#E5ECF6\",\"gridcolor\":\"white\",\"linecolor\":\"white\",\"showbackground\":true,\"ticks\":\"\",\"zerolinecolor\":\"white\",\"gridwidth\":2},\"yaxis\":{\"backgroundcolor\":\"#E5ECF6\",\"gridcolor\":\"white\",\"linecolor\":\"white\",\"showbackground\":true,\"ticks\":\"\",\"zerolinecolor\":\"white\",\"gridwidth\":2},\"zaxis\":{\"backgroundcolor\":\"#E5ECF6\",\"gridcolor\":\"white\",\"linecolor\":\"white\",\"showbackground\":true,\"ticks\":\"\",\"zerolinecolor\":\"white\",\"gridwidth\":2}},\"shapedefaults\":{\"line\":{\"color\":\"#2a3f5f\"}},\"annotationdefaults\":{\"arrowcolor\":\"#2a3f5f\",\"arrowhead\":0,\"arrowwidth\":1},\"geo\":{\"bgcolor\":\"white\",\"landcolor\":\"#E5ECF6\",\"subunitcolor\":\"white\",\"showland\":true,\"showlakes\":true,\"lakecolor\":\"white\"},\"title\":{\"x\":0.05},\"mapbox\":{\"style\":\"light\"}}},\"xaxis\":{\"anchor\":\"y\",\"domain\":[0.0,1.0],\"title\":{\"text\":\"出現割合\"}},\"yaxis\":{\"anchor\":\"x\",\"domain\":[0.0,1.0],\"title\":{\"text\":\"授業一覧\"}},\"legend\":{\"title\":{\"text\":\"row_idx\"},\"tracegroupgap\":0},\"title\":{\"text\":\"授業別高頻度単語(top_n=20)の内訳（割合）\"},\"barmode\":\"stack\"},                        {\"responsive\": true}                    ).then(function(){\n",
              "                            \n",
              "var gd = document.getElementById('9fe96259-b6eb-44e9-bf29-c6bf067f2c7d');\n",
              "var x = new MutationObserver(function (mutations, observer) {{\n",
              "        var display = window.getComputedStyle(gd).display;\n",
              "        if (!display || display === 'none') {{\n",
              "            console.log([gd, 'removed!']);\n",
              "            Plotly.purge(gd);\n",
              "            observer.disconnect();\n",
              "        }}\n",
              "}});\n",
              "\n",
              "// Listen for the removal of the full notebook cells\n",
              "var notebookContainer = gd.closest('#notebook-container');\n",
              "if (notebookContainer) {{\n",
              "    x.observe(notebookContainer, {childList: true});\n",
              "}}\n",
              "\n",
              "// Listen for the clearing of the current output cell\n",
              "var outputEl = gd.closest('.output');\n",
              "if (outputEl) {{\n",
              "    x.observe(outputEl, {childList: true});\n",
              "}}\n",
              "\n",
              "                        })                };                            </script>        </div>\n",
              "</body>\n",
              "</html>"
            ]
          },
          "metadata": {}
        }
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "qyShV5QuNYOt"
      },
      "source": [
        "## 用例集\n",
        "「ござる」？？　これを含む文例を探してみよう。[pd.Series.str.contains](https://pandas.pydata.org/docs/reference/api/pandas.Series.str.contains.html)を使えば良いだけなんだけど、微妙に使いづらいので関数として用意してみる。"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 18,
      "metadata": {
        "id": "RGTorIeVNYOt",
        "outputId": "b2e04a93-186d-4ea2-e2a8-edc73f31f4dd",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 448
        }
      },
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "text/plain": [
              "14     新しく触れる分野だったので不安はあったのですが、自分なりに解釈して理解することができたと思い...\n",
              "31     良い技術者になるためには、道徳の分野が重要だということがわかりました。和田先生の講義内容は私...\n",
              "44     この講義のおかげで、周りの人と話すことができたのでとてもよかったです。この講義がなければ私は...\n",
              "64     私は今までプログラミングに触れたことがなかったので新しいことを覚えるのに必死でした。ですが、...\n",
              "75     最初はターミナルの使い方すら分からなくてとても焦りました。ですが、コマンドやコードの意味、書...\n",
              "90                                           ありがとうございました\n",
              "97     企業の方を招待してお話を聞かせていただいてありがとうございました。とてもためになるお話が聞け...\n",
              "141    講義を通して、確率統計に関する知識を獲得することができたと思います。これらの知識を利用して個...\n",
              "145                               とても良かったです．ありがとうございました．\n",
              "152    実際にIT機器や技術がどのように使われているかを学ぶことができて良かったです。\\r\\nありが...\n",
              "159    CM楽しかったです。実際に講義で学んだ手法を使うと、スムーズにグループワーク ができることを...\n",
              "165    課題が難しいものが多く、時間を多くとってもらえたのは非常に良かったですがかなりきつかったです...\n",
              "Name: comment, dtype: object"
            ],
            "text/html": [
              "<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>comment</th>\n",
              "    </tr>\n",
              "  </thead>\n",
              "  <tbody>\n",
              "    <tr>\n",
              "      <th>14</th>\n",
              "      <td>新しく触れる分野だったので不安はあったのですが、自分なりに解釈して理解することができたと思い...</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>31</th>\n",
              "      <td>良い技術者になるためには、道徳の分野が重要だということがわかりました。和田先生の講義内容は私...</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>44</th>\n",
              "      <td>この講義のおかげで、周りの人と話すことができたのでとてもよかったです。この講義がなければ私は...</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>64</th>\n",
              "      <td>私は今までプログラミングに触れたことがなかったので新しいことを覚えるのに必死でした。ですが、...</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>75</th>\n",
              "      <td>最初はターミナルの使い方すら分からなくてとても焦りました。ですが、コマンドやコードの意味、書...</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>90</th>\n",
              "      <td>ありがとうございました</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>97</th>\n",
              "      <td>企業の方を招待してお話を聞かせていただいてありがとうございました。とてもためになるお話が聞け...</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>141</th>\n",
              "      <td>講義を通して、確率統計に関する知識を獲得することができたと思います。これらの知識を利用して個...</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>145</th>\n",
              "      <td>とても良かったです．ありがとうございました．</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>152</th>\n",
              "      <td>実際にIT機器や技術がどのように使われているかを学ぶことができて良かったです。\\r\\nありが...</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>159</th>\n",
              "      <td>CM楽しかったです。実際に講義で学んだ手法を使うと、スムーズにグループワーク ができることを...</td>\n",
              "    </tr>\n",
              "    <tr>\n",
              "      <th>165</th>\n",
              "      <td>課題が難しいものが多く、時間を多くとってもらえたのは非常に良かったですがかなりきつかったです...</td>\n",
              "    </tr>\n",
              "  </tbody>\n",
              "</table>\n",
              "</div><br><label><b>dtype:</b> object</label>"
            ]
          },
          "metadata": {},
          "execution_count": 18
        }
      ],
      "source": [
        "def get_examples(df, column, text):\n",
        "    return df[df[column].str.contains(text)][column]\n",
        "\n",
        "#assesment_df['comment'].str.contains('例題')\n",
        "df = get_examples(assesment_df, 'comment', 'ござ')\n",
        "df"
      ]
    },
    {
      "cell_type": "markdown",
      "source": [
        "上記はちょっとわかりにくい。この用途ではNLTKが便利。"
      ],
      "metadata": {
        "id": "BRidlpF0Ossh"
      }
    },
    {
      "cell_type": "code",
      "source": [
        "import nltk\n",
        "\n",
        "# テキスト一覧を用意\n",
        "text_list = assesment_df[\"comment\"].tolist()\n",
        "text_data = ' '.join(text_list)\n",
        "\n",
        "# トークン化\n",
        "tokens = []\n",
        "doc = nlp(text_data)\n",
        "for token in doc:\n",
        "  tokens.append(token.lemma_)\n",
        "\n",
        "# nltkでテキスト処理\n",
        "nltk_text = nltk.Text(tokens)\n",
        "\n",
        "# コンコーダンス出力\n",
        "target = \"ござる\"\n",
        "nltk_text.concordance(target, width=50, lines=5)\n"
      ],
      "metadata": {
        "id": "xdfmLLL4OwvJ",
        "outputId": "e283eac8-22ea-4a97-c7eb-9291e176daf9",
        "colab": {
          "base_uri": "https://localhost:8080/"
        }
      },
      "execution_count": 19,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "Displaying 5 of 13 matches:\n",
            "ぶ の は 楽しい た です 。 ありがとう ござる ます た 。 数学 だ けど 数学 っぽい \n",
            " ます た 。 貴重 だ お 話 ありがとう ござる ます た 。 元気 が ある 先生 で 、 \n",
            " 機会 を 設ける て くださる ありがとう ござる ます た 。 今後 の グループ 活動 や \n",
            " 講義 は 楽しい た です 。 ありがとう ござる ます た 。 後期 の 講義 で も お世話\n",
            "る やすい 教える て くださる ありがとう ござる ます た 。 コロナ の 影響 で 仕方ない\n"
          ]
        }
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "gi4CHH2XNYOt"
      },
      "source": [
        "## n-gramsを利用した用例検索\n",
        "個々の単語をカウントして上位確認することでおおよその概要を掴みやすくなった。しかしこれだけだと複数の連続語として出現しやすい表現（フレーズ）や、同時に現れやすい単語（共起語）については把握しづらい。\n",
        "\n",
        "このような複数語を観察しやすくする一つの方法として **n-gram** で観察してみよう。n-gramとは、「n個の連続した単語」を特徴として扱う考え方であり、これまでの「個々の単語を独立してカウント」していたものは ``1-gram`` に相当する。n=2の ``2-gram（bi-gramとも呼ばれる）`` ならば「2個の連続した語」を基本特徴とする。何個まで考慮するかはケース・バイ・ケースである。増やすほどより細かな特徴を対象とすることが可能だが、それだけ処理が重くなってしまうため多くの場合は2〜5-gramに留めることが多いかもしれない。例として2007年にGoogleにより公開された[大規模日本語n-gramデータ](https://japan.googleblog.com/2007/11/n-gram.html)では1〜7-gramまで対応している。より大規模な英語コーパスに対しては[Google Books Ngram Viewer](https://books.google.com/ngrams)として1〜5-gramまで対応しており、こちらは品詞指定なども可能となっている。\n",
        "\n",
        "ここではn-gramを自前で解析してみよう。"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 20,
      "metadata": {
        "id": "atx0I6qjNYOt",
        "outputId": "16e1b167-dcb3-427f-ea03-bbd8eba5ba4e",
        "colab": {
          "base_uri": "https://localhost:8080/"
        }
      },
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "text/plain": [
              "[('と 思う ます', 46),\n",
              " ('た の だ', 38),\n",
              " ('ます た 。', 37),\n",
              " ('思う ます 。', 35),\n",
              " ('た です 。', 30),\n",
              " ('た と 思う', 28),\n",
              " ('こと が できる', 21),\n",
              " ('です が 、', 17),\n",
              " ('が できる た', 16),\n",
              " ('の だ 、', 15)]"
            ]
          },
          "metadata": {},
          "execution_count": 20
        }
      ],
      "source": [
        "def count_ngrams(df, column, n=3):\n",
        "    '''分かち書き4：原形処理し、ストップワードを除き、類義語を代表語に置き換え、品詞別にカウント。\n",
        "    args:\n",
        "      df (pd.DataFrame): 読み込み対象データフレーム。\n",
        "      column (str): データフレーム内の読み込み対象列名。\n",
        "      n (int): n-gramとしてカウントする連続語数n。\n",
        "    return\n",
        "      result ({n_gram_text:count}): 出現したn-gram毎の出現回数を保持した辞書。\n",
        "    '''\n",
        "    if n <= 1:\n",
        "        return None\n",
        "\n",
        "    stop_words = ['', '\\r\\n']\n",
        "    result = {}\n",
        "    for comment in df[column]:\n",
        "        doc = nlp(comment)\n",
        "        token_list = []\n",
        "        for token in doc:\n",
        "            if token.lemma_ not in stop_words:\n",
        "                token_list.append(token.lemma_)\n",
        "\n",
        "        if len(token_list) < n:\n",
        "            pass\n",
        "\n",
        "        for index in range(len(token_list)-n+1):\n",
        "            ngram = ' '.join(token_list[index:index+n]) # n-gramをスペース区切り文字列として用意\n",
        "            if ngram not in result:\n",
        "                result[ngram] = 1\n",
        "            else:\n",
        "                result[ngram] += 1\n",
        "    return result\n",
        "\n",
        "ngrams = count_ngrams(assesment_df, 'comment', 3)\n",
        "ngrams_count = collections.Counter(ngrams)\n",
        "ngrams_count.most_common(10)"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 21,
      "metadata": {
        "id": "s1R28QJ7NYOt",
        "outputId": "3a194deb-fbb9-42d2-b17e-bc01dac16a60",
        "colab": {
          "base_uri": "https://localhost:8080/"
        }
      },
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "text/plain": [
              "[('ありがとう ござる ます', 13),\n",
              " ('ござる ます た', 13),\n",
              " ('。 ありがとう ござる', 7),\n",
              " ('くださる ありがとう ござる', 2),\n",
              " ('話 ありがとう ござる', 1),\n",
              " ('て ありがとう ござる', 1),\n",
              " ('. ありがとう ござる', 1)]"
            ]
          },
          "metadata": {},
          "execution_count": 21
        }
      ],
      "source": [
        "def filter_dict(ngrams_count_dict, text):\n",
        "    '''指定した語を含むngramを検索。\n",
        "    args:\n",
        "      ngrams_count_dict (dict): count_ngrams()で作成したn-gram解析結果の辞書。\n",
        "      text (str): 検索語。\n",
        "    '''\n",
        "    return dict(filter(lambda item: text in item[0], ngrams_count_dict.items()))\n",
        "\n",
        "examples = filter_dict(ngrams_count, 'ござ')\n",
        "examples_count = collections.Counter(examples)\n",
        "examples_count.most_common(10)"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "1GsqF1aLNYOt"
      },
      "source": [
        "## 係り受け情報を利用した検索\n",
        "n-gramはn個の連続した語、もしくはその範疇にある共起語に対してはうまく機能する。nを増やせば理論的にはあらゆる共起を参照できるが計算コスト的には現実的ではない上に「共起＝それらの語が密接に結びついている」とは限らないこともある。\n",
        "\n",
        "例えば「授業用スライドが丁寧に作られていてわかりやすかった。」という文を例に上げると、わかりやすかったのは「授業」もしくは「授業用スライド」だろう。このような関係は係り受け構造を考慮した方が良い。しかしながら係り受け関係は複雑であり、全てを網羅して処理するのは苦労する。例えば今回の例では aux, mark が出現する。これらは補助的に使われる関係（Non-core dependents）であり、主要な情報ではない。実際「作る」に係る関係のうち、auxは「に」、markは「て」であり、今回の共起語としては扱いたくない。そこで以下の例では「使いたくない関係を指定」した上で抽出するとしよう。\n",
        "\n",
        "- 参考\n",
        "  - [Universal Dependencies](https://universaldependencies.org), spacyで採用している汎用(言語を問わない)係り受け関係。\n",
        "  - [Universal Dependency Relations](https://universaldependencies.org/u/dep/), 係り受けタグの一覧。"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 22,
      "metadata": {
        "id": "HMbHxuluNYOu",
        "outputId": "9165c6d2-9f06-4eef-9cf2-634a30e4dbf4",
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 480
        }
      },
      "outputs": [
        {
          "output_type": "display_data",
          "data": {
            "text/plain": [
              "<IPython.core.display.HTML object>"
            ],
            "text/html": [
              "<span class=\"tex2jax_ignore\"><svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" xml:lang=\"ja\" id=\"58e9d04360f341cb973d29e92b15c468-0\" class=\"displacy\" width=\"2150\" height=\"437.0\" direction=\"ltr\" style=\"max-width: none; height: 437.0px; color: #000000; background: #ffffff; font-family: Arial; direction: ltr\">\n",
              "<text class=\"displacy-token\" fill=\"currentColor\" text-anchor=\"middle\" y=\"347.0\">\n",
              "    <tspan class=\"displacy-word\" fill=\"currentColor\" x=\"50\">授業</tspan>\n",
              "    <tspan class=\"displacy-tag\" dy=\"2em\" fill=\"currentColor\" x=\"50\">NOUN</tspan>\n",
              "</text>\n",
              "\n",
              "<text class=\"displacy-token\" fill=\"currentColor\" text-anchor=\"middle\" y=\"347.0\">\n",
              "    <tspan class=\"displacy-word\" fill=\"currentColor\" x=\"200\">用</tspan>\n",
              "    <tspan class=\"displacy-tag\" dy=\"2em\" fill=\"currentColor\" x=\"200\">NOUN</tspan>\n",
              "</text>\n",
              "\n",
              "<text class=\"displacy-token\" fill=\"currentColor\" text-anchor=\"middle\" y=\"347.0\">\n",
              "    <tspan class=\"displacy-word\" fill=\"currentColor\" x=\"350\">スライド</tspan>\n",
              "    <tspan class=\"displacy-tag\" dy=\"2em\" fill=\"currentColor\" x=\"350\">NOUN</tspan>\n",
              "</text>\n",
              "\n",
              "<text class=\"displacy-token\" fill=\"currentColor\" text-anchor=\"middle\" y=\"347.0\">\n",
              "    <tspan class=\"displacy-word\" fill=\"currentColor\" x=\"500\">が</tspan>\n",
              "    <tspan class=\"displacy-tag\" dy=\"2em\" fill=\"currentColor\" x=\"500\">ADP</tspan>\n",
              "</text>\n",
              "\n",
              "<text class=\"displacy-token\" fill=\"currentColor\" text-anchor=\"middle\" y=\"347.0\">\n",
              "    <tspan class=\"displacy-word\" fill=\"currentColor\" x=\"650\">丁寧</tspan>\n",
              "    <tspan class=\"displacy-tag\" dy=\"2em\" fill=\"currentColor\" x=\"650\">ADJ</tspan>\n",
              "</text>\n",
              "\n",
              "<text class=\"displacy-token\" fill=\"currentColor\" text-anchor=\"middle\" y=\"347.0\">\n",
              "    <tspan class=\"displacy-word\" fill=\"currentColor\" x=\"800\">に</tspan>\n",
              "    <tspan class=\"displacy-tag\" dy=\"2em\" fill=\"currentColor\" x=\"800\">AUX</tspan>\n",
              "</text>\n",
              "\n",
              "<text class=\"displacy-token\" fill=\"currentColor\" text-anchor=\"middle\" y=\"347.0\">\n",
              "    <tspan class=\"displacy-word\" fill=\"currentColor\" x=\"950\">作ら</tspan>\n",
              "    <tspan class=\"displacy-tag\" dy=\"2em\" fill=\"currentColor\" x=\"950\">VERB</tspan>\n",
              "</text>\n",
              "\n",
              "<text class=\"displacy-token\" fill=\"currentColor\" text-anchor=\"middle\" y=\"347.0\">\n",
              "    <tspan class=\"displacy-word\" fill=\"currentColor\" x=\"1100\">れ</tspan>\n",
              "    <tspan class=\"displacy-tag\" dy=\"2em\" fill=\"currentColor\" x=\"1100\">AUX</tspan>\n",
              "</text>\n",
              "\n",
              "<text class=\"displacy-token\" fill=\"currentColor\" text-anchor=\"middle\" y=\"347.0\">\n",
              "    <tspan class=\"displacy-word\" fill=\"currentColor\" x=\"1250\">て</tspan>\n",
              "    <tspan class=\"displacy-tag\" dy=\"2em\" fill=\"currentColor\" x=\"1250\">SCONJ</tspan>\n",
              "</text>\n",
              "\n",
              "<text class=\"displacy-token\" fill=\"currentColor\" text-anchor=\"middle\" y=\"347.0\">\n",
              "    <tspan class=\"displacy-word\" fill=\"currentColor\" x=\"1400\">い</tspan>\n",
              "    <tspan class=\"displacy-tag\" dy=\"2em\" fill=\"currentColor\" x=\"1400\">VERB</tspan>\n",
              "</text>\n",
              "\n",
              "<text class=\"displacy-token\" fill=\"currentColor\" text-anchor=\"middle\" y=\"347.0\">\n",
              "    <tspan class=\"displacy-word\" fill=\"currentColor\" x=\"1550\">て</tspan>\n",
              "    <tspan class=\"displacy-tag\" dy=\"2em\" fill=\"currentColor\" x=\"1550\">SCONJ</tspan>\n",
              "</text>\n",
              "\n",
              "<text class=\"displacy-token\" fill=\"currentColor\" text-anchor=\"middle\" y=\"347.0\">\n",
              "    <tspan class=\"displacy-word\" fill=\"currentColor\" x=\"1700\">わかり</tspan>\n",
              "    <tspan class=\"displacy-tag\" dy=\"2em\" fill=\"currentColor\" x=\"1700\">VERB</tspan>\n",
              "</text>\n",
              "\n",
              "<text class=\"displacy-token\" fill=\"currentColor\" text-anchor=\"middle\" y=\"347.0\">\n",
              "    <tspan class=\"displacy-word\" fill=\"currentColor\" x=\"1850\">やすかっ</tspan>\n",
              "    <tspan class=\"displacy-tag\" dy=\"2em\" fill=\"currentColor\" x=\"1850\">AUX</tspan>\n",
              "</text>\n",
              "\n",
              "<text class=\"displacy-token\" fill=\"currentColor\" text-anchor=\"middle\" y=\"347.0\">\n",
              "    <tspan class=\"displacy-word\" fill=\"currentColor\" x=\"2000\">た。</tspan>\n",
              "    <tspan class=\"displacy-tag\" dy=\"2em\" fill=\"currentColor\" x=\"2000\">AUX</tspan>\n",
              "</text>\n",
              "\n",
              "<g class=\"displacy-arrow\">\n",
              "    <path class=\"displacy-arc\" id=\"arrow-58e9d04360f341cb973d29e92b15c468-0-0\" stroke-width=\"2px\" d=\"M62,302.0 62,252.0 344.0,252.0 344.0,302.0\" fill=\"none\" stroke=\"currentColor\"/>\n",
              "    <text dy=\"1.25em\" style=\"font-size: 0.8em; letter-spacing: 1px\">\n",
              "        <textPath xlink:href=\"#arrow-58e9d04360f341cb973d29e92b15c468-0-0\" class=\"displacy-label\" startOffset=\"50%\" side=\"left\" fill=\"currentColor\" text-anchor=\"middle\">compound</textPath>\n",
              "    </text>\n",
              "    <path class=\"displacy-arrowhead\" d=\"M62,304.0 L58,296.0 66,296.0\" fill=\"currentColor\"/>\n",
              "</g>\n",
              "\n",
              "<g class=\"displacy-arrow\">\n",
              "    <path class=\"displacy-arc\" id=\"arrow-58e9d04360f341cb973d29e92b15c468-0-1\" stroke-width=\"2px\" d=\"M212,302.0 212,277.0 341.0,277.0 341.0,302.0\" fill=\"none\" stroke=\"currentColor\"/>\n",
              "    <text dy=\"1.25em\" style=\"font-size: 0.8em; letter-spacing: 1px\">\n",
              "        <textPath xlink:href=\"#arrow-58e9d04360f341cb973d29e92b15c468-0-1\" class=\"displacy-label\" startOffset=\"50%\" side=\"left\" fill=\"currentColor\" text-anchor=\"middle\">compound</textPath>\n",
              "    </text>\n",
              "    <path class=\"displacy-arrowhead\" d=\"M212,304.0 L208,296.0 216,296.0\" fill=\"currentColor\"/>\n",
              "</g>\n",
              "\n",
              "<g class=\"displacy-arrow\">\n",
              "    <path class=\"displacy-arc\" id=\"arrow-58e9d04360f341cb973d29e92b15c468-0-2\" stroke-width=\"2px\" d=\"M362,302.0 362,227.0 947.0,227.0 947.0,302.0\" fill=\"none\" stroke=\"currentColor\"/>\n",
              "    <text dy=\"1.25em\" style=\"font-size: 0.8em; letter-spacing: 1px\">\n",
              "        <textPath xlink:href=\"#arrow-58e9d04360f341cb973d29e92b15c468-0-2\" class=\"displacy-label\" startOffset=\"50%\" side=\"left\" fill=\"currentColor\" text-anchor=\"middle\">nsubj</textPath>\n",
              "    </text>\n",
              "    <path class=\"displacy-arrowhead\" d=\"M362,304.0 L358,296.0 366,296.0\" fill=\"currentColor\"/>\n",
              "</g>\n",
              "\n",
              "<g class=\"displacy-arrow\">\n",
              "    <path class=\"displacy-arc\" id=\"arrow-58e9d04360f341cb973d29e92b15c468-0-3\" stroke-width=\"2px\" d=\"M362,302.0 362,277.0 491.0,277.0 491.0,302.0\" fill=\"none\" stroke=\"currentColor\"/>\n",
              "    <text dy=\"1.25em\" style=\"font-size: 0.8em; letter-spacing: 1px\">\n",
              "        <textPath xlink:href=\"#arrow-58e9d04360f341cb973d29e92b15c468-0-3\" class=\"displacy-label\" startOffset=\"50%\" side=\"left\" fill=\"currentColor\" text-anchor=\"middle\">case</textPath>\n",
              "    </text>\n",
              "    <path class=\"displacy-arrowhead\" d=\"M491.0,304.0 L495.0,296.0 487.0,296.0\" fill=\"currentColor\"/>\n",
              "</g>\n",
              "\n",
              "<g class=\"displacy-arrow\">\n",
              "    <path class=\"displacy-arc\" id=\"arrow-58e9d04360f341cb973d29e92b15c468-0-4\" stroke-width=\"2px\" d=\"M662,302.0 662,252.0 944.0,252.0 944.0,302.0\" fill=\"none\" stroke=\"currentColor\"/>\n",
              "    <text dy=\"1.25em\" style=\"font-size: 0.8em; letter-spacing: 1px\">\n",
              "        <textPath xlink:href=\"#arrow-58e9d04360f341cb973d29e92b15c468-0-4\" class=\"displacy-label\" startOffset=\"50%\" side=\"left\" fill=\"currentColor\" text-anchor=\"middle\">advcl</textPath>\n",
              "    </text>\n",
              "    <path class=\"displacy-arrowhead\" d=\"M662,304.0 L658,296.0 666,296.0\" fill=\"currentColor\"/>\n",
              "</g>\n",
              "\n",
              "<g class=\"displacy-arrow\">\n",
              "    <path class=\"displacy-arc\" id=\"arrow-58e9d04360f341cb973d29e92b15c468-0-5\" stroke-width=\"2px\" d=\"M662,302.0 662,277.0 791.0,277.0 791.0,302.0\" fill=\"none\" stroke=\"currentColor\"/>\n",
              "    <text dy=\"1.25em\" style=\"font-size: 0.8em; letter-spacing: 1px\">\n",
              "        <textPath xlink:href=\"#arrow-58e9d04360f341cb973d29e92b15c468-0-5\" class=\"displacy-label\" startOffset=\"50%\" side=\"left\" fill=\"currentColor\" text-anchor=\"middle\">aux</textPath>\n",
              "    </text>\n",
              "    <path class=\"displacy-arrowhead\" d=\"M791.0,304.0 L795.0,296.0 787.0,296.0\" fill=\"currentColor\"/>\n",
              "</g>\n",
              "\n",
              "<g class=\"displacy-arrow\">\n",
              "    <path class=\"displacy-arc\" id=\"arrow-58e9d04360f341cb973d29e92b15c468-0-6\" stroke-width=\"2px\" d=\"M962,302.0 962,202.0 1700.0,202.0 1700.0,302.0\" fill=\"none\" stroke=\"currentColor\"/>\n",
              "    <text dy=\"1.25em\" style=\"font-size: 0.8em; letter-spacing: 1px\">\n",
              "        <textPath xlink:href=\"#arrow-58e9d04360f341cb973d29e92b15c468-0-6\" class=\"displacy-label\" startOffset=\"50%\" side=\"left\" fill=\"currentColor\" text-anchor=\"middle\">advcl</textPath>\n",
              "    </text>\n",
              "    <path class=\"displacy-arrowhead\" d=\"M962,304.0 L958,296.0 966,296.0\" fill=\"currentColor\"/>\n",
              "</g>\n",
              "\n",
              "<g class=\"displacy-arrow\">\n",
              "    <path class=\"displacy-arc\" id=\"arrow-58e9d04360f341cb973d29e92b15c468-0-7\" stroke-width=\"2px\" d=\"M962,302.0 962,277.0 1091.0,277.0 1091.0,302.0\" fill=\"none\" stroke=\"currentColor\"/>\n",
              "    <text dy=\"1.25em\" style=\"font-size: 0.8em; letter-spacing: 1px\">\n",
              "        <textPath xlink:href=\"#arrow-58e9d04360f341cb973d29e92b15c468-0-7\" class=\"displacy-label\" startOffset=\"50%\" side=\"left\" fill=\"currentColor\" text-anchor=\"middle\">aux</textPath>\n",
              "    </text>\n",
              "    <path class=\"displacy-arrowhead\" d=\"M1091.0,304.0 L1095.0,296.0 1087.0,296.0\" fill=\"currentColor\"/>\n",
              "</g>\n",
              "\n",
              "<g class=\"displacy-arrow\">\n",
              "    <path class=\"displacy-arc\" id=\"arrow-58e9d04360f341cb973d29e92b15c468-0-8\" stroke-width=\"2px\" d=\"M962,302.0 962,252.0 1244.0,252.0 1244.0,302.0\" fill=\"none\" stroke=\"currentColor\"/>\n",
              "    <text dy=\"1.25em\" style=\"font-size: 0.8em; letter-spacing: 1px\">\n",
              "        <textPath xlink:href=\"#arrow-58e9d04360f341cb973d29e92b15c468-0-8\" class=\"displacy-label\" startOffset=\"50%\" side=\"left\" fill=\"currentColor\" text-anchor=\"middle\">mark</textPath>\n",
              "    </text>\n",
              "    <path class=\"displacy-arrowhead\" d=\"M1244.0,304.0 L1248.0,296.0 1240.0,296.0\" fill=\"currentColor\"/>\n",
              "</g>\n",
              "\n",
              "<g class=\"displacy-arrow\">\n",
              "    <path class=\"displacy-arc\" id=\"arrow-58e9d04360f341cb973d29e92b15c468-0-9\" stroke-width=\"2px\" d=\"M1262,302.0 1262,277.0 1391.0,277.0 1391.0,302.0\" fill=\"none\" stroke=\"currentColor\"/>\n",
              "    <text dy=\"1.25em\" style=\"font-size: 0.8em; letter-spacing: 1px\">\n",
              "        <textPath xlink:href=\"#arrow-58e9d04360f341cb973d29e92b15c468-0-9\" class=\"displacy-label\" startOffset=\"50%\" side=\"left\" fill=\"currentColor\" text-anchor=\"middle\">fixed</textPath>\n",
              "    </text>\n",
              "    <path class=\"displacy-arrowhead\" d=\"M1391.0,304.0 L1395.0,296.0 1387.0,296.0\" fill=\"currentColor\"/>\n",
              "</g>\n",
              "\n",
              "<g class=\"displacy-arrow\">\n",
              "    <path class=\"displacy-arc\" id=\"arrow-58e9d04360f341cb973d29e92b15c468-0-10\" stroke-width=\"2px\" d=\"M962,302.0 962,227.0 1547.0,227.0 1547.0,302.0\" fill=\"none\" stroke=\"currentColor\"/>\n",
              "    <text dy=\"1.25em\" style=\"font-size: 0.8em; letter-spacing: 1px\">\n",
              "        <textPath xlink:href=\"#arrow-58e9d04360f341cb973d29e92b15c468-0-10\" class=\"displacy-label\" startOffset=\"50%\" side=\"left\" fill=\"currentColor\" text-anchor=\"middle\">mark</textPath>\n",
              "    </text>\n",
              "    <path class=\"displacy-arrowhead\" d=\"M1547.0,304.0 L1551.0,296.0 1543.0,296.0\" fill=\"currentColor\"/>\n",
              "</g>\n",
              "\n",
              "<g class=\"displacy-arrow\">\n",
              "    <path class=\"displacy-arc\" id=\"arrow-58e9d04360f341cb973d29e92b15c468-0-11\" stroke-width=\"2px\" d=\"M1712,302.0 1712,277.0 1841.0,277.0 1841.0,302.0\" fill=\"none\" stroke=\"currentColor\"/>\n",
              "    <text dy=\"1.25em\" style=\"font-size: 0.8em; letter-spacing: 1px\">\n",
              "        <textPath xlink:href=\"#arrow-58e9d04360f341cb973d29e92b15c468-0-11\" class=\"displacy-label\" startOffset=\"50%\" side=\"left\" fill=\"currentColor\" text-anchor=\"middle\">aux</textPath>\n",
              "    </text>\n",
              "    <path class=\"displacy-arrowhead\" d=\"M1841.0,304.0 L1845.0,296.0 1837.0,296.0\" fill=\"currentColor\"/>\n",
              "</g>\n",
              "\n",
              "<g class=\"displacy-arrow\">\n",
              "    <path class=\"displacy-arc\" id=\"arrow-58e9d04360f341cb973d29e92b15c468-0-12\" stroke-width=\"2px\" d=\"M1712,302.0 1712,252.0 1994.0,252.0 1994.0,302.0\" fill=\"none\" stroke=\"currentColor\"/>\n",
              "    <text dy=\"1.25em\" style=\"font-size: 0.8em; letter-spacing: 1px\">\n",
              "        <textPath xlink:href=\"#arrow-58e9d04360f341cb973d29e92b15c468-0-12\" class=\"displacy-label\" startOffset=\"50%\" side=\"left\" fill=\"currentColor\" text-anchor=\"middle\">aux</textPath>\n",
              "    </text>\n",
              "    <path class=\"displacy-arrowhead\" d=\"M1994.0,304.0 L1998.0,296.0 1990.0,296.0\" fill=\"currentColor\"/>\n",
              "</g>\n",
              "</svg></span>"
            ]
          },
          "metadata": {}
        }
      ],
      "source": [
        "from spacy import displacy\n",
        "\n",
        "doc = nlp(assesment_df['comment'][13])\n",
        "displacy.render(doc, style=\"dep\", options={\"compact\":True})"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 23,
      "metadata": {
        "id": "qq-lgmRVNYOv",
        "outputId": "8c8d99a0-16ed-4480-b455-523616139797",
        "colab": {
          "base_uri": "https://localhost:8080/"
        }
      },
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "0 授業 compound 2\n",
            "1 用 compound 2\n",
            "2 スライド nsubj 6\n",
            "3 が case 2\n",
            "4 丁寧 advcl 6\n",
            "5 に aux 4\n",
            "6 作ら advcl 11\n",
            "7 れ aux 6\n",
            "8 て mark 6\n",
            "9 い fixed 8\n",
            "10 て mark 6\n",
            "11 わかり ROOT 11\n",
            "12 やすかっ aux 11\n",
            "13 た aux 11\n",
            "14 。 punct 11\n"
          ]
        }
      ],
      "source": [
        "# 係り受け情報の確認\n",
        "doc = nlp(assesment_df['comment'][13])\n",
        "for token in doc:\n",
        "    print(token.i, token.text, token.dep_, token.head.i)"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 24,
      "metadata": {
        "id": "lSkpCimaNYOv",
        "outputId": "38713f56-663c-4d51-cd23-aa9fd7cdbab8",
        "colab": {
          "base_uri": "https://localhost:8080/"
        }
      },
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "text/plain": [
              "['スライド', '丁寧']"
            ]
          },
          "metadata": {},
          "execution_count": 24
        }
      ],
      "source": [
        "# 指定単語に係る元の単語を探してみる\n",
        "\n",
        "def find_pre_token(text, target_word, deps=['aux', 'mark']):\n",
        "    '''指定単語に係る元の単語集合を探す。ただし特定関係は除外する。\n",
        "    args:\n",
        "      text (str): 解析対象文。\n",
        "      target_word (str): 指定単語。\n",
        "      deps ([str]): 除外したい係り受け関係。\n",
        "    return\n",
        "      result ([str]): target_wordに係る単語のリスト。\n",
        "    '''\n",
        "\n",
        "    # 係り受け情報を保存\n",
        "    doc = nlp(text)\n",
        "    dependencies = {}\n",
        "    for token in doc:\n",
        "        dependencies.update({token.i:[token.text, token.dep_, token.head.i]})\n",
        "        if token.text == target_word:\n",
        "            target_index = token.i # 検索語のインデックス\n",
        "\n",
        "    # 係り受け元探し\n",
        "    result = []\n",
        "    for key, value in dependencies.items():\n",
        "        if value[2] == target_index:\n",
        "            if value[1] not in deps:\n",
        "                result.append(value[0])\n",
        "    return result\n",
        "\n",
        "text = assesment_df['comment'][13]\n",
        "pre_tokens = find_pre_token(text, '作ら')\n",
        "pre_tokens"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "koDzAZNpNYOv"
      },
      "source": [
        "## 固有表現抽出\n",
        "場所や人名、日付、時間等の特定対象を指す表現を固有表現 (Named Entity) と呼ぶ。実際の定義はツール毎に異なる点に注意。\n",
        "- 参考: [Wikipedia:固有表現抽出](https://ja.wikipedia.org/wiki/固有表現抽出)"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 25,
      "metadata": {
        "id": "AVHL-ImFNYOv",
        "outputId": "5581f044-0dc2-403b-e09d-ed3940680314",
        "colab": {
          "base_uri": "https://localhost:8080/"
        }
      },
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "一度 Frequency\n",
            "3つ Countx_Other\n",
            "１ずつ N_Product\n",
            "１年次 Countx_Other\n",
            "線形代数 Academic\n",
            "線形代数 Academic\n",
            "第２Q Ordinal_Number\n",
            "コロナ Company\n",
            "教授 Position_Vocation\n",
            "COVID１９ Product_Other\n",
            "沖縄 Province\n",
            "技術者 Position_Vocation\n",
            "和田 Person\n",
            "先生 Position_Vocation\n",
            "和田 Person\n",
            "先生 Position_Vocation\n",
            "先生 Position_Vocation\n",
            "4年間 Period_Year\n",
            "1Q Pro_Sports_Organization\n",
            "社会人 Position_Vocation\n",
            "企業人インタビュー Position_Vocation\n",
            "工学部 Organization_Other\n",
            "7つ Countx_Other\n",
            "一つ Countx_Other\n",
            "ネット Doctrine_Method_Other\n",
            "プログラミングII Game\n",
            "夏休み Date\n",
            "２学期 Date\n",
            "GOOD Dish\n",
            "一人 N_Person\n",
            "當間 Person\n",
            "先生 Position_Vocation\n",
            "１週間 Period_Week\n",
            "２週間 Period_Week\n",
            "プログラミング１ Game\n",
            "コロナ Company\n",
            "黄色 Nature_Color\n",
            "先生 Position_Vocation\n",
            "生徒 Position_Vocation\n",
            "成績評価 Position_Vocation\n",
            "２週 Period_Year\n",
            "先生 Position_Vocation\n",
            "webclass Person\n",
            "webclass Person\n",
            "1ページ Countx_Other\n",
            "4枚 N_Product\n",
            "1ページ N_Product\n",
            "1枚 N_Product\n",
            "1ページ Countx_Other\n",
            "4枚分 N_Product\n",
            "先生 Position_Vocation\n",
            "mattermost Food_Other\n",
            "生徒 Position_Vocation\n",
            "先生 Position_Vocation\n",
            "先生 Position_Vocation\n",
            "生徒 Position_Vocation\n",
            "1ページ N_Product\n",
            "4分割 Percent\n",
            "頭 Animal_Part\n",
            "1, Countx_Other\n",
            "2週間ほど Period_Week\n",
            "2週連続 Period_Year\n",
            "webclass Company\n",
            "２週 Period_Week\n",
            "20% Percent\n",
            "40+40=80% Time\n",
            "学生全員 Position_Vocation\n",
            "技術者 Position_Vocation\n",
            "頭 Animal_Part\n",
            "0点 Point\n",
            "一週間前 Period_Week\n",
            "webclass Person\n",
            "学生 Position_Vocation\n",
            "学生 Position_Vocation\n",
            "２週 Timex_Other\n",
            "Webclass Product_Other\n",
            "Zoom Product_Other\n",
            "Zoom Company\n",
            "生徒 Position_Vocation\n",
            "生徒側 Position_Vocation\n",
            "先生 Position_Vocation\n",
            "先生 Position_Vocation\n",
            "5月 Date\n",
            "次年度 Date\n",
            "最後３ Ordinal_Number\n",
            "４週間 Period_Week\n",
            "30分前後 Period_Time\n",
            "2時間 Period_Time\n",
            "朝 Time\n",
            "２時間 Period_Time\n",
            "先生 Position_Vocation\n",
            "先生 Position_Vocation\n",
            "100% Percent\n",
            "100% Percent\n",
            "試験100% Percent\n",
            "100% Percent\n",
            "100% Percent\n",
            "先生 Position_Vocation\n",
            "1週間以上 Countx_Other\n",
            "PM Doctrine_Method_Other\n",
            "グループメンバー Position_Vocation\n",
            "キャンパス School\n",
            "学生 Position_Vocation\n",
            "先生 Position_Vocation\n",
            "unity Doctrine_Method_Other\n",
            "班員 Position_Vocation\n",
            "モバイルアプリ班 Company\n",
            "JavaScript Product_Other\n",
            "メンバー Position_Vocation\n",
            "GitHub Show_Organization\n"
          ]
        }
      ],
      "source": [
        "for comment in assesment_df['comment']:\n",
        "    doc = nlp(comment)\n",
        "    for entity in doc.ents:\n",
        "        print(entity.text, entity.label_)"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "vECSShfANYOw"
      },
      "source": [
        "## 単語の特徴ベクトル（分散表現）\n",
        "分かち書きされたTokenを対象として処理する際の問題の一つに、単語表記を元にした処理をしようとした際の柔軟性が低いことがあげられる。例えば類義語処理においては「授業」と「講義」を同一視するために直接それらを列挙する必要があった。実際問題として手動でやる手間をゼロにすることは困難だが、ある程度の自動化については[分散表現](https://ledge.ai/word2vec/)が機能しつつある。分散表現の詳細は後日扱うとして、ここでは「単語の意味をベクトルとして表現する」ぐらいに捉え、実例を眺めてみよう。"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 26,
      "metadata": {
        "id": "JZL6pEkfNYOw",
        "outputId": "8df34551-e6bc-45d3-e2de-cbbbc342fcb1",
        "colab": {
          "base_uri": "https://localhost:8080/"
        }
      },
      "outputs": [
        {
          "output_type": "execute_result",
          "data": {
            "text/plain": [
              "(26000, 300)"
            ]
          },
          "metadata": {},
          "execution_count": 26
        }
      ],
      "source": [
        "# ja_ginza (5.1.0) の標準モデルでは2万6千語が300次元のベクトルとして登録されている。\n",
        "# Transformersモデルとして構築し直された ja_ginza_electra は ja_ginzaよりも高精度だが、\n",
        "# メモリ16GB以上が必要だ。\n",
        "\n",
        "nlp.vocab.vectors.shape"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "z2BOHewjNYOw"
      },
      "source": [
        "### tokenやdocからベクトルを得る\n",
        "単にベクトルを得るだけならば、nlpで解析後に doc.vector や token.vectorとするだけで得られる。"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 27,
      "metadata": {
        "id": "ub6D_geVNYOw",
        "outputId": "7ec866b9-f4c3-4941-fb39-6345e8a3ac81",
        "colab": {
          "base_uri": "https://localhost:8080/"
        }
      },
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "(300,)\n",
            "[ 0.03997449 -0.12051773 -0.04468929 -0.12576343 -0.11509937]\n"
          ]
        }
      ],
      "source": [
        "text = assesment_df['comment'][0]\n",
        "doc = nlp(text)\n",
        "print(doc.vector.shape)\n",
        "print(doc.vector[:5]) # 冒頭5次元目まで"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 28,
      "metadata": {
        "id": "V1dd-89ANYOw",
        "outputId": "b797aea1-4493-4901-b943-7ffa0c1de081",
        "colab": {
          "base_uri": "https://localhost:8080/"
        }
      },
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "特に [ 0.19660935 -0.06194177  0.00594446 -0.23807472 -0.10820279]\n",
            "なし [-0.11666037 -0.17909369 -0.09532304 -0.01345213 -0.12199596]\n"
          ]
        }
      ],
      "source": [
        "for token in doc:\n",
        "    print(token.text, token.vector[:5])"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "q1Az9TPoNYOw"
      },
      "source": [
        "### 直接単語や文章からベクトルを得る\n",
        "nlpで解析せずとも、内部モデルからベクトルを参照することも可能。ただし単語を直接指定するのではなく、``nlp.vocab.strings('単語')`` により単語のハッシュ値を求め、そのハッシュ値に対応するベクトルを参照するという手順を踏む必要がある。"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 29,
      "metadata": {
        "id": "sW5UpltBNYOw",
        "outputId": "39cb2e35-1ee1-4d05-f38c-5ea05a0a510e",
        "colab": {
          "base_uri": "https://localhost:8080/"
        }
      },
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "4452343185052482328\n",
            "特に =>  [ 0.19660935 -0.06194177  0.00594446 -0.23807472 -0.10820279]\n"
          ]
        }
      ],
      "source": [
        "print(nlp.vocab.strings['特に'])\n",
        "word_vector = nlp.vocab.vectors[nlp.vocab.strings['特に']]\n",
        "print('特に => ', word_vector[:5])"
      ]
    },
    {
      "cell_type": "markdown",
      "metadata": {
        "id": "ewPcUdJ3NYOw"
      },
      "source": [
        "### 類似語を探してみる\n",
        "今回のコメント一覧だけを対象として類似語参照してみよう。"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 30,
      "metadata": {
        "id": "1yobJjN8NYOw",
        "outputId": "7a589a5e-6aab-465f-e4d4-4a3dc28a4d2c",
        "colab": {
          "base_uri": "https://localhost:8080/"
        }
      },
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "916 916\n",
            "[特に, なし, 正直, わかり, ずらい] ['特に', 'なし', '正直', 'わかる', 'ずらい']\n",
            "<class 'spacy.tokens.token.Token'> <class 'str'>\n"
          ]
        }
      ],
      "source": [
        "def get_uniq_token(df, column):\n",
        "    '''ユニークなTokenのみを収集。\n",
        "    args:\n",
        "      df (pd.DataFrame): 読み込み対象データフレーム。\n",
        "      column (str): データフレーム内の読み込み対象列名。\n",
        "    return\n",
        "      uniq_tokens ([token]): ユニークTokenのリスト。\n",
        "      uniq_words ([token.lemma_]): ユニークToken.lemma_のリスト。\n",
        "    '''\n",
        "    uniq_tokens = []\n",
        "    uniq_words = []\n",
        "    for comment in df[column]:\n",
        "        doc = nlp(comment)\n",
        "        for token in doc:\n",
        "            if token.lemma_ not in uniq_words:\n",
        "                uniq_tokens.append(token)\n",
        "                uniq_words.append(token.lemma_)\n",
        "    return uniq_tokens, uniq_words\n",
        "\n",
        "uniq_tokens, uniq_words = get_uniq_token(assesment_df, 'comment')\n",
        "print(len(uniq_tokens), len(uniq_words))\n",
        "print(uniq_tokens[:5], uniq_words[:5])\n",
        "print(type(uniq_tokens[0]), type(uniq_words[0]))"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 31,
      "metadata": {
        "id": "TCK79pLtNYOx",
        "outputId": "09280b29-35e7-4e7f-f8db-c1695d1e3ce8",
        "colab": {
          "base_uri": "https://localhost:8080/"
        }
      },
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "[特に, なし, 正直]\n",
            "特に1.0000002, 0.4533139, 0.5239588, \n",
            "なし0.4533139, 0.99999976, 0.39796996, \n",
            "正直0.5239588, 0.39796996, 1.0000001, \n"
          ]
        }
      ],
      "source": [
        "from sklearn.metrics.pairwise import cosine_similarity\n",
        "\n",
        "def calc_similarity_matrix(tokens):\n",
        "    '''トークン同士の類似度（コサイン類似度）を計算。\n",
        "    args:\n",
        "      tokens ([token]): トークン一覧のリスト。\n",
        "    return\n",
        "      result ([[similarity1, similarity2,,,],,,]): トークン同士の類似度行列。\n",
        "    '''\n",
        "    target_vectors = [token.vector for token in tokens]\n",
        "    result = cosine_similarity(target_vectors, target_vectors)\n",
        "    return result\n",
        "\n",
        "similarity_matrix = calc_similarity_matrix(uniq_tokens)\n",
        "\n",
        "print(uniq_tokens[:3])\n",
        "for i in range(3):\n",
        "    print(uniq_tokens[i], end='')\n",
        "    for j in range(3):\n",
        "        print(similarity_matrix[i][j], end=', ')\n",
        "    print()\n"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 32,
      "metadata": {
        "id": "rL6dPTEmNYOx",
        "outputId": "0eae4f2d-159f-4f0e-f028-644b88279db6",
        "colab": {
          "base_uri": "https://localhost:8080/"
        }
      },
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "[551  71 737  54 849]\n",
            "板書 1.0000001\n",
            "授業 1.0000001\n",
            "自学 1.0000001\n",
            "講義 0.8029713\n",
            "学校 0.7283687\n"
          ]
        }
      ],
      "source": [
        "def most_similar(similarity_matrix, tokens, words, word, n=3):\n",
        "    '''類似度行列から指定単語と類似している単語上位n個を出力。\n",
        "    args:\n",
        "      similarity_matrix: calc_similarity_matrix()で算出した類似度行別。\n",
        "      tokens ([token]): ユニークなトークンのリスト。\n",
        "      words ([word]): ユニークな単語のリスト。\n",
        "      word (str): 検索対象語。\n",
        "      n (int): 出力件数。\n",
        "    return\n",
        "      None\n",
        "    '''\n",
        "    word_index = words.index(word)\n",
        "    similar_indices = np.argsort(similarity_matrix[word_index])[::-1][:n]\n",
        "    print(similar_indices)\n",
        "\n",
        "    for i in range(n):\n",
        "        target_index = similar_indices[i]\n",
        "        print(tokens[target_index].lemma_, similarity_matrix[word_index][target_index])\n",
        "\n",
        "most_similar(similarity_matrix, uniq_tokens, uniq_words, '授業', n=5)"
      ]
    },
    {
      "cell_type": "code",
      "execution_count": 32,
      "metadata": {
        "id": "9XXpTFCuNYOx"
      },
      "outputs": [],
      "source": []
    }
  ],
  "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
}