ColorScience 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: fc0b232eac573852f6e04ed3062fafc47fba886cb0b91be272713e10af9e92eb
4
+ data.tar.gz: e9cebeb6aa3f48a280e471a3fdc3d59174c75d1e2fdde0a2416ebd6c1ea29a61
5
+ SHA512:
6
+ metadata.gz: 5de94970880805f7c9a0d35b437ff202c63409442e813475ef32b15ec343ce452c2746ca0a8e856d5e183fef881e68640b55b79cd3ab54e80617d2b755880200
7
+ data.tar.gz: c224871caed466261573aea153429b6ef3be7f2b9a0c64fdf5053e97f1101e750d0c264a8529e554d500fda507c605c0cf14a8fa27fa7780e74b9cb818aa0ff5
data/ColorScience.rb ADDED
@@ -0,0 +1,510 @@
1
+ module ColorScience
2
+ class Analyze
3
+
4
+ ###############################################################################################
5
+ # Colors In Context #
6
+ ###############################################################################################
7
+ # This enables the framework to generate new contexts for when a color might be referenced or #
8
+ # said in conversation, such as discovering an untranslated phrase about a color in an #
9
+ # ancient language. #
10
+ ###############################################################################################
11
+ def self.colors_in_context
12
+ ## Choosing an random Word Class
13
+ word_classes = [
14
+ [["Le", "Le"], ["Le", "La"], ["Le", "Les"]],
15
+ [["La", "Le"], ["La", "La"], ["La", "Les"]],
16
+ [["Les", "Le"], ["Les", "La"], ["Les", "Les"]],
17
+ ]
18
+
19
+ row_options = [0, 1, 2]
20
+ col_options = [0, 1, 2]
21
+ arr_options = [0, 1]
22
+
23
+ cur_row = row_options.sample
24
+ cur_col = col_options.sample
25
+ cur_arr = row_options.sample
26
+
27
+ chosen_word_class = word_classes[cur_row][cur_col][cur_arr]
28
+
29
+ ## Choosing a random noun
30
+ nouns = [
31
+ [["chien", "chien"], ["chien", "chatte"], ["chien", "furet"]],
32
+ [["chatte", "chien"], ["chatte", "chatte"], ["chatte", "furet"]],
33
+ [["furet", "chien"], ["furet", "chatte"], ["furet", "furet"]],
34
+ ]
35
+
36
+ row_options = [0, 1, 2]
37
+ col_options = [0, 1, 2]
38
+ arr_options = [0, 1]
39
+
40
+ cur_row = row_options.sample
41
+ cur_col = col_options.sample
42
+ cur_arr = row_options.sample
43
+
44
+ chosen_noun = nouns[cur_row][cur_col][cur_arr]
45
+
46
+ ## Choosing a random adjectives
47
+ r = "rouge"
48
+ o = "orange"
49
+ y = "jaune"
50
+ g = "vert"
51
+ b = "bleu"
52
+ p = "violet"
53
+
54
+ adjectives = [
55
+ [[r, r], [r, o], [r, y], [r, g], [r, b], [r, p]],
56
+ [[o, r], [o, o], [o, y], [o, g], [o, b], [o, p]],
57
+ [[y, r], [y, o], [y, y], [y, g], [y, b], [y, p]],
58
+ [[g, r], [g, o], [g, y], [g, g], [g, b], [g, p]],
59
+ [[b, r], [b, o], [b, y], [b, g], [b, b], [b, p]],
60
+ ]
61
+
62
+ row_options = [0, 1, 2, 3, 4]
63
+ col_options = [0, 1, 2, 3, 4]
64
+ arr_options = [0, 1]
65
+
66
+ cur_row = row_options.sample
67
+ cur_col = col_options.sample
68
+ cur_arr = row_options.sample
69
+
70
+ chosen_adjective = adjectives[cur_row][cur_col][cur_arr]
71
+
72
+ ## Choosing a random subject
73
+ j = "Je"
74
+ t = "Tu"
75
+ v = "Vous"
76
+ n1 = "Nous"
77
+ i1 = "Il"
78
+ i2 = "Ils"
79
+ e1 = "Elle"
80
+ e2 = "Elles"
81
+ n2 = "Nousil"
82
+ n3 = "Nousils"
83
+ n4 = "Nouselle"
84
+ n5 = "Nouselles"
85
+ n6 = "Noustu"
86
+
87
+ subjects = [
88
+ [[j, j], [j, t], [j, v], [j, n1], [j, il1], [j, il2], [j, e1], [j, e2], [j, n2], [j, n3], [j, n4], [j, n5], [j, n6]],
89
+ [[t, j], [t, t], [t, v], [t, n1], [t, il1], [t, il2], [t, e1], [t, e2], [t, n2], [t, n3], [t, n4], [t, n5], [t, n6]],
90
+ [[v, j], [v, t], [v, v], [v, n1], [v, il1], [v, il2], [v, e1], [v, e2], [v, n2], [v, n3], [v, n4], [v, n5], [v, n6]],
91
+ [[n1, j], [n1, t], [n1, v], [n1, n1], [n1, il1], [n1, il2], [n1, e1], [n1, e2], [n1, n2], [n1, n3], [n1, n4], [n1, n5], [n1, n6]],
92
+ [[i1, j], [i1, t], [i1, v], [i1, n1], [i1, il1], [i1, il2], [i1, e1], [i1, e2], [i1, n2], [i1, n3], [i1, n4], [i1, n5], [i1, n6]],
93
+ [[i2, j], [i2, t], [i2, v], [i2, n1], [i2, il1], [i2, il2], [i2, e1], [i2, e2], [i2, n2], [i2, n3], [i2, n4], [i2, n5], [i2, n6]],
94
+ [[e1, j], [e1, t], [e1, v], [e1, n1], [e1, el1], [e1, el2], [e1, e1], [e1, e2], [e1, n2], [e1, n3], [e1, n4], [e1, n5], [e1, n6]],
95
+ [[e2, j], [e2, t], [e2, v], [e2, n1], [e2, el1], [e2, el2], [e2, e1], [e2, e2], [e2, n2], [e2, n3], [e2, n4], [e2, n5], [e2, n6]],
96
+ [[n1, j], [n1, t], [n1, v], [n1, n1], [n1, il1], [n1, il2], [n1, e1], [n1, e2], [n1, n2], [n1, n3], [n1, n4], [n1, n5], [n1, n6]],
97
+ [[n2, j], [n2, t], [n2, v], [n2, n1], [n2, il1], [n2, il2], [n2, e1], [n2, e2], [n2, n2], [n2, n3], [n2, n4], [n2, n5], [n2, n6]],
98
+ [[n3, j], [n3, t], [n3, v], [n3, n1], [n3, il1], [n3, il2], [n3, e1], [n3, e2], [n3, n2], [n3, n3], [n3, n4], [n3, n5], [n3, n6]],
99
+ [[n4, j], [n4, t], [n4, v], [n4, n1], [n4, il1], [n4, il2], [n4, e1], [n4, e2], [n4, n2], [n4, n3], [n4, n4], [n4, n5], [n4, n6]],
100
+ [[n5, j], [n5, t], [n5, v], [n5, n1], [n5, il1], [n5, il2], [n5, e1], [n5, e2], [n5, n2], [n5, n3], [n5, n5], [n5, n5], [n5, n6]],
101
+ ]
102
+
103
+ row_options = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
104
+ col_options = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
105
+ arr_options = [0, 1]
106
+
107
+ cur_row = row_options.sample
108
+ cur_col = col_options.sample
109
+ cur_arr = row_options.sample
110
+
111
+ chosen_subject = subjects[cur_row][cur_col][cur_arr]
112
+
113
+ ## Choosing a random verb
114
+ p = "petto"
115
+ f = "fido"
116
+ w = "warutzu"
117
+
118
+ verbs = [
119
+ [[p, p], [p, f], [p, w]],
120
+ [[f, p], [f, f], [f, w]],
121
+ [[w, p], [w, f], [w, w]],
122
+ ]
123
+
124
+ row_options = [0, 1, 2]
125
+ col_options = [0, 1, 2]
126
+ arr_options = [0, 1]
127
+
128
+ cur_row = row_options.sample
129
+ cur_col = col_options.sample
130
+ cur_arr = row_options.sample
131
+
132
+ chosen_verb = verbs[cur_row][cur_col][cur_arr]
133
+
134
+ ## Choosing a random adverb
135
+ q = "quicely"
136
+ s = "lentement"
137
+
138
+ adverbs = [
139
+ [[q, q], [q, s]],
140
+ [[s, q], [s, s]],
141
+ ]
142
+
143
+ row_options = [0, 1]
144
+ col_options = [0, 1]
145
+ arr_options = [0, 1]
146
+
147
+ cur_row = row_options.sample
148
+ cur_col = col_options.sample
149
+ cur_arr = row_options.sample
150
+
151
+ chosen_adverb = adverbs[cur_row][cur_col][cur_arr]
152
+
153
+ created_phrase = "#{chosen_word_class} #{chosen_noun} #{chosen_adjective} #{chosen_subject} #{chosen_verb} #{chosen_adverb}."
154
+
155
+ print "#{created_phrase} : "
156
+
157
+ File.open("data/colors/new_colors.txt", "a") { |f|
158
+ f.puts created_phrase
159
+ }
160
+ end
161
+
162
+ ###############################################################################################
163
+ # Assign Color Data #
164
+ ###############################################################################################
165
+ # This allows the system to assign identifiers, English names, hex codes, and invented lang #
166
+ # names for colors into a format the naive bayes and decision tree algorithm for recommending #
167
+ # new information can use. #
168
+ ###############################################################################################
169
+ def self.color_data
170
+ color_ph = [
171
+ [:PH4DR1, "Salmon", "#FC746B", "Samon"], # 0
172
+ [:PH4DR2, "Copper", "#D27D48", "Cuivre"], # 1
173
+ [:PH4DR3, "Salmon Pink", "#F26E6E", "Samonrose"], # 2
174
+ [:PH5DR1, "Pale Salmon", "#EEA38F", "Samonblanc"], # 3
175
+ [:PH5DR2, "Khaki", "#B9B369", "Khaki"], # 4
176
+ [:PH5DR3, "Light Mauve", "#C7A2B1", "Mauveraito"], # 5
177
+ [:PH6DR1, "Maize", "#F9CF55", "Meizu"], # 6
178
+ [:PH6DR2, "Pale Lime", "#B1F468", "Remonblanc"], # 7
179
+ [:PH6DR3, "Bland", "#CBC4AA", "Burando"], # 8
180
+ [:PH7DR1, "Vibrant Green", "#0AD322", "Gurinvieil"], # 9
181
+ [:PH7DR2, "Medium Green", "#50CE6C", "Chadeuxgris"], # 10
182
+ [:PH7DR3, "Grey Blue", "#84A9CA", "Burugris"], # 11
183
+ [:PH8DR1, "Japanese Bistre", "#65482C", "Nihongobistre"], # 12
184
+ [:PH8DR2, "Kelly Green", "#0DA52B", "Kerivert"], # 13
185
+ [:PH8DR2, "Sapphire 1", "#0D36A3", "Saphirune"], # 14
186
+ [:PH9DR1, "Dull Purple", "#7D567A", "Gris De Violet"], # 15
187
+ [:PH9DR2, "Viridian", "#0B916B", "Viridian"], # 16
188
+ [:PH9DR3, "Sapphire 2", "#0A47B8", "Saphirdeux"], # 17
189
+ ]
190
+
191
+ ## Salmon
192
+ @salmon_ident = color_ph[0][0]
193
+ @salmon_name = color_ph[0][1]
194
+ @salmon_hex = color_ph[0][2]
195
+ @salmon_invent = color_ph[0][3]
196
+
197
+ ## Copper
198
+ @copper_ident = color_ph[1][0]
199
+ @copper_name = color_ph[1][1]
200
+ @copper_hex = color_ph[1][2]
201
+ @copper_invent = color_ph[1][3]
202
+
203
+ ## Salmon Pink
204
+ @salmonpink_ident = color_ph[2][0]
205
+ @salmonpink_name = color_ph[2][1]
206
+ @salmonink_hex = color_ph[2][2]
207
+ @salmonink_invent = color_ph[2][4]
208
+
209
+ ## Pale Salmon
210
+ @salmonpale_ident = color_ph[3][0]
211
+ @salmonpale_name = color_ph[3][1]
212
+ @salmonpale_hex = color_ph[3][2]
213
+ @salmonpale_invent = color_ph[3][3]
214
+
215
+ ## Maize
216
+ @maize_ident = color_ph[4][0]
217
+ @maize_name = color_ph[4][1]
218
+ @maize_hex = color_ph[4][2]
219
+ @maize_invent = color_ph[4][3]
220
+
221
+ ## Pale Lime
222
+ @plime_ident = color_ph[5][0]
223
+ @plime_name = color_ph[5][1]
224
+ @plime_hex = color_ph[5][2]
225
+ @plime_invent = color_ph[5][3]
226
+
227
+ ## Khaki
228
+ @khaki_ident = color_ph[6][0]
229
+ @khaki_name = color_ph[6][1]
230
+ @khaki_hex = color_ph[6][2]
231
+ @khaki_invent = color_ph[6][4]
232
+
233
+ ## Light Mauve
234
+ @lmauve_ident = color_ph[7][0]
235
+ @lmauve_name = color_ph[7][1]
236
+ @lmauve_hex = color_ph[7][2]
237
+ @lmauve_invent = color_ph[7][4]
238
+
239
+ ## Bland
240
+ @bland_ident = color_ph[8][0]
241
+ @bland_name = color_ph[8][1]
242
+ @bland_hex = color_ph[8][2]
243
+ @bland_invent = color_ph[8][4]
244
+
245
+ ## Vibrant Green
246
+ @vgreen_ident = color_ph[9][0]
247
+ @vgreen_name = color_ph[9][1]
248
+ @vgreen_hex = color_ph[9][2]
249
+ @vgreen_invent = color_ph[9][4]
250
+
251
+ ## Medium Green
252
+ @mgreen_ident = color_ph[10][0]
253
+ @mgreen_name = color_ph[10][1]
254
+ @mgreen_hex = color_ph[10][2]
255
+ @mgreen_invent = color_ph[10][4]
256
+
257
+ ## Grey Blue
258
+ @gblue_ident = color_ph[11][0]
259
+ @gblue_name = color_ph[11][1]
260
+ @gblue_hex = color_ph[11][2]
261
+ @gblue_invent = color_ph[11][4]
262
+
263
+ ## Japanese Bistre
264
+ @jbistre_ident = color_ph[12][0]
265
+ @jbistre_name = color_ph[12][1]
266
+ @jbistre_hex = color_ph[12][2]
267
+ @jbistre_invent = color_ph[12][4]
268
+
269
+ ## Kelly Green
270
+ @kgreen_ident = color_ph[13][0]
271
+ @kgreen_name = color_ph[13][1]
272
+ @kgreen_hex = color_ph[13][2]
273
+ @kgreen_invent = color_ph[13][4]
274
+
275
+ ## Sapphire 1
276
+ @saph1_ident = color_ph[14][0]
277
+ @saph1_name = color_ph[14][1]
278
+ @saph1_hex = color_ph[14][2]
279
+ @saph1_invent = color_ph[14][4]
280
+
281
+ ## Dull Purple
282
+ @dpurp_ident = color_ph[15][0]
283
+ @dpurp_name = color_ph[15][1]
284
+ @dpurp_hex = color_ph[15][2]
285
+ @dpurp_invent = color_ph[15][4]
286
+
287
+ ## Viridian
288
+ @viri_ident = color_ph[16][0]
289
+ @viri_name = color_ph[16][1]
290
+ @viri_hex = color_ph[16][2]
291
+ @viri_invent = color_ph[16][4]
292
+
293
+ ## Sapphire 2
294
+ @saph2_ident = color_ph[17][0]
295
+ @saph2_name = color_ph[17][1]
296
+ @saph2_hex = color_ph[17][2]
297
+ @saph2_invent = color_ph[17][4]
298
+ end
299
+
300
+ ###############################################################################################
301
+ # Predict Colors #
302
+ ###############################################################################################
303
+ # Predict new color probabilities based on the assigned information provided, and convert #
304
+ # that into a probability that the decision tree can use. #
305
+ ###############################################################################################
306
+ def self.predict_colors
307
+ require "naive_bayes"
308
+
309
+ color_science = NaiveBayes.new(:identifier, :name, :hex_code, :invented_language_name)
310
+
311
+ ## Identifiers
312
+ color_science.train(:identifier, @salmon_ident, "Salmon")
313
+ color_science.train(:identifier, @copper_ident, "Copper")
314
+ color_science.train(:identifier, @salmonpink_ident, "Salmon Pink")
315
+ color_science.train(:identifier, @salmonpale_ident, "Salmon Pale")
316
+ color_science.train(:identifier, @maize_ident, "Maize")
317
+ color_science.train(:identifier, @plime_ident, "Pale Lime")
318
+ color_science.train(:identifier, @khaki_ident, "Khaki")
319
+ color_science.train(:identifier, @lmauve_ident, "Light Mauve")
320
+ color_science.train(:identifier, @bland_ident, "Bland")
321
+ color_science.train(:identifier, @vgreen_ident, "Vibrant Green")
322
+ color_science.train(:identifier, @gblue_ident, "Grey Blue")
323
+ color_science.train(:identifier, @jbistre_ident, "Japanese Bistre")
324
+ color_science.train(:identifier, @kgreen_ident, "Kelly Green")
325
+ color_science.train(:identifier, @saph1_ident, "Sapphire 1")
326
+ color_science.train(:identifier, @dpurp_ident, "Dull Purple")
327
+ color_science.train(:identifier, @viri_ident, "Dull Purple")
328
+ color_science.train(:identifier, @saph2_ident, "Sapphire 2")
329
+
330
+ ## Name
331
+ color_science.train(:name, @salmon_name, "Salmon")
332
+ color_science.train(:name, @copper_name, "Copper")
333
+ color_science.train(:name, @salmonpink_name, "Salmon Pink")
334
+ color_science.train(:name, @salmonpale_name, "Salmon Pale")
335
+ color_science.train(:name, @maize_name, "Maize")
336
+ color_science.train(:name, @plime_name, "Pale Lime")
337
+ color_science.train(:name, @khaki_name, "Khaki")
338
+ color_science.train(:name, @lmauve_name, "Light Mauve")
339
+ color_science.train(:name, @bland_name, "Bland")
340
+ color_science.train(:name, @vgreen_name, "Vibrant Green")
341
+ color_science.train(:name, @gblue_name, "Grey Blue")
342
+ color_science.train(:name, @jbistre_name, "Japanese Bistre")
343
+ color_science.train(:name, @kgreen_name, "Kelly Green")
344
+ color_science.train(:name, @saph1_name, "Sapphire 1")
345
+ color_science.train(:name, @dpurp_name, "Dull Purple")
346
+ color_science.train(:name, @viri_name, "Dull Purple")
347
+ color_science.train(:name, @saph2_name, "Sapphire 2")
348
+
349
+ ## Hex Code
350
+ color_science.train(:hex_code, @salmon_hex, "Salmon")
351
+ color_science.train(:hex_code, @copper_hex, "Copper")
352
+ color_science.train(:hex_code, @salmonpink_hex, "Salmon Pink")
353
+ color_science.train(:hex_code, @salmonpale_hex, "Salmon Pale")
354
+ color_science.train(:hex_code, @maize_hex, "Maize")
355
+ color_science.train(:hex_code, @plime_hex, "Pale Lime")
356
+ color_science.train(:hex_code, @khaki_hex, "Khaki")
357
+ color_science.train(:hex_code, @lmauve_hex, "Light Mauve")
358
+ color_science.train(:hex_code, @bland_hex, "Bland")
359
+ color_science.train(:hex_code, @vgreen_hex, "Vibrant Green")
360
+ color_science.train(:hex_code, @gblue_hex, "Grey Blue")
361
+ color_science.train(:hex_code, @jbistre_hex, "Japanese Bistre")
362
+ color_science.train(:hex_code, @kgreen_hex, "Kelly Green")
363
+ color_science.train(:hex_code, @saph1_hex, "Sapphire 1")
364
+ color_science.train(:hex_code, @dpurp_hex, "Dull Purple")
365
+ color_science.train(:hex_code, @viri_hex, "Dull Purple")
366
+ color_science.train(:hex_code, @saph2_hex, "Sapphire 2")
367
+
368
+ ## invent Code
369
+ color_science.train(::invented_language_name, @salmon_invent, "Salmon")
370
+ color_science.train(::invented_language_name, @copper_invent, "Copper")
371
+ color_science.train(::invented_language_name, @salmonpink_invent, "Salmon Pink")
372
+ color_science.train(::invented_language_name, @salmonpale_invent, "Salmon Pale")
373
+ color_science.train(::invented_language_name, @maize_invent, "Maize")
374
+ color_science.train(::invented_language_name, @plime_invent, "Pale Lime")
375
+ color_science.train(::invented_language_name, @khaki_invent, "Khaki")
376
+ color_science.train(::invented_language_name, @lmauve_invent, "Light Mauve")
377
+ color_science.train(::invented_language_name, @bland_invent, "Bland")
378
+ color_science.train(::invented_language_name, @vgreen_invent, "Vibrant Green")
379
+ color_science.train(::invented_language_name, @gblue_invent, "Grey Blue")
380
+ color_science.train(::invented_language_name, @jbistre_invent, "Japanese Bistre")
381
+ color_science.train(::invented_language_name, @kgreen_invent, "Kelly Green")
382
+ color_science.train(::invented_language_name, @saph1_invent, "Sapphire 1")
383
+ color_science.train(::invented_language_name, @dpurp_invent, "Dull Purple")
384
+ color_science.train(::invented_language_name, @viri_invent, "Dull Purple")
385
+ color_science.train(::invented_language_name, @saph2_invent, "Sapphire 2")
386
+
387
+ new_colors = File.readlines("data/colors/new_colors.txt")
388
+ size_limit = new_colors.size.to_i
389
+ index = 0
390
+
391
+ size_time.times do
392
+ classification = color_science.classify(*new_colors[index])
393
+
394
+ ## Classification Datapoints
395
+ label = classification[0]
396
+ probability_no = classification[1]
397
+ probability_yes = 1 - probability_no
398
+
399
+ print "Is color #{label}? #{probability_yes} / #{probability_no} : "
400
+ end
401
+
402
+ ## Saves classification for use in color recommendation framework.
403
+ @classification = classification
404
+ end
405
+
406
+ ###############################################################################################
407
+ # Suggest New Color #
408
+ ###############################################################################################
409
+ # Suggest a new color to the player that can go into their color palette, rather than #
410
+ # chasing a random color name or hex code at random. #
411
+ ###############################################################################################
412
+ def self.suggest_next_color
413
+ require "decisiontree"
414
+ require "digest"
415
+
416
+ attributes = ["Identifier"], ["Name"], ["Hex Code"], ["Invented Name"]
417
+
418
+ training = [
419
+ ["PH4DR1", 0.058823529], ["PH4DR2", 0.088235296], ["PH4DR3", 0.147058825],
420
+ ["PH5DR1", 0.205882354], ["PH5DR2", 0.264705883], ["PH5DR3", 0.323529412],
421
+ ["PH6DR1", 0.397058824], ["PH6DR2", 0.470588236], ["PH6DR3", 0.529411765],
422
+ ["PH7DR1", 0.764705883], ["PH7DR2", 0.794117648], ["PH7DR3", 0.823529412],
423
+ ["PH8DR1", 0.852941177], ["PH8DR2", 0.882352941], ["PH8DR2", 0.897058824],
424
+ ["PH9DR1", 0.911764706], ["PH9DR2", 0.955882353], ["PH9DR3", 1.000000000],
425
+ ], [
426
+ ["Salmon", 0.058823529], ["Copper", 0.088235296], ["Salmon Pink", 0.147058825],
427
+ ["Pale Salmon", 0.205882354], ["Khaki", 0.264705883], ["Light Mauve", 0.323529412],
428
+ ["Maize", 0.397058824], ["Pale Lime", 0.470588236], ["Bland", 0.529411765],
429
+ ["Vibrant Green", 0.764705883], ["Medium Green", 0.794117648], ["Grey Blue", 0.823529412],
430
+ ["Japanese Bistre", 0.852941177], ["Kelly Green", 0.882352941], ["Sapphire 1", 0.897058824],
431
+ ["Dull Purple", 0.911764706], ["Viidian", 0.955882353], ["Sapphire 2", 1.000000000],
432
+ ], [
433
+ ["#FC746B", 0.058823529], ["#D27D48", 0.088235296], ["#F26E6E", 0.147058825],
434
+ ["#EEA38F", 0.205882354], ["#B9B369", 0.264705883], ["#C7A2B1", 0.323529412],
435
+ ["#F9CF55", 0.397058824], ["#B1F468", 0.470588236], ["#CBC4AA", 0.529411765],
436
+ ["#0AD322", 0.764705883], ["#50CE6C", 0.794117648], ["#84A9CA", 0.823529412],
437
+ ["#65482C", 0.852941177], ["#0DA52B", 0.882352941], ["#0D36A3", 0.897058824],
438
+ ["#7D567A", 0.911764706], ["#0B916B", 0.955882353], ["#0A47B8", 1.000000000],
439
+ ], [
440
+ ["#FC746B", 0.058823529], ["#D27D48", 0.088235296], ["#F26E6E", 0.147058825],
441
+ ["#EEA38F", 0.205882354], ["#B9B369", 0.264705883], ["#C7A2B1", 0.323529412],
442
+ ["#F9CF55", 0.397058824], ["#B1F468", 0.470588236], ["#CBC4AA", 0.529411765],
443
+ ["#0AD322", 0.764705883], ["#50CE6C", 0.794117648], ["#84A9CA", 0.823529412],
444
+ ["#65482C", 0.852941177], ["#0DA52B", 0.882352941], ["#0D36A3", 0.897058824],
445
+ ["#7D567A", 0.911764706], ["#0B916B", 0.955882353], ["#0A47B8", 1.000000000],
446
+ ], [
447
+ ["Samon", 0.058823529], ["Cuivre", 0.088235296], ["Samonrose", 0.147058825],
448
+ ["Samonblanc", 0.205882354], ["Khaki", 0.264705883], ["Mauveraito", 0.323529412],
449
+ ["Meizu", 0.397058824], ["Remonblanc", 0.470588236], ["Burando", 0.529411765],
450
+ ["Gurinviell", 0.764705883], ["Chadeuxgris", 0.794117648], ["Burugris", 0.823529412],
451
+ ["Nihongobistre", 0.852941177], ["Kerivert", 0.882352941], ["Saphirune", 0.897058824],
452
+ ["Gris De Violet", 0.911764706], ["Viridian", 0.955882353], ["Saphirdeux", 1.000000000],
453
+ ]
454
+
455
+ dec_tree = DecisionTree::ID3Tree.new(attributes[0], training[0], 1, :continuous),
456
+ DecisionTree::ID3Tree.new(attributes[1], training[1], 1, :continuous),
457
+ DecisionTree::ID3Tree.new(attributes[2], training[2], 1, :continuous),
458
+ DecisionTree::ID3Tree.new(attributes[3], training[3], 1, :continuous),
459
+ DecisionTree::ID3Tree.new(attributes[4], training[4], 1, :continuous)
460
+
461
+ current_dectree1 = dec_tree[0]
462
+ current_dectree1.train
463
+
464
+ current_dectree2 = dec_tree[1]
465
+ current_dectree2.train
466
+
467
+ current_dectree3 = dec_tree[2]
468
+ current_dectree3.train
469
+
470
+ current_dectree3 = dec_tree[3]
471
+ current_dectree3.train
472
+
473
+ identifier = [@classification[1], "PH6DR2"]
474
+ name = [@classification[1], "Pale Lime"]
475
+ hex_code = [@classification[1], "#B1F468"]
476
+ invent_name = [@classification[1], "Remonblanc"]
477
+
478
+ # Labels the color identifier in PH value and dryness factor.
479
+ decision1 = current_dectree1.predict(identifier)
480
+
481
+ # Labels the standard English color name.
482
+ decision2 = current_dectree2.predict(name)
483
+
484
+ # Labels the hex code value.
485
+ decision3 = current_dectree3.predict(hex_code)
486
+
487
+ # Labels the invented language name.
488
+ decision4 = current_dectree4.predict(invent_name)
489
+
490
+ md5 = Digest::MD5.new
491
+ new_mixture = md5.update "[#{decision1}, #{decision2}, #{decision3}, #{decision4}]"
492
+
493
+ puts " > [#{decision1}, #{decision2}, #{decision3}, #{decision4}]"
494
+
495
+ File.open("data/colors/suggestions/suggest_colors.txt", "a") { |f|
496
+ f.puts "[:#{decision1}, '#{decision2}', '#{decision3}', '#{decision4}'] #{new_mixture}"
497
+ }
498
+ end
499
+
500
+ ###############################################################################################
501
+ # Chat With Color Scientist #
502
+ ###############################################################################################
503
+ # Using AIML to chat with the color scientist by making color requests in natural language, #
504
+ # by having them translate documents in the invented language. #
505
+ ###############################################################################################
506
+ def self.chat_color_science
507
+ require "programr"
508
+ end
509
+ end
510
+ end
data/README.md ADDED
@@ -0,0 +1,35 @@
1
+ # ColorScience
2
+
3
+ TODO: Delete this and the text below, and describe your gem
4
+
5
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/ColorScience`. To experiment with that code, run `bin/console` for an interactive prompt.
6
+
7
+ ## Installation
8
+
9
+ TODO: Replace `UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG` with your gem name right after releasing it to RubyGems.org. Please do not do it earlier due to security reasons. Alternatively, replace this section with instructions to install your gem from git if you don't plan to release to RubyGems.org.
10
+
11
+ Install the gem and add to the application's Gemfile by executing:
12
+
13
+ ```bash
14
+ bundle add UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
15
+ ```
16
+
17
+ If bundler is not being used to manage dependencies, install the gem by executing:
18
+
19
+ ```bash
20
+ gem install UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
21
+ ```
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/ColorScience.
data/Rakefile ADDED
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ task default: %i[]
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ColorScience
4
+ VERSION = "0.2.2"
5
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "ColorScience/version"
4
+
5
+ module ColorScience
6
+ class Analyze
7
+ def self.hello_world
8
+ puts "Hello WOrld"
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,4 @@
1
+ module ColorScience
2
+ VERSION: String
3
+ # See the writing guide of rbs: https://github.com/ruby/rbs#guides
4
+ end
metadata ADDED
@@ -0,0 +1,104 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ColorScience
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.2
5
+ platform: ruby
6
+ authors:
7
+ - LWFlouisa
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2025-08-06 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: naive_bayes
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 0.0.3
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 0.0.3
27
+ - !ruby/object:Gem::Dependency
28
+ name: decisiontree
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 0.5.0
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 0.5.0
41
+ - !ruby/object:Gem::Dependency
42
+ name: programr
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 0.0.2
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 0.0.2
55
+ - !ruby/object:Gem::Dependency
56
+ name: gabbler
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 0.1.0
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 0.1.0
69
+ description: A Self-Adapting Random Forest that analyses color information.
70
+ email:
71
+ - lwflouisa@gmail.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - ColorScience.rb
77
+ - README.md
78
+ - Rakefile
79
+ - lib/ColorScience.rb
80
+ - lib/ColorScience/version.rb
81
+ - sig/ColorScience.rbs
82
+ homepage: https://lwflouisa.github.io
83
+ licenses: []
84
+ metadata: {}
85
+ post_install_message:
86
+ rdoc_options: []
87
+ require_paths:
88
+ - lib
89
+ required_ruby_version: !ruby/object:Gem::Requirement
90
+ requirements:
91
+ - - ">="
92
+ - !ruby/object:Gem::Version
93
+ version: 3.0.0
94
+ required_rubygems_version: !ruby/object:Gem::Requirement
95
+ requirements:
96
+ - - ">="
97
+ - !ruby/object:Gem::Version
98
+ version: '0'
99
+ requirements: []
100
+ rubygems_version: 3.3.5
101
+ signing_key:
102
+ specification_version: 4
103
+ summary: Package for doing color science.
104
+ test_files: []