{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [],
   "source": [
    "import random #otherwise random does not work :)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [],
   "source": [
    "#first parts of the first 12 articles of the italian constitutes\n",
    "\n",
    "it_articles = [\"\\n\\nART.1 \\nItaly is a Democratic Republic, founded\", 'ART.2 \\nThe Republic recognises and guarantees', 'ART.3 \\nAll citizens have equal social dignity and are','ART.4 \\nThe Republic recognises the right of all citizens to','ART.5 \\nThe Republic, one and indivisible, recognises and promotes','ART.6 \\nThe Republic shall protect','ART.7 \\nThe State and the Catholic Church are','ART.8 \\nAll religious confessions enjoy','ART.9 \\nThe Republic shall promote the development of','ART.10 \\nThe Italian legal system conforms to the generally recognised rules of','ART.11 \\nItaly  rejects  war  as  an  instrument  of','ART.12 \\nThe flag of the Republic is']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [],
   "source": [
    "with open(\"Utopia.txt\") as utopia:  #open the external .txt\n",
    "    contents = utopia.read().replace('\\n','  ').replace('\\r ', '').replace('-','').replace('  ',' ').strip(' and ')#delete useless breaks\n",
    "    \n",
    "with open(\"anarchist_cookbook.txt\") as cookbook:\n",
    "    contents2 = cookbook.read().replace('\\n', ' ').replace('\\r', '').strip('1234567890').replace('-','').replace('  ',' ').strip(' and ')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [],
   "source": [
    "utopia_splitted = contents.split(\",\" or \".\" or '\"' or '; ' or 'and') #splits the texts and makes a list\n",
    "\n",
    "cookbook_splitted = contents2.split(\",\" or \".\" or '\"' or '; ' or 'and')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [],
   "source": [
    "export = './export.txt'\n",
    "with open(export, 'w') as export:\n",
    "\n",
    "    for i in range(20): #creates more possibilities, change the value to have more or less results\n",
    "    #while True\n",
    "    \n",
    "        for constitute in it_articles: \n",
    "        \n",
    "            utopia_random = random.choice(utopia_splitted) #it takes a random sentence from the list\n",
    "            cookbook_random = random.choice(cookbook_splitted)\n",
    "            \n",
    "            speculative_constitute = constitute + utopia_random\n",
    "        \n",
    "            print(f'''{speculative_constitute}.\\n''',file=export)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "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.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
