commited all contents created by participants
This commit is contained in:
@@ -0,0 +1,61 @@
|
||||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import re
|
||||
import random
|
||||
|
||||
dictee_file = open("dictee-2005.txt", "r")
|
||||
|
||||
dictee_text = dictee_file.read()
|
||||
dictee_genetic = dictee_text
|
||||
# print(dictee_text)
|
||||
|
||||
dictee_text_clean = re.sub('\n+', ' ', dictee_text)
|
||||
dictee_text_clean = re.sub(r'\(.+\)', '', dictee_text_clean)
|
||||
# print(dictee_text_clean)
|
||||
|
||||
words = dictee_text_clean.split(' ')
|
||||
# print(words)
|
||||
|
||||
clean_words = []
|
||||
for word in words:
|
||||
clean_word = re.sub(r'[^\w\s]', '', word)
|
||||
if len(clean_word) :
|
||||
clean_words.append(clean_word)
|
||||
|
||||
# print(clean_words)
|
||||
|
||||
genetic_words = {}
|
||||
for word in clean_words:
|
||||
# print(word)
|
||||
genetic_words[word] = []
|
||||
for c in word:
|
||||
# print(ord(c))
|
||||
genetic_words[word].append(ord(c))
|
||||
|
||||
print(genetic_words)
|
||||
|
||||
for g_word in genetic_words:
|
||||
# print(g_word)
|
||||
# print("len",len(genetic_words[g_word]))
|
||||
l = random.randint(0, len(genetic_words[g_word])-1)
|
||||
# print("l", l)
|
||||
genetic_words[g_word][l] = genetic_words[g_word][l]+1
|
||||
|
||||
print(genetic_words)
|
||||
|
||||
|
||||
for g_word in genetic_words:
|
||||
print(g_word)
|
||||
word = ""
|
||||
for c in genetic_words[g_word]:
|
||||
print(c)
|
||||
word+=chr(c)
|
||||
print(word)
|
||||
dictee_genetic = dictee_genetic.replace(g_word, word)
|
||||
|
||||
print(dictee_genetic)
|
||||
|
||||
|
||||
with open('export.txt', 'w') as f:
|
||||
f.write(dictee_genetic)
|
||||
Reference in New Issue
Block a user