You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
3.7 KiB
3.7 KiB
In [10]:
import random #otherwise random does not work :)
In [11]:
#first parts of the first 12 articles of the italian constitutes 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']
In [ ]:
In [12]:
with open("Utopia.txt") as utopia: #open the external .txt contents = utopia.read().replace('\n',' ').replace('\r ', '').replace('-','').replace(' ',' ').strip(' and ')#delete useless breaks with open("anarchist_cookbook.txt") as cookbook: contents2 = cookbook.read().replace('\n', ' ').replace('\r', '').strip('1234567890').replace('-','').replace(' ',' ').strip(' and ')
In [ ]:
In [13]:
utopia_splitted = contents.split("," or "." or '"' or '; ' or 'and') #splits the texts and makes a list cookbook_splitted = contents2.split("," or "." or '"' or '; ' or 'and')
In [16]:
export = './export.txt' with open(export, 'w') as export: for i in range(20): #creates more possibilities, change the value to have more or less results #while True for constitute in it_articles: utopia_random = random.choice(utopia_splitted) #it takes a random sentence from the list cookbook_random = random.choice(cookbook_splitted) speculative_constitute = constitute + utopia_random print(f'''{speculative_constitute}.\n''',file=export)
In [ ]:
In [ ]:
In [ ]: