|
|
@ -3,25 +3,25 @@ Development Notes
|
|
|
|
JSON is a common format used to represent structured text.
|
|
|
|
JSON is a common format used to represent structured text.
|
|
|
|
|
|
|
|
|
|
|
|
The essence of the program is to introduce noise to disrupt the
|
|
|
|
The essence of the program is to introduce noise to disrupt the
|
|
|
|
mapping relation of the dictionary.
|
|
|
|
mapping relation present in the dictionary.
|
|
|
|
|
|
|
|
|
|
|
|
Learning rules is also essential to machine learning.
|
|
|
|
Rules are also present in machine learning.
|
|
|
|
|
|
|
|
|
|
|
|
When the rule is disrupted, when I query the dictionary again,
|
|
|
|
The mapping rule is disrupted, when I query the dictionary again,
|
|
|
|
the message is disrupted.
|
|
|
|
the message is disrupted.
|
|
|
|
|
|
|
|
|
|
|
|
The rule is disrupted by linear arithemetic operation,
|
|
|
|
The rule is disrupted by linear arithemetic operation,
|
|
|
|
are there more disruptive and complex rules?
|
|
|
|
are there more non-linear and nuanced rules?
|
|
|
|
|
|
|
|
|
|
|
|
Prototype to translate a system to text into dictionary
|
|
|
|
Prototype to translate a system to text into dictionary
|
|
|
|
as a type of structured text
|
|
|
|
as a type of structured text.
|
|
|
|
|
|
|
|
|
|
|
|
str int conversion is important to debug the program
|
|
|
|
str int conversion is important to debug the program
|
|
|
|
|
|
|
|
|
|
|
|
why is it that noise is perceived as adverse?
|
|
|
|
I am still hostile to the concept and etymology of noise, rename
|
|
|
|
|
|
|
|
the concept into something else.
|
|
|
|
|
|
|
|
|
|
|
|
'''
|
|
|
|
'''
|
|
|
|
|
|
|
|
|
|
|
|
import numpy as np
|
|
|
|
import numpy as np
|
|
|
|
import json
|
|
|
|
import json
|
|
|
|
|
|
|
|
|
|
|
@ -34,49 +34,77 @@ import json
|
|
|
|
|
|
|
|
|
|
|
|
# disrupted message idenfified by "no" field
|
|
|
|
# disrupted message idenfified by "no" field
|
|
|
|
|
|
|
|
|
|
|
|
data = json.load(open('seed.json', 'r'))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
print("before disrupting, the message is: ")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for i in data:
|
|
|
|
def parse_json(filename):
|
|
|
|
print(i)
|
|
|
|
data = json.load(open(filename,'r'))
|
|
|
|
if i["no"] == "2":
|
|
|
|
return data
|
|
|
|
print(i["glyph"] + " " + i["radical"] )
|
|
|
|
|
|
|
|
if i["no"] == "3":
|
|
|
|
|
|
|
|
print(i["glyph"] + " " + i["radical"] )
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# write as a function, input are codes, output are a {} of glyphs
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
noise = np.random.randint(1,3)
|
|
|
|
def in_msg(data):
|
|
|
|
|
|
|
|
message_i = []
|
|
|
|
|
|
|
|
message_full_i = []
|
|
|
|
|
|
|
|
|
|
|
|
for i in data:
|
|
|
|
for i in data:
|
|
|
|
i["no"] = int(i["no"])
|
|
|
|
if i["no"] == "2":
|
|
|
|
i["no"] += noise
|
|
|
|
message_i.append(i["glyph"])
|
|
|
|
|
|
|
|
message_full_i.append(i)
|
|
|
|
|
|
|
|
if i["no"] == "3":
|
|
|
|
|
|
|
|
message_i.append(i["glyph"])
|
|
|
|
|
|
|
|
message_full_i.append(i)
|
|
|
|
|
|
|
|
|
|
|
|
with open('noised.json','w') as w_file:
|
|
|
|
print("message prior to disruption contains: ")
|
|
|
|
json.dump(data,w_file, indent=4)
|
|
|
|
for s in message_i:
|
|
|
|
|
|
|
|
print(s)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def disrupt(data):
|
|
|
|
|
|
|
|
noise = np.random.randint(1,3)
|
|
|
|
|
|
|
|
for i in data:
|
|
|
|
|
|
|
|
i["no"] = int(i["no"])
|
|
|
|
|
|
|
|
i["no"] += noise
|
|
|
|
|
|
|
|
return data
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def save_json(data):
|
|
|
|
|
|
|
|
with open('noised.json','w', encoding='utf-8') as w_file:
|
|
|
|
|
|
|
|
json.dump(data,w_file, indent=4, ensure_ascii = False)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def out_msg(noise_data):
|
|
|
|
|
|
|
|
message_o = []
|
|
|
|
|
|
|
|
message_full_o = []
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for i in noise_data:
|
|
|
|
|
|
|
|
#comparing integers, the noise_data no fields are previously
|
|
|
|
|
|
|
|
#dumped as integers
|
|
|
|
|
|
|
|
if i["no"] == 2:
|
|
|
|
|
|
|
|
message_o.append(i["glyph"])
|
|
|
|
|
|
|
|
message_full_o.append(i)
|
|
|
|
|
|
|
|
if i["no"] == 3:
|
|
|
|
|
|
|
|
message_o.append(i["glyph"])
|
|
|
|
|
|
|
|
message_full_o.append(i)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
print("message after disruption contains: ")
|
|
|
|
|
|
|
|
|
|
|
|
print("after disrupting, the message is: ")
|
|
|
|
for s in message_o:
|
|
|
|
|
|
|
|
print(s)
|
|
|
|
|
|
|
|
|
|
|
|
# use noised json to decrypt
|
|
|
|
# at this point the interferences are somewhat apparent
|
|
|
|
|
|
|
|
# how can i present the interference to be more apparent?
|
|
|
|
|
|
|
|
# todo
|
|
|
|
|
|
|
|
# input chinese blocks in here
|
|
|
|
|
|
|
|
|
|
|
|
noise_data = json.load(open('noised.json','r'))
|
|
|
|
|
|
|
|
for i in noise_data:
|
|
|
|
|
|
|
|
print(i)
|
|
|
|
|
|
|
|
print(type(i["no"]))
|
|
|
|
|
|
|
|
# comparing integers, the noise_data no fields are previously
|
|
|
|
|
|
|
|
# dumped as integers
|
|
|
|
|
|
|
|
if i["no"] == 2:
|
|
|
|
|
|
|
|
print(i["glyph"] + " " + i["radical"] )
|
|
|
|
|
|
|
|
if i["no"] == 3:
|
|
|
|
|
|
|
|
print(i["glyph"] + " " + i["radical"] )
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# at this point the interferences are not so apparent
|
|
|
|
if __name__ == "__main__":
|
|
|
|
|
|
|
|
parsed_json = parse_json(filename = "seed.json")
|
|
|
|
|
|
|
|
in_msg(data = parsed_json)
|
|
|
|
|
|
|
|
disrupted_data = disrupt(data = parsed_json)
|
|
|
|
|
|
|
|
save_json(data = disrupted_data)
|
|
|
|
|
|
|
|
parsed_noise_json = parse_json(filename = "noised.json")
|
|
|
|
|
|
|
|
out_msg(noise_data = parsed_noise_json)
|
|
|
|
|
|
|
|
|
|
|
|
# test with a large corpus
|
|
|
|
# test with a large corpus in separate program
|
|
|
|
|
|
|
|
|
|
|
|
# try with corpuses of different language
|
|
|
|
# try with corpuses of different language
|
|
|
|
|
|
|
|
|
|
|
|
# try a chinese dictionary and a latin dictionary
|
|
|
|
# try a chinese dictionary and a latin dictionary
|
|
|
|
|
|
|
|
|
|
|
|
# and any other types of dictionary structures, remix!
|
|
|
|
# and any other types of dictionary structures, remix!
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# main section looks really ugly
|