{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "7f9e8728",
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "import stanza\n",
    "import numpy as np\n",
    "from stanza.models.common.doc import Word"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "302ae754",
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "2022-05-27 22:12:51 INFO: Loading these models for language: hu (Hungarian):\n",
      "=======================\n",
      "| Processor | Package |\n",
      "-----------------------\n",
      "| tokenize  | szeged  |\n",
      "| pos       | szeged  |\n",
      "| lemma     | szeged  |\n",
      "| depparse  | szeged  |\n",
      "=======================\n",
      "\n",
      "2022-05-27 22:12:51 INFO: Use device: cpu\n",
      "2022-05-27 22:12:51 INFO: Loading: tokenize\n",
      "2022-05-27 22:12:52 INFO: Loading: pos\n",
      "2022-05-27 22:12:52 INFO: Loading: lemma\n",
      "2022-05-27 22:12:52 INFO: Loading: depparse\n",
      "2022-05-27 22:12:52 INFO: Done loading processors!\n"
     ]
    }
   ],
   "source": [
    "nlp=stanza.Pipeline(\"hu\",processors='tokenize,pos,lemma,depparse')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "4d8d3739",
   "metadata": {},
   "outputs": [],
   "source": [
    "text=\"Mi nem vagyunk magyarok.\"\n",
    "text=\"− Én sem értem, hogy miért keresek ma mindent.\"\n",
    "text=\"Koridor itu beraroma kubis rebus dan karpet butut.\"\n",
    "text=\"Pada mulanya, waktu Allah mulai menciptakan alam semesta\"\n",
    "text='dan dinamakan-Nya terang itu \"Siang\" dan gelap itu \"Malam\"'\n",
    "text=\"Koridor itu beraroma kubisnya rebus dan karpet butut.\"\n",
    "text=\"Apakah Allah benar-benar, melarang :e: terbesar terjelas kalian-nya makan buah-buahan dari segala pohon di taman ini?\"\n",
    "text=\"WAKTU itu musim semi tahun 1894. Seluruh dikenal dilakukan penduduk kota London gempar atas terbunuhnya\"\n",
    "text=\"A nagyon szép nőhöz megyem. kitörésröl kitörésekre Amerikából\"\n",
    "text= \"Kazahsztánban a mai kazak nyelv cirill betűs írást használ.\"# Közeli rokonai a kirgiz, a tatár, a baskír, valamint a kihalt besenyő és kun nyelvek.\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "e34d01e4",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "4eb2a3dc",
   "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>id</th>\n",
       "      <th>text</th>\n",
       "      <th>lemma</th>\n",
       "      <th>upos</th>\n",
       "      <th>feats</th>\n",
       "      <th>head</th>\n",
       "      <th>deprel</th>\n",
       "      <th>start_char</th>\n",
       "      <th>end_char</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1</td>\n",
       "      <td>Kazahsztánban</td>\n",
       "      <td>Kazahsztán</td>\n",
       "      <td>PROPN</td>\n",
       "      <td>Case=Ine|Number=Sing</td>\n",
       "      <td>9</td>\n",
       "      <td>obl</td>\n",
       "      <td>0</td>\n",
       "      <td>13</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>2</td>\n",
       "      <td>a</td>\n",
       "      <td>a</td>\n",
       "      <td>DET</td>\n",
       "      <td>Definite=Def|PronType=Art</td>\n",
       "      <td>5</td>\n",
       "      <td>det</td>\n",
       "      <td>14</td>\n",
       "      <td>15</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>3</td>\n",
       "      <td>mai</td>\n",
       "      <td>mai</td>\n",
       "      <td>ADJ</td>\n",
       "      <td>Case=Nom|Degree=Pos|Number=Sing</td>\n",
       "      <td>5</td>\n",
       "      <td>amod:att</td>\n",
       "      <td>16</td>\n",
       "      <td>19</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>4</td>\n",
       "      <td>kazak</td>\n",
       "      <td>kazak</td>\n",
       "      <td>ADJ</td>\n",
       "      <td>Case=Nom|Degree=Pos|Number=Sing</td>\n",
       "      <td>5</td>\n",
       "      <td>amod:att</td>\n",
       "      <td>20</td>\n",
       "      <td>25</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>5</td>\n",
       "      <td>nyelv</td>\n",
       "      <td>nyelv</td>\n",
       "      <td>NOUN</td>\n",
       "      <td>Case=Nom|Number=Sing</td>\n",
       "      <td>9</td>\n",
       "      <td>nsubj</td>\n",
       "      <td>26</td>\n",
       "      <td>31</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>6</td>\n",
       "      <td>cirill</td>\n",
       "      <td>cirill</td>\n",
       "      <td>ADJ</td>\n",
       "      <td>Case=Nom|Degree=Pos|Number=Sing</td>\n",
       "      <td>8</td>\n",
       "      <td>amod:att</td>\n",
       "      <td>32</td>\n",
       "      <td>38</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>7</td>\n",
       "      <td>betűs</td>\n",
       "      <td>betűs</td>\n",
       "      <td>ADJ</td>\n",
       "      <td>Case=Nom|Degree=Pos|Number=Sing</td>\n",
       "      <td>8</td>\n",
       "      <td>amod:att</td>\n",
       "      <td>39</td>\n",
       "      <td>44</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>8</td>\n",
       "      <td>írást</td>\n",
       "      <td>írás</td>\n",
       "      <td>NOUN</td>\n",
       "      <td>Case=Acc|Number=Sing</td>\n",
       "      <td>9</td>\n",
       "      <td>obj</td>\n",
       "      <td>45</td>\n",
       "      <td>50</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>9</td>\n",
       "      <td>használ</td>\n",
       "      <td>használ</td>\n",
       "      <td>VERB</td>\n",
       "      <td>Definite=Ind|Mood=Ind|Number=Sing|Person=3|Ten...</td>\n",
       "      <td>0</td>\n",
       "      <td>root</td>\n",
       "      <td>51</td>\n",
       "      <td>58</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>10</td>\n",
       "      <td>.</td>\n",
       "      <td>.</td>\n",
       "      <td>PUNCT</td>\n",
       "      <td>NaN</td>\n",
       "      <td>9</td>\n",
       "      <td>punct</td>\n",
       "      <td>58</td>\n",
       "      <td>59</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   id           text       lemma   upos  \\\n",
       "0   1  Kazahsztánban  Kazahsztán  PROPN   \n",
       "0   2              a           a    DET   \n",
       "0   3            mai         mai    ADJ   \n",
       "0   4          kazak       kazak    ADJ   \n",
       "0   5          nyelv       nyelv   NOUN   \n",
       "0   6         cirill      cirill    ADJ   \n",
       "0   7          betűs       betűs    ADJ   \n",
       "0   8          írást        írás   NOUN   \n",
       "0   9        használ     használ   VERB   \n",
       "0  10              .           .  PUNCT   \n",
       "\n",
       "                                               feats head    deprel  \\\n",
       "0                               Case=Ine|Number=Sing    9       obl   \n",
       "0                          Definite=Def|PronType=Art    5       det   \n",
       "0                    Case=Nom|Degree=Pos|Number=Sing    5  amod:att   \n",
       "0                    Case=Nom|Degree=Pos|Number=Sing    5  amod:att   \n",
       "0                               Case=Nom|Number=Sing    9     nsubj   \n",
       "0                    Case=Nom|Degree=Pos|Number=Sing    8  amod:att   \n",
       "0                    Case=Nom|Degree=Pos|Number=Sing    8  amod:att   \n",
       "0                               Case=Acc|Number=Sing    9       obj   \n",
       "0  Definite=Ind|Mood=Ind|Number=Sing|Person=3|Ten...    0      root   \n",
       "0                                                NaN    9     punct   \n",
       "\n",
       "  start_char end_char  \n",
       "0          0       13  \n",
       "0         14       15  \n",
       "0         16       19  \n",
       "0         20       25  \n",
       "0         26       31  \n",
       "0         32       38  \n",
       "0         39       44  \n",
       "0         45       50  \n",
       "0         51       58  \n",
       "0         58       59  "
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "doc = nlp(text) \n",
    "wordlist=pd.concat([pd.Series(word.to_dict()).to_frame().T for sentence in doc.sentences for word in sentence.words])\n",
    "wordlist"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "a9e0c2b2",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'Definite=Ind|Mood=Ind|Number=Sing|Person=3|Tense=Pres|VerbForm=Fin|Voice=Act'"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "wordlist.iloc[4][\"feats\"]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "id": "8468fa0b",
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/home/maxwell/.local/lib/python3.8/site-packages/pandas/core/series.py:1056: SettingWithCopyWarning: \n",
      "A value is trying to be set on a copy of a slice from a DataFrame\n",
      "\n",
      "See the caveats in the documentation: https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy\n",
      "  cacher_needs_updating = self._check_is_chained_assignment_possible()\n"
     ]
    },
    {
     "ename": "IndexError",
     "evalue": "string index out of range",
     "output_type": "error",
     "traceback": [
      "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[0;31mIndexError\u001b[0m                                Traceback (most recent call last)",
      "Input \u001b[0;32mIn [21]\u001b[0m, in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[1;32m     20\u001b[0m wordlist\u001b[38;5;241m.\u001b[39miloc[\u001b[38;5;241m0\u001b[39m][\u001b[38;5;124m'\u001b[39m\u001b[38;5;124mend_char_prev\u001b[39m\u001b[38;5;124m'\u001b[39m]\u001b[38;5;241m=\u001b[39m\u001b[38;5;241m0\u001b[39m\n\u001b[1;32m     21\u001b[0m wordlist[\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mseparator_prev\u001b[39m\u001b[38;5;124m\"\u001b[39m]\u001b[38;5;241m=\u001b[39mwordlist[[\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mend_char_prev\u001b[39m\u001b[38;5;124m\"\u001b[39m,\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mstart_char\u001b[39m\u001b[38;5;124m\"\u001b[39m]]\u001b[38;5;241m.\u001b[39mapply(\u001b[38;5;28;01mlambda\u001b[39;00m x: text[x[\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mend_char_prev\u001b[39m\u001b[38;5;124m\"\u001b[39m]:x[\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mstart_char\u001b[39m\u001b[38;5;124m\"\u001b[39m]], axis\u001b[38;5;241m=\u001b[39m\u001b[38;5;241m1\u001b[39m)\n\u001b[0;32m---> 23\u001b[0m sep_end\u001b[38;5;241m=\u001b[39m\u001b[43mtext\u001b[49m\u001b[43m[\u001b[49m\u001b[43mwordlist\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43miloc\u001b[49m\u001b[43m[\u001b[49m\u001b[38;5;241;43m-\u001b[39;49m\u001b[38;5;241;43m1\u001b[39;49m\u001b[43m]\u001b[49m\u001b[43m[\u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mend_char\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m]\u001b[49m\u001b[43m]\u001b[49m\n\u001b[1;32m     24\u001b[0m \u001b[38;5;28mprint\u001b[39m(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;241m.\u001b[39mjoin(\u001b[38;5;28mlist\u001b[39m(wordlist[\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mseparator_prev\u001b[39m\u001b[38;5;124m\"\u001b[39m]\u001b[38;5;241m+\u001b[39mwordlist[\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mtranslemma\u001b[39m\u001b[38;5;124m\"\u001b[39m])\u001b[38;5;241m+\u001b[39m[sep_end]))\n",
      "\u001b[0;31mIndexError\u001b[0m: string index out of range"
     ]
    }
   ],
   "source": [
    "folder=\"~/Desktop/Regina Phalange/Conlang/\"\n",
    "dic=pd.read_csv(folder+\"dict.csv\",sep=\";\")\n",
    "lemmadict=dict(zip(dic[\"lemma\"],dic[\"translation\"]))\n",
    "capitalize_get = lambda x : x[\"text\"][0].isupper()\n",
    "wordlist[\"capitalize\"] = wordlist[[\"text\"]].apply(capitalize_get, axis=1)\n",
    "capitalize_apply = lambda x,y : x[0].upper()+x[1:] if y else x\n",
    "def lemmadictget (x):\n",
    "    if x[\"upos\"]!=\"PUNCT\":\n",
    "        if x[\"lemma\"] in lemmadict.keys():\n",
    "            return capitalize_apply(lemmadict[x[\"lemma\"]], x[\"capitalize\"])\n",
    "        else:\n",
    "            return \"*\"+capitalize_apply(x[\"lemma\"], x[\"capitalize\"])\n",
    "    else:\n",
    "        return x[\"text\"]\n",
    "\n",
    "wordlist[\"translemma\"] = wordlist[[\"lemma\",\"upos\",\"text\",\"capitalize\"]].apply(lemmadictget, axis=1)\n",
    "\n",
    "\n",
    "wordlist['end_char_prev'] = np.roll(wordlist['end_char'],1)\n",
    "wordlist.iloc[0]['end_char_prev']=0\n",
    "wordlist[\"separator_prev\"]=wordlist[[\"end_char_prev\",\"start_char\"]].apply(lambda x: text[x[\"end_char_prev\"]:x[\"start_char\"]], axis=1)\n",
    "\n",
    "sep_end=text[wordlist.iloc[-1][\"end_char\"]]\n",
    "print(\"\".join(list(wordlist[\"separator_prev\"]+wordlist[\"translemma\"])+[sep_end]))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "3640f3d7",
   "metadata": {},
   "outputs": [],
   "source": [
    "\n",
    "\n",
    "# depict\n",
    "pd.set_option(\"display.max_rows\", None, \"display.max_columns\", None)\n",
    "print(wordlist)\n",
    "import networkx as nx\n",
    "import graphviz\n",
    "w = graphviz.Digraph()\n",
    "for i,row in wordlist.iterrows(): w.node(str(row[\"id\"]), \"\\n\".join(row[:-2].apply(str)))\n",
    "\n",
    "for i,row in wordlist.iterrows(): w.edge(str(row[\"id\"]), str(row[\"head\"]))\n",
    "\n",
    "w.render('test-output/round-table.gv', view=True)\n",
    "\n",
    "folder=\"~/Desktop/Regina Phalange/Conlang/\"\n",
    "dic=pd.read_csv(folder+\"dict.csv\",sep=\";\")\n",
    "lemmadict=dict(zip(dic[\"lemma\"],dic[\"translation\"]))\n",
    "capitalize_get = lambda x : x[\"text\"][0].isupper()\n",
    "wordlist[\"capitalize\"] = wordlist[[\"text\"]].apply(capitalize_get, axis=1)\n",
    "capitalize_apply = lambda x,y : x[0].upper()+x[1:] if y else x\n",
    "def lemmadictget (x):\n",
    "    if x[\"upos\"]!=\"PUNCT\":\n",
    "        if x[\"lemma\"] in lemmadict.keys():\n",
    "            return capitalize_apply(lemmadict[x[\"lemma\"]], x[\"capitalize\"])\n",
    "        else:\n",
    "            return \"*\"+capitalize_apply(x[\"lemma\"], x[\"capitalize\"])\n",
    "    else:\n",
    "        return x[\"text\"]\n",
    "\n",
    "wordlist[\"translemma\"] = wordlist[[\"lemma\",\"upos\",\"text\",\"capitalize\"]].apply(lemmadictget, axis=1)\n",
    "\n",
    "\n",
    "wordlist['end_char_prev'] = np.roll(wordlist['end_char'],1)\n",
    "wordlist.iloc[0]['end_char_prev']=0\n",
    "wordlist[\"separator_prev\"]=wordlist[[\"end_char_prev\",\"start_char\"]].apply(lambda x: text[x[\"end_char_prev\"]:x[\"start_char\"]], axis=1)\n",
    "\n",
    "sep_end=text[wordlist.iloc[-1][\"end_char\"]]\n",
    "print(\"\".join(list(wordlist[\"separator_prev\"]+wordlist[\"translemma\"])+[sep_end]))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 43,
   "id": "dbdf7be0",
   "metadata": {},
   "outputs": [],
   "source": [
    "import unimorph as um"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 46,
   "id": "7a0de9a6",
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "Cloning into 'ru'...\n",
      "fatal: could not read Username for 'https://github.com': No such device or address\n"
     ]
    },
    {
     "ename": "CalledProcessError",
     "evalue": "Command '['git', 'clone', 'https://github.com/unimorph/ru.git']' returned non-zero exit status 128.",
     "output_type": "error",
     "traceback": [
      "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[0;31mCalledProcessError\u001b[0m                        Traceback (most recent call last)",
      "Input \u001b[0;32mIn [46]\u001b[0m, in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0m \u001b[43mum\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mdownload_unimorph\u001b[49m\u001b[43m(\u001b[49m\u001b[43mlang\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mru\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m)\u001b[49m\n",
      "File \u001b[0;32m~/.local/lib/python3.8/site-packages/unimorph.py:67\u001b[0m, in \u001b[0;36mdownload_unimorph\u001b[0;34m(lang)\u001b[0m\n\u001b[1;32m     65\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m not_loaded(lang):\n\u001b[1;32m     66\u001b[0m     logging\u001b[38;5;241m.\u001b[39minfo(\u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mDownloading unimorph/\u001b[39m\u001b[38;5;132;01m{\u001b[39;00mlang\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m to \u001b[39m\u001b[38;5;132;01m{\u001b[39;00moutput_dir\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m\"\u001b[39m)\n\u001b[0;32m---> 67\u001b[0m     \u001b[43msubprocess\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mrun\u001b[49m\u001b[43m(\u001b[49m\n\u001b[1;32m     68\u001b[0m \u001b[43m        \u001b[49m\u001b[43m[\u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mgit\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mclone\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;124;43mf\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mhttps://github.com/unimorph/\u001b[39;49m\u001b[38;5;132;43;01m{\u001b[39;49;00m\u001b[43mlang\u001b[49m\u001b[38;5;132;43;01m}\u001b[39;49;00m\u001b[38;5;124;43m.git\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m]\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m     69\u001b[0m \u001b[43m        \u001b[49m\u001b[43mcheck\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;28;43;01mTrue\u001b[39;49;00m\u001b[43m,\u001b[49m\n\u001b[1;32m     70\u001b[0m \u001b[43m        \u001b[49m\u001b[43mcwd\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mUNIMORPH_DIR\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m     71\u001b[0m \u001b[43m    \u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m     72\u001b[0m \u001b[38;5;28;01massert\u001b[39;00m output_dir\u001b[38;5;241m.\u001b[39mis_dir()\n",
      "File \u001b[0;32m/usr/lib/python3.8/subprocess.py:516\u001b[0m, in \u001b[0;36mrun\u001b[0;34m(input, capture_output, timeout, check, *popenargs, **kwargs)\u001b[0m\n\u001b[1;32m    514\u001b[0m     retcode \u001b[38;5;241m=\u001b[39m process\u001b[38;5;241m.\u001b[39mpoll()\n\u001b[1;32m    515\u001b[0m     \u001b[38;5;28;01mif\u001b[39;00m check \u001b[38;5;129;01mand\u001b[39;00m retcode:\n\u001b[0;32m--> 516\u001b[0m         \u001b[38;5;28;01mraise\u001b[39;00m CalledProcessError(retcode, process\u001b[38;5;241m.\u001b[39margs,\n\u001b[1;32m    517\u001b[0m                                  output\u001b[38;5;241m=\u001b[39mstdout, stderr\u001b[38;5;241m=\u001b[39mstderr)\n\u001b[1;32m    518\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m CompletedProcess(process\u001b[38;5;241m.\u001b[39margs, retcode, stdout, stderr)\n",
      "\u001b[0;31mCalledProcessError\u001b[0m: Command '['git', 'clone', 'https://github.com/unimorph/ru.git']' returned non-zero exit status 128."
     ]
    }
   ],
   "source": [
    "um.download_unimorph(lang=\"ru\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 45,
   "id": "e216aa12",
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "Cloning into 'ru'...\n",
      "fatal: could not read Username for 'https://github.com': No such device or address\n"
     ]
    },
    {
     "ename": "CalledProcessError",
     "evalue": "Command '['git', 'clone', 'https://github.com/unimorph/ru.git']' returned non-zero exit status 128.",
     "output_type": "error",
     "traceback": [
      "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[0;31mCalledProcessError\u001b[0m                        Traceback (most recent call last)",
      "Input \u001b[0;32mIn [45]\u001b[0m, in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0m \u001b[43mum\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43manalyze_word\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mсвистишь\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mlang\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mru\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m)\u001b[49m\n",
      "File \u001b[0;32m~/.local/lib/python3.8/site-packages/unimorph.py:113\u001b[0m, in \u001b[0;36manalyze_word\u001b[0;34m(word, lang)\u001b[0m\n\u001b[1;32m    112\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21manalyze_word\u001b[39m(word: \u001b[38;5;28mstr\u001b[39m, \u001b[38;5;241m*\u001b[39m, lang: \u001b[38;5;28mstr\u001b[39m):\n\u001b[0;32m--> 113\u001b[0m     data \u001b[38;5;241m=\u001b[39m \u001b[43mload_dataset\u001b[49m\u001b[43m(\u001b[49m\u001b[43mlang\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m    114\u001b[0m     \u001b[38;5;28;01mreturn\u001b[39;00m data[data\u001b[38;5;241m.\u001b[39mform \u001b[38;5;241m==\u001b[39m word]\u001b[38;5;241m.\u001b[39mto_csv(sep\u001b[38;5;241m=\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;130;01m\\t\u001b[39;00m\u001b[38;5;124m\"\u001b[39m, index\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;01mFalse\u001b[39;00m, header\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;01mNone\u001b[39;00m)\n",
      "File \u001b[0;32m~/.local/lib/python3.8/site-packages/unimorph.py:79\u001b[0m, in \u001b[0;36mload_dataset\u001b[0;34m(lang, specific_file)\u001b[0m\n\u001b[1;32m     76\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m specific_file \u001b[38;5;129;01mis\u001b[39;00m \u001b[38;5;28;01mNone\u001b[39;00m:\n\u001b[1;32m     77\u001b[0m     specific_file \u001b[38;5;241m=\u001b[39m lang\n\u001b[0;32m---> 79\u001b[0m \u001b[43mdownload_unimorph\u001b[49m\u001b[43m(\u001b[49m\u001b[43mlang\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m     81\u001b[0m language_path \u001b[38;5;241m=\u001b[39m UNIMORPH_DIR \u001b[38;5;241m/\u001b[39m lang \u001b[38;5;241m/\u001b[39m specific_file\n\u001b[1;32m     82\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m lang \u001b[38;5;241m==\u001b[39m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mfin\u001b[39m\u001b[38;5;124m\"\u001b[39m:\n",
      "File \u001b[0;32m~/.local/lib/python3.8/site-packages/unimorph.py:67\u001b[0m, in \u001b[0;36mdownload_unimorph\u001b[0;34m(lang)\u001b[0m\n\u001b[1;32m     65\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m not_loaded(lang):\n\u001b[1;32m     66\u001b[0m     logging\u001b[38;5;241m.\u001b[39minfo(\u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mDownloading unimorph/\u001b[39m\u001b[38;5;132;01m{\u001b[39;00mlang\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m to \u001b[39m\u001b[38;5;132;01m{\u001b[39;00moutput_dir\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m\"\u001b[39m)\n\u001b[0;32m---> 67\u001b[0m     \u001b[43msubprocess\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mrun\u001b[49m\u001b[43m(\u001b[49m\n\u001b[1;32m     68\u001b[0m \u001b[43m        \u001b[49m\u001b[43m[\u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mgit\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mclone\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;124;43mf\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mhttps://github.com/unimorph/\u001b[39;49m\u001b[38;5;132;43;01m{\u001b[39;49;00m\u001b[43mlang\u001b[49m\u001b[38;5;132;43;01m}\u001b[39;49;00m\u001b[38;5;124;43m.git\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m]\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m     69\u001b[0m \u001b[43m        \u001b[49m\u001b[43mcheck\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;28;43;01mTrue\u001b[39;49;00m\u001b[43m,\u001b[49m\n\u001b[1;32m     70\u001b[0m \u001b[43m        \u001b[49m\u001b[43mcwd\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[43mUNIMORPH_DIR\u001b[49m\u001b[43m,\u001b[49m\n\u001b[1;32m     71\u001b[0m \u001b[43m    \u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m     72\u001b[0m \u001b[38;5;28;01massert\u001b[39;00m output_dir\u001b[38;5;241m.\u001b[39mis_dir()\n",
      "File \u001b[0;32m/usr/lib/python3.8/subprocess.py:516\u001b[0m, in \u001b[0;36mrun\u001b[0;34m(input, capture_output, timeout, check, *popenargs, **kwargs)\u001b[0m\n\u001b[1;32m    514\u001b[0m     retcode \u001b[38;5;241m=\u001b[39m process\u001b[38;5;241m.\u001b[39mpoll()\n\u001b[1;32m    515\u001b[0m     \u001b[38;5;28;01mif\u001b[39;00m check \u001b[38;5;129;01mand\u001b[39;00m retcode:\n\u001b[0;32m--> 516\u001b[0m         \u001b[38;5;28;01mraise\u001b[39;00m CalledProcessError(retcode, process\u001b[38;5;241m.\u001b[39margs,\n\u001b[1;32m    517\u001b[0m                                  output\u001b[38;5;241m=\u001b[39mstdout, stderr\u001b[38;5;241m=\u001b[39mstderr)\n\u001b[1;32m    518\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m CompletedProcess(process\u001b[38;5;241m.\u001b[39margs, retcode, stdout, stderr)\n",
      "\u001b[0;31mCalledProcessError\u001b[0m: Command '['git', 'clone', 'https://github.com/unimorph/ru.git']' returned non-zero exit status 128."
     ]
    }
   ],
   "source": [
    "um.analyze_word(\"свистишь\", lang=\"ru\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "42b06aaf",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "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.10"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
