{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "colab": {},
    "colab_type": "code",
    "executionInfo": {
     "elapsed": 404,
     "status": "ok",
     "timestamp": 1593049561633,
     "user": {
      "displayName": "Kevin Chen",
      "photoUrl": "",
      "userId": "13334341206008152383"
     },
     "user_tz": 420
    },
    "id": "XkhF7ccHJw4m"
   },
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import glob"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "colab": {},
    "colab_type": "code",
    "executionInfo": {
     "elapsed": 449,
     "status": "ok",
     "timestamp": 1593049582796,
     "user": {
      "displayName": "Kevin Chen",
      "photoUrl": "",
      "userId": "13334341206008152383"
     },
     "user_tz": 420
    },
    "id": "4lmu6rePJ0IL"
   },
   "outputs": [],
   "source": [
    "y_pred_final = np.array([1, 0, 0, 0, 2, 0, 0, 1, 1, 2, 1, 1, 1, 1, 1, 0, 2, 2, 2, 1, 1, 2,\n",
    "       1, 0, 2, 1, 1, 0, 2, 1, 1, 1, 0, 0, 1, 1, 1, 0, 1, 2, 1, 1, 1, 2,\n",
    "       2, 0, 1, 1, 1, 0, 2, 1, 1, 1, 2, 1, 0, 1, 0, 1, 2, 2, 1, 0, 1, 2,\n",
    "       0, 0, 1, 1, 2, 0, 0, 2, 2, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0, 1, 0, 0,\n",
    "       2, 0, 0, 1, 1, 2, 1, 1, 2, 1, 0, 0, 0, 1, 0, 2, 0, 2, 1, 1, 1, 0,\n",
    "       1, 1, 0, 2, 2, 1, 2, 0, 0, 2, 2, 2, 2, 2, 1, 1, 1, 0, 0, 1, 1, 0,\n",
    "       2, 0, 2, 0, 0, 0, 2, 1, 1, 2, 2, 1, 1, 2, 0, 1, 0, 0, 1, 0, 0, 2,\n",
    "       1, 1, 0, 0, 2, 2, 1, 2, 0, 1, 2, 2, 1, 2, 2, 1, 1, 1, 2, 1, 1, 1,\n",
    "       0, 0, 1, 2, 0, 0, 1, 2, 1, 1, 2, 1, 1, 1, 0, 0, 0, 2, 1, 1, 2, 0,\n",
    "       1, 2, 1, 1, 0, 0, 1, 0, 1, 1, 0, 1, 2, 1, 2, 1, 1, 0, 2, 1, 0, 1,\n",
    "       0, 1, 2, 1, 0, 2, 1, 1, 1, 2, 2, 0, 1, 1, 0, 2, 2, 0, 1, 0, 1, 0,\n",
    "       2, 1, 2, 2, 1, 2, 0, 1, 2, 0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 1,\n",
    "       2, 2, 1, 0, 1, 1, 0, 0, 2, 2, 0, 1, 1, 1, 1, 1, 1, 1, 0, 2, 2, 1,\n",
    "       2, 1, 2, 2, 1, 1, 1, 0, 0, 0, 1, 0, 1, 1, 0, 1, 1, 0, 0, 1, 0, 2,\n",
    "       0, 1, 2, 0, 2, 2, 0, 1, 1, 1, 1, 0, 0, 2, 2, 0, 1, 0, 0, 2, 0, 1,\n",
    "       0, 2, 0, 1, 1, 1, 1, 1, 0, 0, 0, 1, 0, 0, 1, 2, 0, 2, 1, 1, 0, 1,\n",
    "       0, 0, 1, 1, 1, 2, 0, 2, 1, 0, 0, 2, 0, 1, 2, 1, 1, 1, 0, 0, 1, 1,\n",
    "       0, 1, 0, 2, 1, 2, 1, 1, 0, 1, 0, 1, 2, 0, 2, 0, 2, 2, 0, 2, 2, 1,\n",
    "       0, 1, 0, 1, 0, 1, 2, 0, 1, 0, 0, 2, 0, 0, 2, 2, 0, 2, 2, 0, 1, 1,\n",
    "       1, 1, 1, 1, 0, 1, 0, 1, 1, 1, 0, 2, 1, 1, 1, 0, 0, 0, 1, 0, 0, 2,\n",
    "       0, 1, 2, 1, 2, 1, 2, 1, 1, 0, 1, 1, 1, 2, 2, 2, 2, 2, 0, 1, 1, 1,\n",
    "       0, 0, 1, 2, 2, 1, 1, 0, 1, 1, 1, 2, 1, 2, 1, 1, 1, 1, 0, 2, 1, 1,\n",
    "       1, 1, 1, 1, 0, 1, 1, 2, 1, 1, 1, 1, 0, 0, 1, 1, 0, 0, 2, 2, 1, 0,\n",
    "       2, 2, 0, 1, 0, 1, 0, 0, 1, 2, 1, 2, 0, 2, 2, 2, 2, 2, 1, 1, 1, 1,\n",
    "       0, 0, 2, 2, 2, 0, 1, 0, 1, 1, 2, 2, 1, 2, 1, 1, 1, 1, 0, 1, 0, 1,\n",
    "       1, 0, 1, 0, 1, 0, 0, 0, 2, 1, 1, 1, 2, 1, 1, 2, 2, 2, 0, 1, 2, 1,\n",
    "       2, 2, 0, 0, 0, 2, 1, 2, 1, 2, 2, 0, 1, 1, 0, 1, 0, 1, 1, 2, 2, 2,\n",
    "       1, 2, 1, 0, 0, 2, 0, 0, 0, 1, 0, 2, 1, 0, 2, 1, 1, 1, 1, 1, 0, 1,\n",
    "       2, 1, 1, 1, 1, 2, 1, 0, 1, 1, 2, 2, 2, 2, 2, 1, 1, 2, 2, 0, 1, 2,\n",
    "       1, 2, 0, 1, 2, 1, 2, 1, 2, 1, 0, 0, 0, 2, 1, 1, 1, 2, 2, 1, 2, 1,\n",
    "       2, 1, 0, 2, 2, 0, 1, 0, 1, 1, 2, 0, 2, 1, 1, 1, 1, 1, 1, 0, 1, 1,\n",
    "       2, 1, 0, 1, 1, 0, 0, 1, 1, 0, 2, 0, 2, 2, 1, 1, 1, 1, 1, 2, 1, 1,\n",
    "       1, 2, 0, 1, 1, 0, 1, 1, 0, 2, 0, 2, 1, 0, 1, 1, 1, 2, 1, 0, 1, 1,\n",
    "       0, 1, 1, 1, 1, 1, 2, 1, 2, 0, 0, 1, 2, 0, 2, 2, 0, 0, 2, 1, 2, 1,\n",
    "       0, 1, 1, 2, 0, 0, 1, 1])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "colab": {
     "base_uri": "https://localhost:8080/",
     "height": 1000
    },
    "colab_type": "code",
    "executionInfo": {
     "elapsed": 1361,
     "status": "ok",
     "timestamp": 1593050975823,
     "user": {
      "displayName": "Kevin Chen",
      "photoUrl": "",
      "userId": "13334341206008152383"
     },
     "user_tz": 420
    },
    "id": "OziMm7WOLMm2",
    "outputId": "6cf8fbc0-b9d3-4e6f-f4b4-f64630942a48"
   },
   "outputs": [],
   "source": [
    "vids = sorted(glob.glob('./*.mp4'))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "colab": {},
    "colab_type": "code",
    "executionInfo": {
     "elapsed": 322,
     "status": "ok",
     "timestamp": 1593052171218,
     "user": {
      "displayName": "Kevin Chen",
      "photoUrl": "",
      "userId": "13334341206008152383"
     },
     "user_tz": 420
    },
    "id": "L2MDbMNCLmrK"
   },
   "outputs": [],
   "source": [
    "categories = {0: 'Positive', 1: 'Neutral', 2: 'Negative'}\n",
    "for i in range(len(vids)):\n",
    "    path = vids[i].replace('.mp4', '.txt')\n",
    "    with open(path, 'w') as output:\n",
    "        pred = y_pred_final[i]\n",
    "        cat = categories[pred]\n",
    "        output.write(cat)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {
    "colab": {},
    "colab_type": "code",
    "executionInfo": {
     "elapsed": 1886,
     "status": "ok",
     "timestamp": 1593052281219,
     "user": {
      "displayName": "Kevin Chen",
      "photoUrl": "",
      "userId": "13334341206008152383"
     },
     "user_tz": 420
    },
    "id": "y_Xh4Li6TDrk"
   },
   "outputs": [],
   "source": [
    "from zipfile import ZipFile"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "colab": {},
    "colab_type": "code",
    "id": "LV_cDGt7UkuI"
   },
   "outputs": [],
   "source": [
    "file_paths = glob.glob('Test_*.txt')\n",
    "with ZipFile('Stanford231_2.zip','w') as zip: \n",
    "    # writing each file one by one \n",
    "    for file in file_paths: \n",
    "        zip.write(file) "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "colab": {
   "authorship_tag": "ABX9TyP6b+Sz/gTVxjVAvy0PlKH9",
   "name": "Submit.ipynb",
   "provenance": []
  },
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 1
}
