From 8b94ab0e3a1dd3578845cf34ce090d6066063768 Mon Sep 17 00:00:00 2001 From: onebigear Date: Mon, 13 Jun 2022 11:41:05 -0600 Subject: [PATCH] update --- dict.json | 30 ++++++++++++++++++++++++++++++ dict_test.py | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ yong.py | 17 +++++++++++++++++ 3 files changed, 97 insertions(+) create mode 100644 dict.json create mode 100644 dict_test.py create mode 100644 yong.py diff --git a/dict.json b/dict.json new file mode 100644 index 0000000..7c57be1 --- /dev/null +++ b/dict.json @@ -0,0 +1,30 @@ +[ + { + "letter": "silk-1", + "radical": "silk", + "numeral": "1" + + }, + + { + "letter": "silk-2", + "radical": "silk", + "numeral": "2" + + }, + + { + "letter": "silk-3", + "radical": "silk", + "numeral": "3" + + }, + + { + "letter": "earth-1", + "radical": "earth", + "numeral": "4" + + } +] + diff --git a/dict_test.py b/dict_test.py new file mode 100644 index 0000000..3c9481e --- /dev/null +++ b/dict_test.py @@ -0,0 +1,50 @@ +# prototype to translate a system to text into dictionary +# as a type of structured text +import numpy as np +import json + +# what is the proper way to store radicals with dictionary? +# use json + +data = json.load(open('dict.json', 'r')) + +# the essence of the program is to introduce noise to disrupt +# the mapping relation of the dictionary. +# learning rules is also essential to machine learning, which +for i in data: + print(i["letter"]) + # modify numeral for letter and update json file + i["numeral"] = "updated value nul" + print(i["numeral"]) + +for i in data: + print(i) + +# how to save to json file + +# the problem is, dictionary keys are saved as strings +# using numerical update can apply? + + +# current rule +# 1 <= key <= 3, silk; 4 <= key <= 6, earth; 7 <= key <= 9, water + + + +# add noise to rule + +# there is some noise +noise = np.random.randint(1,3) + + +# loop through keys, add noise to key value +# say noise is 2, every key adds 2 +# dict = { '3':'silk-1', '4':'silk-2', '5':'silk-3', +# '6':'earth-1', '7':'earth-2', '8':'earth-3', +# '9':'water-1', '10':'water-2', '11':'water-3', +# } +# then when i query the dictionary again, +# the rule is disrupted, the message is disrupted +# the rule is disrupted by adding a simple number +# are there more disruptive and complex rules? + diff --git a/yong.py b/yong.py new file mode 100644 index 0000000..3391f17 --- /dev/null +++ b/yong.py @@ -0,0 +1,17 @@ +import numpy as np +yong_grid = [[0,0,0,0,1,1,0,0,0,0], + [0,0,1,1,1,1,0,0,1,0], + [0,0,0,0,0,1,0,1,0,0], + [0,0,0,0,0,1,1,0,0,0], + [0,1,1,1,1,1,1,0,0,0], + [0,0,0,1,0,1,1,0,0,0], + [0,0,1,0,0,1,0,1,0,0], + [0,1,0,0,0,1,0,0,1,0], + [0,0,0,1,0,1,0,0,0,0], + [0,0,0,0,1,1,0,0,0,0]] + +print(np.matrix(yong_grid)) + +from matplotlib import pyplot as plt +im = plt.imshow(yong_grid, cmap="copper_r") +plt.show() \ No newline at end of file