{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "e424ac3f",
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "import collections"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "99457d31",
   "metadata": {},
   "outputs": [],
   "source": [
    "plots=pd.read_csv('tagsText.tsv', sep='\\t')\n",
    "plots1=pd.read_csv('tagsText1.tsv', sep='\\t')\n",
    "plots=plots.append(plots1, ignore_index=True)\n",
    "del plots1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "4a8f3e76",
   "metadata": {},
   "outputs": [],
   "source": [
    "plotTags=pd.read_csv('plot_tags.tsv', sep='\\t')\n",
    "plotTags1=pd.read_csv('plot_tags1.tsv', sep='\\t')\n",
    "plotTags=plotTags.append(plotTags1, ignore_index=True)\n",
    "del plotTags1"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "id": "18ec90b2",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "id": "33a12c29",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "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>titleId</th>\n",
       "      <th>title</th>\n",
       "      <th>genres</th>\n",
       "      <th>TagsText</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>tt0111161</td>\n",
       "      <td>The Shawshank Redemption</td>\n",
       "      <td>Drama</td>\n",
       "      <td>Drama The Shawshank Redemption wrongful impris...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>tt0468569</td>\n",
       "      <td>The Dark Knight</td>\n",
       "      <td>Action Crime Drama</td>\n",
       "      <td>Action Crime Drama The Dark Knight dc comics j...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>tt1375666</td>\n",
       "      <td>Inception</td>\n",
       "      <td>Action Adventure Sci-Fi</td>\n",
       "      <td>Action Adventure Sci-Fi Inception dream ambigu...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>tt0137523</td>\n",
       "      <td>Fight Club</td>\n",
       "      <td>Drama</td>\n",
       "      <td>Drama Fight Club fighting surprise ending anti...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>tt0110912</td>\n",
       "      <td>Pulp Fiction</td>\n",
       "      <td>Crime Drama</td>\n",
       "      <td>Crime Drama Pulp Fiction nonlinear timeline ov...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3995</th>\n",
       "      <td>tt0020530</td>\n",
       "      <td>Un chien andalou</td>\n",
       "      <td>Fantasy Horror Short</td>\n",
       "      <td>Fantasy Horror Short Un chien andalou surreali...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3996</th>\n",
       "      <td>tt0117918</td>\n",
       "      <td>Tin Cup</td>\n",
       "      <td>Comedy Drama Romance</td>\n",
       "      <td>Comedy Drama Romance Tin Cup golf nickname lov...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3997</th>\n",
       "      <td>tt0123964</td>\n",
       "      <td>Life</td>\n",
       "      <td>Comedy Crime Drama</td>\n",
       "      <td>Comedy Crime Drama Life baseball year 1932 wro...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3998</th>\n",
       "      <td>tt0110950</td>\n",
       "      <td>Reality Bites</td>\n",
       "      <td>Comedy Drama Romance</td>\n",
       "      <td>Comedy Drama Romance Reality Bites generation ...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3999</th>\n",
       "      <td>tt1017451</td>\n",
       "      <td>The Runaways</td>\n",
       "      <td>Biography Drama Music</td>\n",
       "      <td>Biography Drama Music The Runaways f rated rev...</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>4000 rows × 4 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "        titleId                     title                   genres  \\\n",
       "0     tt0111161  The Shawshank Redemption                    Drama   \n",
       "1     tt0468569           The Dark Knight       Action Crime Drama   \n",
       "2     tt1375666                 Inception  Action Adventure Sci-Fi   \n",
       "3     tt0137523                Fight Club                    Drama   \n",
       "4     tt0110912              Pulp Fiction              Crime Drama   \n",
       "...         ...                       ...                      ...   \n",
       "3995  tt0020530          Un chien andalou     Fantasy Horror Short   \n",
       "3996  tt0117918                   Tin Cup     Comedy Drama Romance   \n",
       "3997  tt0123964                      Life       Comedy Crime Drama   \n",
       "3998  tt0110950             Reality Bites     Comedy Drama Romance   \n",
       "3999  tt1017451              The Runaways    Biography Drama Music   \n",
       "\n",
       "                                               TagsText  \n",
       "0     Drama The Shawshank Redemption wrongful impris...  \n",
       "1     Action Crime Drama The Dark Knight dc comics j...  \n",
       "2     Action Adventure Sci-Fi Inception dream ambigu...  \n",
       "3     Drama Fight Club fighting surprise ending anti...  \n",
       "4     Crime Drama Pulp Fiction nonlinear timeline ov...  \n",
       "...                                                 ...  \n",
       "3995  Fantasy Horror Short Un chien andalou surreali...  \n",
       "3996  Comedy Drama Romance Tin Cup golf nickname lov...  \n",
       "3997  Comedy Crime Drama Life baseball year 1932 wro...  \n",
       "3998  Comedy Drama Romance Reality Bites generation ...  \n",
       "3999  Biography Drama Music The Runaways f rated rev...  \n",
       "\n",
       "[4000 rows x 4 columns]"
      ]
     },
     "execution_count": 25,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "movies= pd.read_csv('Final Dataa.tsv', sep= '\\t')\n",
    "movies=movies[['titleId', 'title','genres']].merge(plots, left_index=True, right_index=True)\n",
    "movies.rename(columns={'0':'TagsText'},inplace=True)\n",
    "\n",
    "movies.genres=movies.genres.str.replace(',', ' ')\n",
    "movies.TagsText= movies.genres+' '+movies.title+' '+movies.TagsText\n",
    "movies"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "id": "e04517c8",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "de9c8e0f",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "edac3b3b",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "id": "01b593b5",
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "C:\\Users\\PC\\anaconda3\\lib\\site-packages\\gensim\\similarities\\__init__.py:15: UserWarning: The gensim.similarities.levenshtein submodule is disabled, because the optional Levenshtein package <https://pypi.org/project/python-Levenshtein/> is unavailable. Install Levenhstein (e.g. `pip install python-Levenshtein`) to suppress this warning.\n",
      "  warnings.warn(msg)\n"
     ]
    }
   ],
   "source": [
    "from nltk.tokenize import wordpunct_tokenize\n",
    "from nltk.tokenize import word_tokenize\n",
    "import spacy\n",
    "nlp= spacy.load('en_core_web_sm')\n",
    "from nltk.corpus import stopwords\n",
    "from gensim.utils import simple_preprocess\n",
    "stopwords= stopwords.words('english')\n",
    "stopwords.extend(['nude','nudity','male','female','men','women','boy','girl','age','frontal','pubic','woman','man','hair',\\\n",
    "                 'underwear', 'pant','sex',\"'s\", 'aaaxxxyyy','sexual'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "b02317f1",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "id": "ac78a85e",
   "metadata": {},
   "outputs": [],
   "source": [
    "words=[]\n",
    "def preprocess(text):\n",
    "    text=' '.join(simple_preprocess(text, deacc= True))\n",
    "    doc= nlp(text)\n",
    "    text=[]\n",
    "    for token in doc:\n",
    "        lemma= token.lemma_\n",
    "        if lemma not in stopwords:\n",
    "            text.append(lemma)\n",
    "            if lemma not in words and len(lemma)> 3:\n",
    "                words.append(lemma)\n",
    "    text=' '.join(text)\n",
    "    \n",
    "    return text\n",
    "\n",
    "\n",
    "\n",
    "movies.TagsText=movies.TagsText.apply(lambda x: preprocess(x))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "239dd339",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "id": "532dd0fc",
   "metadata": {},
   "outputs": [],
   "source": [
    "plots=movies.TagsText.to_numpy()\n",
    "words= list(set(words))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "26011475",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "dc2c03c8",
   "metadata": {},
   "outputs": [],
   "source": [
    "    "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "64457f2f",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "6147f3d8",
   "metadata": {},
   "outputs": [],
   "source": [
    "#vector matrix is which word in which plot and how many times"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 192,
   "id": "2788c62e",
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "vector_matrix= pd.DataFrame(np.zeros(( len(movies) , len(words)  )), columns=words, index= movies.TagsText)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "93faa48b",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 193,
   "id": "2a2be687",
   "metadata": {},
   "outputs": [],
   "source": [
    "def word_counter(column):\n",
    "    word=column.name\n",
    "    #print(word)\n",
    "    texts= movies.TagsText.to_numpy()\n",
    "    score=[]\n",
    "    for i, text in enumerate(texts):\n",
    "        \n",
    "        c=text.count(word)\n",
    "        score.append(c)\n",
    "    return score\n",
    "\n",
    "\n",
    "vector_matrix= vector_matrix.apply(lambda x: word_counter(x))\n",
    "#vector_matrix=vector_matrix[vector_matrix>0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "32aa8c6d",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "34e61472",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 194,
   "id": "7e8104ef",
   "metadata": {},
   "outputs": [],
   "source": [
    "def word_freq(x, minimum_freq=3):\n",
    "    x=x[x>2]\n",
    "    y=x.describe().T\n",
    "    y=y[y['count']> minimum_freq].T.dropna(axis=1).columns\n",
    "    return x[y].fillna(0)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 195,
   "id": "71a88d5c",
   "metadata": {},
   "outputs": [],
   "source": [
    "vector_matrix=word_freq(vector_matrix)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 196,
   "id": "17b56edd",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "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>mori</th>\n",
       "      <th>accident</th>\n",
       "      <th>captain</th>\n",
       "      <th>sever</th>\n",
       "      <th>gare</th>\n",
       "      <th>mach</th>\n",
       "      <th>hick</th>\n",
       "      <th>father</th>\n",
       "      <th>light</th>\n",
       "      <th>dream</th>\n",
       "      <th>...</th>\n",
       "      <th>make</th>\n",
       "      <th>fish</th>\n",
       "      <th>ender</th>\n",
       "      <th>potter</th>\n",
       "      <th>versus</th>\n",
       "      <th>cigarette</th>\n",
       "      <th>alter</th>\n",
       "      <th>line</th>\n",
       "      <th>government</th>\n",
       "      <th>museum</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>TagsText</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></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>drama shawshank redemption wrongful imprisonment base work stephen king prison escape prison voice narration police brutality prison cell search friendship infidelity suicide suicide villain cheat wife harlot wrongful conviction suicide hang life imprisonment unfaithful wife base novella plot twist prison yard reference rita hayworth tunneling freedom prison guard wall betrayer pig loose easy imprisonment carve tin box reference fort hancock texas voice letter maggot trial suicide gunshot suicide friend miss prisoner solitary confinement surprise end stand rita hayworth poster prison library first person narration parole board parole hear assault gay rape banker shower room talk bird vinyl record betting watch movie record player biblical quote masterpiece shawshank</th>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>...</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>action crime drama dark knight dc comic_strip joker psychopath clown criminal mastermind scarred face superhero moral dilemma clown mask dual identity psychological manipulation base comic book evil clown opening action scene disfigurement batmobile electronic music score second part mob boss star die release organize crime hero evil sequel sequel reboot joker character urban set money love triangle skyscraper mobster human monster race time super villain jujitsu face paint clown face billionaire tragic hero batman character bruce wayne character batman joker neo noir villain chaos presume dead alfred pennyworth character barbara gordon character harvey dent character opening credit electronic music score style orchestral music score title begin title end district attorney coin flip mysterious tragic past stylize violence grenade henchman</th>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>...</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>action adventure sci fi inception dream ambiguous end subconscious surprise end mindbender psycho thriller strong character architecture psychological manipulation fall height hero strong lead architect fantasy become reality deception kidnapping write director child suspense marriage suicide memory suicide attempt spin top title speak character title end character repeat someone else dialogue dream sequence dream sequence within dream sequence dream within dream elevator airplane guilt dream within dream within dream bathtub hotel bar train corporate espionage neo noir alter version studio logo nonlinear timeline haunt past van disguise jump height hallway tie chair hostage manipulation ensemble cast death revenge ambiguity produce director night underwater scene brawl sniper building collapse</th>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>9.0</td>\n",
       "      <td>...</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>drama fight club fight surprise end anti establishment insomnia multiple personality disorder base novel group therapy anti conformity anti capitalism disturb individual ikea black comedy graphic violence self destructiveness suicide attempt consumerism plot twist alter ego homoerotic break fourth wall dissociative identity disorder desire anti social behavior loss control mental instability alienation imaginary friend violence scene masochism cult film anti hero testicular cancer base book sadomasochism philosophy unreliable narrator schizophrenia overhear cult classic self injury famous twist soap fight support group control rage missionary position missionary position listen breast exam sound dream manic pixie dream underground sport breast drunkenness title fight beat pulp attraction</th>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>...</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>crime drama pulp fiction nonlinear timeline overdose drug overdose drug use bondage drug deal neo noir rape car accident dance contest black comedy violence rapist shootout drug dealer postmodern gangster restaurant robbery corpse marijuana joint organize crime boxer violence rape anal rape cunnilingus slave oral motel multiple perspective torture bible quote bind gag multiple storyline ensemble cast serial rapist professional killer anthology mini dress pantie blue pantie white pantie katana tie chair ball gag hit car strip club double cross run drug snort murder heroin cult film dark comedy restaurant briefcase imply cunnilingus scantily clothe problem solver</th>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>...</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>3.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>fantasy horror short un chien andalou surrealism donkey breast fondle eye injury ant piano grand piano bicycle accident full moon experimental film gun nonlinear timeline mutilation avant garde cult film anti clericalism moon oneiric nihilism razor straight razor sever hand priest androgynous character androgynous death box desire unshaved armpit armpit absurdism controversy territory name title animal title midnight movie transvestism murder hit car fondle corpse carcass bicycle armpit</th>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>...</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>comedy drama romance tin cup golf nickname love kiss friend rivalry texas psychologist arrogance wager temper golf movie car automobile convertible car cadillac cadillac motor vehicle cadillac convertible japanese car nissan nissan motor vehicle nissan convertible nissan zx motorhome winnebago winnebago indian golf lesson golf tournament golf player golf course golf club golf ball title speak character</th>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>...</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>comedy crime drama life baseball year wrongful conviction passage time wrongful imprisonment black comedy flashback sheriff mississippi life imprisonment criminal watch great depression hold gunpoint friendship word profanity prison violence pump action shotgun winchester rifle repeat rifle comic violence violence bare knuckle fighting fistfight prison fight bully bully comeuppance obesity false accusation racist racial injustice prison life prison labor prison guard prison farm prison escape prison cell new york city jail fat escape attempt death affection bootlegging bootlegger bootleg liquor interracial relationship segregation crop duster racism blooper credit poker friendship prison southern african american pie</th>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>...</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>comedy drama romance reality bite generation houston texas texas nipple visible clothing vito russo test pass imply car crash smoking marijuana reference bill clinton romantic triangle clothing store roommate aid test television studio morning talk show cue card pilot show slacker rock band argument chicago illinois romantic reconciliation credit card debt fire job love valedictorian directorial debut two word title college fictional reality show college graduation teen movie twenty something track friendship video footage medium hype cult film</th>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>...</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>biography drama music runaway rate revisionist history triple rate feminist film cherry bomb high heel crush pill crush pill feminism band rock star guitarist friend drummer vodka tour publicity band japan drug rock band band member rock roll coming reference beatle strong lead strong character teen movie nightclub leather record player masturbation stage performance stage song singing singer rock musician rock group rock concert roadtrip recording reconciliation pill abuse party paint face road music industry musician music group music concert music business money microphone mend friendship listen music leave home guitar player grow</th>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>...</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "      <td>0.0</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>4000 rows × 981 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "                                                    mori  accident  captain  \\\n",
       "TagsText                                                                      \n",
       "drama shawshank redemption wrongful imprisonmen...   0.0       0.0      0.0   \n",
       "action crime drama dark knight dc comic_strip j...   0.0       0.0      0.0   \n",
       "action adventure sci fi inception dream ambiguo...   0.0       0.0      0.0   \n",
       "drama fight club fight surprise end anti establ...   0.0       0.0      0.0   \n",
       "crime drama pulp fiction nonlinear timeline ove...   0.0       0.0      0.0   \n",
       "...                                                  ...       ...      ...   \n",
       "fantasy horror short un chien andalou surrealis...   0.0       0.0      0.0   \n",
       "comedy drama romance tin cup golf nickname love...   0.0       0.0      0.0   \n",
       "comedy crime drama life baseball year wrongful ...   0.0       0.0      0.0   \n",
       "comedy drama romance reality bite generation ho...   0.0       0.0      0.0   \n",
       "biography drama music runaway rate revisionist ...   0.0       0.0      0.0   \n",
       "\n",
       "                                                    sever  gare  mach  hick  \\\n",
       "TagsText                                                                      \n",
       "drama shawshank redemption wrongful imprisonmen...    0.0   0.0   0.0   0.0   \n",
       "action crime drama dark knight dc comic_strip j...    0.0   0.0   0.0   0.0   \n",
       "action adventure sci fi inception dream ambiguo...    0.0   0.0   0.0   0.0   \n",
       "drama fight club fight surprise end anti establ...    0.0   0.0   0.0   0.0   \n",
       "crime drama pulp fiction nonlinear timeline ove...    0.0   0.0   0.0   0.0   \n",
       "...                                                   ...   ...   ...   ...   \n",
       "fantasy horror short un chien andalou surrealis...    0.0   0.0   0.0   0.0   \n",
       "comedy drama romance tin cup golf nickname love...    0.0   0.0   0.0   0.0   \n",
       "comedy crime drama life baseball year wrongful ...    0.0   0.0   0.0   0.0   \n",
       "comedy drama romance reality bite generation ho...    0.0   0.0   0.0   0.0   \n",
       "biography drama music runaway rate revisionist ...    0.0   0.0   0.0   0.0   \n",
       "\n",
       "                                                    father  light  dream  ...  \\\n",
       "TagsText                                                                  ...   \n",
       "drama shawshank redemption wrongful imprisonmen...     0.0    0.0    0.0  ...   \n",
       "action crime drama dark knight dc comic_strip j...     0.0    0.0    0.0  ...   \n",
       "action adventure sci fi inception dream ambiguo...     0.0    0.0    9.0  ...   \n",
       "drama fight club fight surprise end anti establ...     0.0    0.0    0.0  ...   \n",
       "crime drama pulp fiction nonlinear timeline ove...     0.0    0.0    0.0  ...   \n",
       "...                                                    ...    ...    ...  ...   \n",
       "fantasy horror short un chien andalou surrealis...     0.0    0.0    0.0  ...   \n",
       "comedy drama romance tin cup golf nickname love...     0.0    0.0    0.0  ...   \n",
       "comedy crime drama life baseball year wrongful ...     0.0    0.0    0.0  ...   \n",
       "comedy drama romance reality bite generation ho...     0.0    0.0    0.0  ...   \n",
       "biography drama music runaway rate revisionist ...     0.0    0.0    0.0  ...   \n",
       "\n",
       "                                                    make  fish  ender  potter  \\\n",
       "TagsText                                                                        \n",
       "drama shawshank redemption wrongful imprisonmen...   0.0   0.0    0.0     0.0   \n",
       "action crime drama dark knight dc comic_strip j...   0.0   0.0    0.0     0.0   \n",
       "action adventure sci fi inception dream ambiguo...   0.0   0.0    0.0     0.0   \n",
       "drama fight club fight surprise end anti establ...   0.0   0.0    0.0     0.0   \n",
       "crime drama pulp fiction nonlinear timeline ove...   0.0   0.0    0.0     0.0   \n",
       "...                                                  ...   ...    ...     ...   \n",
       "fantasy horror short un chien andalou surrealis...   0.0   0.0    0.0     0.0   \n",
       "comedy drama romance tin cup golf nickname love...   0.0   0.0    0.0     0.0   \n",
       "comedy crime drama life baseball year wrongful ...   0.0   0.0    0.0     0.0   \n",
       "comedy drama romance reality bite generation ho...   0.0   0.0    0.0     0.0   \n",
       "biography drama music runaway rate revisionist ...   0.0   0.0    0.0     0.0   \n",
       "\n",
       "                                                    versus  cigarette  alter  \\\n",
       "TagsText                                                                       \n",
       "drama shawshank redemption wrongful imprisonmen...     0.0        0.0    0.0   \n",
       "action crime drama dark knight dc comic_strip j...     0.0        0.0    0.0   \n",
       "action adventure sci fi inception dream ambiguo...     0.0        0.0    0.0   \n",
       "drama fight club fight surprise end anti establ...     0.0        0.0    0.0   \n",
       "crime drama pulp fiction nonlinear timeline ove...     0.0        0.0    0.0   \n",
       "...                                                    ...        ...    ...   \n",
       "fantasy horror short un chien andalou surrealis...     0.0        0.0    0.0   \n",
       "comedy drama romance tin cup golf nickname love...     0.0        0.0    0.0   \n",
       "comedy crime drama life baseball year wrongful ...     0.0        0.0    0.0   \n",
       "comedy drama romance reality bite generation ho...     0.0        0.0    0.0   \n",
       "biography drama music runaway rate revisionist ...     0.0        0.0    0.0   \n",
       "\n",
       "                                                    line  government  museum  \n",
       "TagsText                                                                      \n",
       "drama shawshank redemption wrongful imprisonmen...   0.0         0.0     0.0  \n",
       "action crime drama dark knight dc comic_strip j...   0.0         0.0     0.0  \n",
       "action adventure sci fi inception dream ambiguo...   0.0         0.0     0.0  \n",
       "drama fight club fight surprise end anti establ...   0.0         0.0     0.0  \n",
       "crime drama pulp fiction nonlinear timeline ove...   3.0         0.0     0.0  \n",
       "...                                                  ...         ...     ...  \n",
       "fantasy horror short un chien andalou surrealis...   0.0         0.0     0.0  \n",
       "comedy drama romance tin cup golf nickname love...   0.0         0.0     0.0  \n",
       "comedy crime drama life baseball year wrongful ...   0.0         0.0     0.0  \n",
       "comedy drama romance reality bite generation ho...   0.0         0.0     0.0  \n",
       "biography drama music runaway rate revisionist ...   0.0         0.0     0.0  \n",
       "\n",
       "[4000 rows x 981 columns]"
      ]
     },
     "execution_count": 196,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "vector_matrix"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "cbdde7da",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "88a76a5e",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "c553a9b8",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "e5856b25",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "4084066c",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 197,
   "id": "95110c7b",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "b416190d",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "934b372c",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "9c27a357",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 204,
   "id": "a8f7d694",
   "metadata": {},
   "outputs": [],
   "source": [
    "movie_index=28\n",
    "input_vector= vector_matrix.iloc[movie_index , :].to_numpy()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "d9312665",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 205,
   "id": "ea88d1b8",
   "metadata": {},
   "outputs": [],
   "source": [
    "distance=[]\n",
    "def dis(vector):\n",
    "    vector=vector.to_numpy()\n",
    "    distance.append(pow(pow((input_vector-vector),2).sum(),1/2))\n",
    "\n",
    "z=vector_matrix.T.apply(lambda x: dis(x))\n",
    "del z\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "c564a7f5",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "1f06e257",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "4624357f",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "7ce581e8",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 206,
   "id": "ed98a02b",
   "metadata": {},
   "outputs": [],
   "source": [
    "movies['distance']= pd.Series(distance)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "ba28b470",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 207,
   "id": "420b16a0",
   "metadata": {},
   "outputs": [],
   "source": [
    "result=movies.sort_values(by='distance').reset_index()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 208,
   "id": "aa7accf0",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "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>index</th>\n",
       "      <th>titleId</th>\n",
       "      <th>title</th>\n",
       "      <th>genres</th>\n",
       "      <th>TagsText</th>\n",
       "      <th>distance</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>28</td>\n",
       "      <td>tt0080684</td>\n",
       "      <td>Star Wars: Episode V - The Empire Strikes Back</td>\n",
       "      <td>Action Adventure Fantasy</td>\n",
       "      <td>action adventure fantasy star war episode empi...</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>199</td>\n",
       "      <td>tt3748528</td>\n",
       "      <td>Rogue One</td>\n",
       "      <td>Action Adventure Sci-Fi</td>\n",
       "      <td>action adventure sci fi rogue one star war los...</td>\n",
       "      <td>5.385165</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>9</td>\n",
       "      <td>tt0167260</td>\n",
       "      <td>The Lord of the Rings: The Return of the King</td>\n",
       "      <td>Action Adventure Drama</td>\n",
       "      <td>action adventure drama lord ring return king e...</td>\n",
       "      <td>6.403124</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>153</td>\n",
       "      <td>tt0126029</td>\n",
       "      <td>Shrek</td>\n",
       "      <td>Adventure Animation Comedy</td>\n",
       "      <td>adventure animation comedy shrek onion epic ex...</td>\n",
       "      <td>6.403124</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>3260</td>\n",
       "      <td>tt3332064</td>\n",
       "      <td>Pan</td>\n",
       "      <td>Adventure Comedy Family</td>\n",
       "      <td>adventure comedy family pan orphan child hero ...</td>\n",
       "      <td>7.615773</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   index    titleId                                           title  \\\n",
       "0     28  tt0080684  Star Wars: Episode V - The Empire Strikes Back   \n",
       "1    199  tt3748528                                       Rogue One   \n",
       "2      9  tt0167260   The Lord of the Rings: The Return of the King   \n",
       "3    153  tt0126029                                           Shrek   \n",
       "4   3260  tt3332064                                             Pan   \n",
       "\n",
       "                       genres  \\\n",
       "0    Action Adventure Fantasy   \n",
       "1     Action Adventure Sci-Fi   \n",
       "2      Action Adventure Drama   \n",
       "3  Adventure Animation Comedy   \n",
       "4     Adventure Comedy Family   \n",
       "\n",
       "                                            TagsText  distance  \n",
       "0  action adventure fantasy star war episode empi...  0.000000  \n",
       "1  action adventure sci fi rogue one star war los...  5.385165  \n",
       "2  action adventure drama lord ring return king e...  6.403124  \n",
       "3  adventure animation comedy shrek onion epic ex...  6.403124  \n",
       "4  adventure comedy family pan orphan child hero ...  7.615773  "
      ]
     },
     "execution_count": 208,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "result[:5]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "23bad1af",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "aeb571a9",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "e8c3ee90",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "ae0b6473",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 115,
   "id": "69b6200b",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "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>titleId</th>\n",
       "      <th>title</th>\n",
       "      <th>genres</th>\n",
       "      <th>TagsText</th>\n",
       "      <th>distance</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2824</th>\n",
       "      <td>tt0851578</td>\n",
       "      <td>Papurika</td>\n",
       "      <td>Animation Drama Fantasy</td>\n",
       "      <td>animation drama fantasy papurika lucid dream v...</td>\n",
       "      <td>18.788294</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "        titleId     title                   genres  \\\n",
       "2824  tt0851578  Papurika  Animation Drama Fantasy   \n",
       "\n",
       "                                               TagsText   distance  \n",
       "2824  animation drama fantasy papurika lucid dream v...  18.788294  "
      ]
     },
     "execution_count": 115,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "movies[movies.title=='Papurika']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "672a601f",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "1584bb35",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "9b8a8a67",
   "metadata": {},
   "outputs": [],
   "source": [
    "print(empty_df.columns)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "df02afdd",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "e6d5e48a",
   "metadata": {},
   "outputs": [],
   "source": [
    "movies.iloc[:10,:1]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "3b2570ed",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "9346a2b1",
   "metadata": {},
   "outputs": [],
   "source": [
    "def find(word, text):\n",
    "    return text.count(word)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "c0f5d740",
   "metadata": {},
   "outputs": [],
   "source": [
    "def word_text(index_no, column_no):\n",
    "    return words[ndex_no], a.columns[column_no]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "04677df3",
   "metadata": {},
   "outputs": [],
   "source": [
    "def my_fun(n):\n",
    "    if n%2 !=0:\n",
    "        print(n)\n",
    "        n=1\n",
    "    return n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "f2dc1e77",
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np \n",
    "\n",
    "x = np.array([1, 2, 3, 4, 5]) \n",
    "\n",
    "squarer = lambda t: my_fun(t)\n",
    "\n",
    "vfunc = np.vectorize(squarer) \n",
    "\n",
    "vfunc(x)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "aabb6940",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "94ec6318",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "247bbd42",
   "metadata": {},
   "outputs": [],
   "source": [
    "s=\"hi, shubham's cat is mysteriously hairs joyful panties opening sex without hairs.\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "6a2af7b3",
   "metadata": {},
   "outputs": [],
   "source": [
    "s.count('hairs')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "354c834a",
   "metadata": {},
   "outputs": [],
   "source": [
    "preprocess(s)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "116f613d",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "f94c0abd",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "73ade13e",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "d5a9c6cd",
   "metadata": {},
   "outputs": [],
   "source": [
    "import spacy\n",
    "from spacytextblob.spacytextblob import SpacyTextBlob\n",
    "\n",
    "nlp = spacy.load('en_core_web_sm')\n",
    "nlp.add_pipe('spacytextblob')\n",
    "text = 'I had a really horrible day. It was the worst day ever! But every now and then I have a really good day that makes me happy.'\n",
    "doc = nlp(movies.iloc[0,-1])\n",
    "doc._.polarity      # Polarity: -0.125\n",
    "doc._.subjectivity  # Sujectivity: 0.9\n",
    "doc._.assessments"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "015ceb5e",
   "metadata": {},
   "outputs": [],
   "source": [
    "a=np.array([1,2,5])\n",
    "b=np.array([2,3,4])\n",
    "c=np.array([4,2.5,4.5])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "a2f851f1",
   "metadata": {},
   "outputs": [],
   "source": [
    "pow(pow((a-b),2).sum(),1/2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "60e6a537",
   "metadata": {},
   "outputs": [],
   "source": [
    "pow(pow((a-c),2).sum(),1/2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "f4b016d5",
   "metadata": {},
   "outputs": [],
   "source": [
    "pow(pow((c-b),2).sum(),1/2)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "6dc3cea8",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "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.8.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
