-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMapping.cpp
More file actions
292 lines (237 loc) · 9.74 KB
/
Mapping.cpp
File metadata and controls
292 lines (237 loc) · 9.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
#include "Mapping.h"
#include <iostream>
#include <iomanip>
Mapping::Mapping() {
// Initialize 27x27 matrix with zeros
mappingMatrix.resize(27, std::vector<int>(27, 0));
}
void Mapping::createEvaToHebrewMapping() {
// Clear existing mappings
for (int i = 0; i < 27; i++) {
for (int j = 0; j < 27; j++) {
mappingMatrix[i][j] = 0;
}
}
// Create a sample mapping from EVA to Hebrew
// This is a hypothetical mapping - in real research this would be based on linguistic analysis
// EVA 'a' (index 0) -> Hebrew aleph (index 0)
setMapping(0, 0);
// EVA 'b' (index 1) -> Hebrew bet (index 1)
setMapping(1, 1);
// EVA 'c' (index 2) -> Hebrew gimel (index 2)
setMapping(2, 2);
// EVA 'd' (index 3) -> Hebrew dalet (index 3)
setMapping(3, 3);
// EVA 'e' (index 4) -> Hebrew he (index 4)
setMapping(4, 4);
// EVA 'f' (index 5) -> Hebrew vav (index 5)
setMapping(5, 5);
// EVA 'g' (index 6) -> Hebrew zayin (index 6)
setMapping(6, 6);
// EVA 'h' (index 7) -> Hebrew chet (index 7)
setMapping(7, 7);
// EVA 'i' (index 8) -> Hebrew yod (index 9)
setMapping(8, 9);
// EVA 'j' (index 9) -> Hebrew kaf (index 10)
setMapping(9, 10);
// EVA 'k' (index 10) -> Hebrew lamed (index 11)
setMapping(10, 11);
// EVA 'l' (index 11) -> Hebrew mem (index 12)
setMapping(11, 12);
// EVA 'm' (index 12) -> Hebrew nun (index 13)
setMapping(12, 13);
// EVA 'n' (index 13) -> Hebrew samech (index 14)
setMapping(13, 14);
// EVA 'o' (index 14) -> Hebrew ayin (index 15)
setMapping(14, 15);
// EVA 'p' (index 15) -> Hebrew pe (index 16)
setMapping(15, 16);
// EVA 'q' (index 16) -> Hebrew tsadi (index 17)
setMapping(16, 17);
// EVA 'r' (index 17) -> Hebrew qof (index 18)
setMapping(17, 18);
// EVA 's' (index 18) -> Hebrew resh (index 19)
setMapping(18, 19);
// EVA 't' (index 19) -> Hebrew shin (index 20)
setMapping(19, 20);
// EVA 'u' (index 20) -> Hebrew tav (index 21)
setMapping(20, 21);
// EVA 'v' (index 21) -> Hebrew final kaf (index 22)
setMapping(21, 22);
// EVA 'w' (index 22) -> Hebrew final mem (index 23)
setMapping(22, 23);
// EVA 'x' (index 23) -> Hebrew final nun (index 24)
setMapping(23, 24);
// EVA 'y' (index 24) -> Hebrew final pe (index 25)
setMapping(24, 25);
// EVA 'z' (index 25) -> Hebrew final tsadi (index 26)
setMapping(25, 26);
// EVA space (index 26) -> Hebrew tet (index 8) - arbitrary mapping for space
setMapping(26, 8);
}
std::vector<int> Mapping::applyMapping(const std::vector<int>& inputVector) const {
if (inputVector.size() != 27) {
std::wcerr << L"Error: Input vector must have 27 elements" << std::endl;
return std::vector<int>(27, 0);
}
std::vector<int> result(27, 0);
// Matrix multiplication: result = inputVector * mappingMatrix
// inputVector is 1x27, mappingMatrix is 27x27, result is 1x27
for (int j = 0; j < 27; j++) {
for (int i = 0; i < 27; i++) {
if (inputVector[i] && mappingMatrix[i][j]) {
result[j] = 1; // Binary OR operation for multiple mappings
}
}
}
return result;
}
Word Mapping::translateToHebrew(const Word& evaWord) const {
if (evaWord.getAlphabet() != Alphabet::EVA) {
std::wcerr << L"Error: Input word must be in EVA alphabet" << std::endl;
return Word(L"", Alphabet::HEBREW);
}
// Get the binary matrix of the EVA word
std::vector<int> evaBinary = evaWord.getBinaryMatrix();
// Apply the mapping
std::vector<int> hebrewBinary = applyMapping(evaBinary);
// Create a Hebrew word representation using ASCII for better console compatibility
std::wstring approximateHebrew = L"H:";
// Convert binary result back to Hebrew letter names for visibility
const wchar_t* hebrewNames[] = {
L"aleph", L"bet", L"gimel", L"dalet", L"he", L"vav", L"zayin",
L"chet", L"tet", L"yod", L"kaf", L"lamed", L"mem", L"nun",
L"samech", L"ayin", L"pe", L"tsadi", L"qof", L"resh", L"shin",
L"tav", L"kaf_final", L"mem_final", L"nun_final", L"pe_final", L"tsadi_final"
};
bool hasMapping = false;
for (int i = 0; i < 27; i++) {
if (hebrewBinary[i]) {
if (hasMapping) approximateHebrew += L"-";
approximateHebrew += hebrewNames[i];
hasMapping = true;
}
}
if (!hasMapping) {
approximateHebrew = L"[no_mapping]";
}
return Word(approximateHebrew, Alphabet::HEBREW);
}
void Mapping::printMappingMatrix() const {
std::wcout << L"EVA to Hebrew Mapping Matrix (27x27):" << std::endl;
std::wcout << L" ";
// Print column headers (Hebrew alphabet indices)
for (int j = 0; j < 27; j++) {
std::wcout << std::setw(2) << j << L" ";
}
std::wcout << std::endl;
// Print matrix with row headers (EVA alphabet indices)
for (int i = 0; i < 27; i++) {
std::wcout << std::setw(2) << i << L": ";
for (int j = 0; j < 27; j++) {
std::wcout << std::setw(2) << mappingMatrix[i][j] << L" ";
}
std::wcout << std::endl;
}
}
void Mapping::setMapping(int evaIndex, int hebrewIndex) {
if (evaIndex >= 0 && evaIndex < 27 && hebrewIndex >= 0 && hebrewIndex < 27) {
mappingMatrix[evaIndex][hebrewIndex] = 1;
}
}
const std::vector<std::vector<int>>& Mapping::getMappingMatrix() const {
return mappingMatrix;
}
std::string Mapping::serializeMappingVisualization() const {
// EVA characters in alphabetical order
const char evaChars[] = "abcdefghijklmnopqrstuvwxyz ";
// Hebrew characters corresponding to indices 0-26
const char hebrewChars[] = {
(char)0xD0, (char)0x05, // aleph א (0x05D0)
(char)0xD1, (char)0x05, // bet ב (0x05D1)
(char)0xD2, (char)0x05, // gimel ג
(char)0xD3, (char)0x05, // dalet ד
(char)0xD4, (char)0x05, // he ה
(char)0xD5, (char)0x05, // vav ו
(char)0xD6, (char)0x05, // zayin ז
(char)0xD7, (char)0x05, // chet ח
(char)0xD8, (char)0x05, // tet ט
(char)0xD9, (char)0x05, // yod י
(char)0xDB, (char)0x05, // kaf כ
(char)0xDC, (char)0x05, // lamed ל
(char)0xDE, (char)0x05, // mem מ
(char)0xE0, (char)0x05, // nun נ
(char)0xE1, (char)0x05, // samech ס
(char)0xE2, (char)0x05, // ayin ע
(char)0xE4, (char)0x05, // pe פ
(char)0xE6, (char)0x05, // tsadi צ
(char)0xE7, (char)0x05, // qof ק
(char)0xE8, (char)0x05, // resh ר
(char)0xE9, (char)0x05, // shin ש
(char)0xEA, (char)0x05, // tav ת
(char)0xDA, (char)0x05, // kaf final ך
(char)0xDD, (char)0x05, // mem final ם
(char)0xDF, (char)0x05, // nun final ן
(char)0xE3, (char)0x05, // pe final ף
(char)0xE5, (char)0x05 // tsadi final ץ
};
std::string result;
// First line: EVA characters
result += "EVA: ";
for (int i = 0; i < 27; ++i) {
if (i > 0) result += " ";
result += evaChars[i];
}
result += "\n";
// Second line: Hebrew characters (show which Hebrew char each EVA maps to)
result += "HEB: ";
for (int i = 0; i < 27; ++i) {
if (i > 0) result += " ";
// Find which Hebrew character this EVA character maps to
int hebrewIndex = -1;
for (int j = 0; j < 27; ++j) {
if (mappingMatrix[i][j] == 1) {
hebrewIndex = j;
break;
}
}
if (hebrewIndex != -1) {
// Convert Hebrew index to Unicode characters
const char* hebrewUnicode = nullptr;
switch (hebrewIndex) {
case 0: hebrewUnicode = "א"; break; // aleph
case 1: hebrewUnicode = "ב"; break; // bet
case 2: hebrewUnicode = "ג"; break; // gimel
case 3: hebrewUnicode = "ד"; break; // dalet
case 4: hebrewUnicode = "ה"; break; // he
case 5: hebrewUnicode = "ו"; break; // vav
case 6: hebrewUnicode = "ז"; break; // zayin
case 7: hebrewUnicode = "ח"; break; // chet
case 8: hebrewUnicode = "ט"; break; // tet
case 9: hebrewUnicode = "י"; break; // yod
case 10: hebrewUnicode = "כ"; break; // kaf
case 11: hebrewUnicode = "ל"; break; // lamed
case 12: hebrewUnicode = "מ"; break; // mem
case 13: hebrewUnicode = "נ"; break; // nun
case 14: hebrewUnicode = "ס"; break; // samech
case 15: hebrewUnicode = "ע"; break; // ayin
case 16: hebrewUnicode = "פ"; break; // pe
case 17: hebrewUnicode = "צ"; break; // tsadi
case 18: hebrewUnicode = "ק"; break; // qof
case 19: hebrewUnicode = "ר"; break; // resh
case 20: hebrewUnicode = "ש"; break; // shin
case 21: hebrewUnicode = "ת"; break; // tav
case 22: hebrewUnicode = "ך"; break; // kaf final
case 23: hebrewUnicode = "ם"; break; // mem final
case 24: hebrewUnicode = "ן"; break; // nun final
case 25: hebrewUnicode = "ף"; break; // pe final
case 26: hebrewUnicode = "ץ"; break; // tsadi final
default: hebrewUnicode = "?"; break;
}
result += hebrewUnicode;
} else {
result += "?";
}
}
return result;
}