changing the files

This commit is contained in:
Helio 2022-04-22 15:50:27 +02:00
parent 803cd30070
commit da0def2486
9 changed files with 466624 additions and 90 deletions

View file

@ -18,7 +18,7 @@ namespace cce {
byte reset = 0;
(int, int) since = (0,0);
while (true) {
Title = Title + " >>> Settings";
Title = Program.title + " >>> Settings";
if (since.Item1 >= 4) {
saved = false;
since.Item1 = 0;
@ -56,11 +56,22 @@ namespace cce {
since.Item2++;
}
}
static internal void Dev() {
if (!File.Exists("dev")) {
BackgroundColor = ConsoleColor.Red;
WriteLine(" \n" +
" Unable to comply, not a dev \n" +
" ");
ResetColor();
return;
}
}
}
internal class AppSettings {
static internal byte Lgwrite = 1;
static internal string Common = "common.json";
static internal string Extended = "extended.json";
static internal string Dictionary = "dictionary.json";
static internal string Settings = "settings.json";
static internal (int, int) top_bottom = (0, 0);
static internal void Check() {

View file

@ -27,12 +27,12 @@ namespace cce {
WriteCrypto();
choice = Chooser();
CursorVisible = false;
var entry = "";
var entry = new List<string>();
if ((new int[] {1,2}).Contains(choice)) {
Utils.LagWrite("Please enter the sentence: ");
Utils.LagWrite("Please enter the sentence (Enter to submit, Shift+Enter for another line: ");
CursorVisible = true;
//Write("Please enter the sentence: ");
entry = ReadLine();
entry = Utils.Entry();
CursorVisible = false;
}
bool skip = false;
@ -40,7 +40,7 @@ namespace cce {
else if (choice == 2) Transcoder.Decode(entry);
else if (choice == 5) Transcoder.Teacher();
else if (choice == 8) skip = App.Settings();
else if (choice == 9) Transcoder.head_transcribe();
else if (choice == 9) App.Dev();
else if (choice == 254) Help();
else if (choice == 255) { Beep(4000, 200); return; }
@ -61,7 +61,7 @@ namespace cce {
+"\n[5] Teach new words"
+"\n-------------------------"
+"\n[8] Settings"
+"\n[9] DEV: Update JSON files using sorted files from python"
+"\n[9] DEV"
+"\n[?] Help"
+"\n[Backspace] Exit"
+"\n>>> ");

View file

@ -12,8 +12,8 @@ using static System.Threading.Thread;
namespace cce {
class Transcoder {
static internal string result = "";
static private Dictionary<string, string> extended_dict = null;
static private Dictionary<string, string> common_dict = null;
static private List<string> extended_dict = null;
static private List<string> common_dict = null;
static private Dictionary<char, char> substitution = new Dictionary<char, char>{
{'a','a' },
{'b','t' },
@ -88,15 +88,15 @@ namespace cce {
if (extended_dict == null || common_dict == null) init();
switch (cki) {
case '1':
if (common_dict.ContainsKey(translation)) {
if (common_dict.Contains(translation)) {
WriteLine("Error: Unable to add a new translation. Translation already present.");
} else common_dict.Add(translation, cyphered);
} else common_dict.Add(translation);
entered = true;
break;
case '2':
if (extended_dict.ContainsKey(translation)) {
if (extended_dict.Contains(translation)) {
WriteLine("Error: Unable to add a new translation. Translation already present.");
} else extended_dict.Add(translation, cyphered);
} else extended_dict.Add(translation);
entered = true;
break;
default:
@ -144,26 +144,12 @@ namespace cce {
Write(string.Join("", writeout));
for (int i = 0; i < decode.Length; i++) {
if (symbols[left] != 'x') left++;
//var options = new List<string>();
CursorTop = memTop;
Console.BackgroundColor = ConsoleColor.Green;
Console.ForegroundColor = ConsoleColor.Black;
wordwrite(common_dict, decode[i], entry, left, i);
/*foreach (var item in common_dict) {
if (item.Value == decode[i]) {
CursorLeft = left;
//options.Add(item.Key);
for (int j = 0; j < item.Key.Length; j++) {
Write(Char.IsUpper(entry[i]) ? char.Parse(item.Key[j].ToString().ToUpper()) : char.Parse(item.Key[j].ToString().ToLower()));
}
Write(item.Key.ToUpper());
Sleep(100);
CursorTop++;
}
}*/
wordwrite(common_dict, decode[i], entry, left);
Console.BackgroundColor = ConsoleColor.Blue;
Console.ForegroundColor = ConsoleColor.Black;
wordwrite(extended_dict, decode[i], entry, left, i);
wordwrite(extended_dict, decode[i], entry, left);
ResetColor();
List<List<char>> letter_decode = new List<List<char>>();
for (int j = 0; j < decode[i].Length; j++) {
@ -197,24 +183,10 @@ namespace cce {
ResetColor();
//return string.Join(" ", decoded);
}
static internal void head_transcribe() {
if(!File.Exists("dev")) {
Clear();
BackgroundColor = ConsoleColor.Red;
Utils.LagWrite(" \n" +
" Unable to comply. Not a dev version \n"+
" ", true);
ResetColor();
return;
}
raw_transcribe("common_dict.txt", "common_dict.json");
raw_transcribe("extended_dict.txt", "extended_dict.json");
uniquire();
}
static private void update() {
uniquire();
File.WriteAllText(AppSettings.Extended, JsonConvert.SerializeObject(extended_dict));
File.WriteAllText(AppSettings.Common, JsonConvert.SerializeObject(common_dict));
uniquere();
var dict = new Dictionary<string, List<string>>();
File.WriteAllText(AppSettings.Dictionary, JsonConvert.SerializeObject(dict));
}
static private string raw_encode(string entry) {
var sentence = entry.ToLower();
@ -231,61 +203,28 @@ namespace cce {
static internal bool init() {
if (common_dict != null && extended_dict != null) return true;
var checker = true;
var dict = new Dictionary<string, List<string>>();
WriteLine("[Loading Dictionary]");
if (File.Exists(AppSettings.Extended)) extended_dict = JsonConvert.DeserializeObject<Dictionary<string, string>>(File.ReadAllText(AppSettings.Extended));
else { WriteLine("File missing"); checker = false; }
if (File.Exists(AppSettings.Common)) common_dict = JsonConvert.DeserializeObject<Dictionary<string, string>>(File.ReadAllText(AppSettings.Common));
if (File.Exists(AppSettings.Dictionary)) dict = JsonConvert.DeserializeObject<Dictionary<string, List<string>>>(File.ReadAllText(AppSettings.Dictionary));
else { WriteLine("File missing"); checker = false; }
common_dict = dict["common"];
extended_dict = dict["extended"];
return checker;
}
static private void uniquire() {
static private void uniquere() {
init();
foreach (var item in common_dict) {
if (extended_dict.ContainsKey(item.Key)) extended_dict.Remove(item.Key);
if (extended_dict.Contains(item)) extended_dict.Remove(item);
}
}
static private void raw_transcribe(string input, string output) {
var lines = File.ReadAllLines(input);
for (int i = 0; i < lines.Length; i++) {
lines[i] = lines[i].ToLower();
}
var English = new string[lines.Length];
lines.CopyTo(English, 0);
for (int i = 0; i < English.Length; i++) {
var word = new char[English[i].Length];
for (int j = 0; j < English[i].Length; j++) {
if (substitution.TryGetValue(English[i][j], out char substituted)) {
word[j] = substituted;
}
else {
word[j] = English[i][j];
}
}
lines[i] = String.Join("", word);
WriteLine($"{English[i]}:{lines[i]}");
}
Dictionary<string, string> vals = new Dictionary<string, string>();
for (int i = 0; i < English.Length; i++) {
if (vals.ContainsKey(English[i])) continue;
vals.Add(English[i], lines[i]);
}
File.WriteAllText(output, JsonConvert.SerializeObject(vals));
}
static internal void concat() {
init();
var dict = new Dictionary<string, Dictionary<string, string>>();
dict.Add("short", common_dict);
dict.Add("long", extended_dict);
File.WriteAllText("dictionary.json", JsonConvert.SerializeObject(dict));
}
static private void wordwrite(Dictionary<string, string> collection, string decode, string entry,int left, int i) {
static private void wordwrite(List<string> collection, string decode, string entry,int left) {
foreach (var item in collection) {
if (item.Value == decode) {
var trans = raw_encode(item);
if (trans == decode) {
CursorLeft = left;
//options.Add(item.Key);
for (int j = 0; j < item.Key.Length; j++) {
Write(Char.IsUpper(entry[CursorLeft]) ? Char.ToUpper(item.Key[j]) : Char.ToLower(item.Key[j]));
for (int j = 0; j < item.Length; j++) {
Write(Char.IsUpper(entry[CursorLeft]) ? Char.ToUpper(item[j]) : Char.ToLower(item[j]));
}
Utils.VarSleep(10, low: 20,high:100);
CursorTop++;

View file

@ -27,7 +27,7 @@ namespace cce {
WriteLine();
if (Char.ToLower(cki) == 'y') { Clipboard.SetText(clip); WriteLine("Writing to Clipboard: Done!"); } else WriteLine("Writing to Clipboard: Canceled by User");
}
internal static void LagWrite(string input, bool newline = false) {
static internal void LagWrite(string input, bool newline = false) {
if (AppSettings.Lgwrite == 0) {
if (newline) WriteLine(input);
else Write(input);
@ -59,5 +59,13 @@ namespace cce {
if (newline || i < phrases.Count - 1) WriteLine();
}
}
static internal List<string> Entry() {
var list = new List<string>();
ConsoleKeyInfo cki;
do {
cki = ReadKey();
} while (cki.Key == ConsoleKey.Enter && cki.Modifiers != ConsoleModifiers.Shift);
}
}
}

File diff suppressed because it is too large Load diff

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,26 @@
import json
f1 = open('common.json', 'r')
f2 = open('extended.json', 'r')
data1 = json.load(f1)
data2 = json.load(f2)
f1.close()
f2.close()
words1 = []
words2 = []
for key in data1:
words1.append(key)
for key in data2:
words2.append(key)
dict = {
'common':words1,
'extended':words2
}
f = open("dictionary.json", "w")
json.dump(dict, f)
f.close()
print("done")

1
cce/strip.py Normal file
View file

@ -0,0 +1 @@
import json