changing the files
This commit is contained in:
parent
803cd30070
commit
da0def2486
13
cce/App.cs
13
cce/App.cs
|
@ -18,7 +18,7 @@ namespace cce {
|
||||||
byte reset = 0;
|
byte reset = 0;
|
||||||
(int, int) since = (0,0);
|
(int, int) since = (0,0);
|
||||||
while (true) {
|
while (true) {
|
||||||
Title = Title + " >>> Settings";
|
Title = Program.title + " >>> Settings";
|
||||||
if (since.Item1 >= 4) {
|
if (since.Item1 >= 4) {
|
||||||
saved = false;
|
saved = false;
|
||||||
since.Item1 = 0;
|
since.Item1 = 0;
|
||||||
|
@ -56,11 +56,22 @@ namespace cce {
|
||||||
since.Item2++;
|
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 {
|
internal class AppSettings {
|
||||||
static internal byte Lgwrite = 1;
|
static internal byte Lgwrite = 1;
|
||||||
static internal string Common = "common.json";
|
static internal string Common = "common.json";
|
||||||
static internal string Extended = "extended.json";
|
static internal string Extended = "extended.json";
|
||||||
|
static internal string Dictionary = "dictionary.json";
|
||||||
static internal string Settings = "settings.json";
|
static internal string Settings = "settings.json";
|
||||||
static internal (int, int) top_bottom = (0, 0);
|
static internal (int, int) top_bottom = (0, 0);
|
||||||
static internal void Check() {
|
static internal void Check() {
|
||||||
|
|
|
@ -27,12 +27,12 @@ namespace cce {
|
||||||
WriteCrypto();
|
WriteCrypto();
|
||||||
choice = Chooser();
|
choice = Chooser();
|
||||||
CursorVisible = false;
|
CursorVisible = false;
|
||||||
var entry = "";
|
var entry = new List<string>();
|
||||||
if ((new int[] {1,2}).Contains(choice)) {
|
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;
|
CursorVisible = true;
|
||||||
//Write("Please enter the sentence: ");
|
//Write("Please enter the sentence: ");
|
||||||
entry = ReadLine();
|
entry = Utils.Entry();
|
||||||
CursorVisible = false;
|
CursorVisible = false;
|
||||||
}
|
}
|
||||||
bool skip = false;
|
bool skip = false;
|
||||||
|
@ -40,7 +40,7 @@ namespace cce {
|
||||||
else if (choice == 2) Transcoder.Decode(entry);
|
else if (choice == 2) Transcoder.Decode(entry);
|
||||||
else if (choice == 5) Transcoder.Teacher();
|
else if (choice == 5) Transcoder.Teacher();
|
||||||
else if (choice == 8) skip = App.Settings();
|
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 == 254) Help();
|
||||||
else if (choice == 255) { Beep(4000, 200); return; }
|
else if (choice == 255) { Beep(4000, 200); return; }
|
||||||
|
|
||||||
|
@ -61,7 +61,7 @@ namespace cce {
|
||||||
+"\n[5] Teach new words"
|
+"\n[5] Teach new words"
|
||||||
+"\n-------------------------"
|
+"\n-------------------------"
|
||||||
+"\n[8] Settings"
|
+"\n[8] Settings"
|
||||||
+"\n[9] DEV: Update JSON files using sorted files from python"
|
+"\n[9] DEV"
|
||||||
+"\n[?] Help"
|
+"\n[?] Help"
|
||||||
+"\n[Backspace] Exit"
|
+"\n[Backspace] Exit"
|
||||||
+"\n>>> ");
|
+"\n>>> ");
|
||||||
|
|
|
@ -12,8 +12,8 @@ using static System.Threading.Thread;
|
||||||
namespace cce {
|
namespace cce {
|
||||||
class Transcoder {
|
class Transcoder {
|
||||||
static internal string result = "";
|
static internal string result = "";
|
||||||
static private Dictionary<string, string> extended_dict = null;
|
static private List<string> extended_dict = null;
|
||||||
static private Dictionary<string, string> common_dict = null;
|
static private List<string> common_dict = null;
|
||||||
static private Dictionary<char, char> substitution = new Dictionary<char, char>{
|
static private Dictionary<char, char> substitution = new Dictionary<char, char>{
|
||||||
{'a','a' },
|
{'a','a' },
|
||||||
{'b','t' },
|
{'b','t' },
|
||||||
|
@ -88,15 +88,15 @@ namespace cce {
|
||||||
if (extended_dict == null || common_dict == null) init();
|
if (extended_dict == null || common_dict == null) init();
|
||||||
switch (cki) {
|
switch (cki) {
|
||||||
case '1':
|
case '1':
|
||||||
if (common_dict.ContainsKey(translation)) {
|
if (common_dict.Contains(translation)) {
|
||||||
WriteLine("Error: Unable to add a new translation. Translation already present.");
|
WriteLine("Error: Unable to add a new translation. Translation already present.");
|
||||||
} else common_dict.Add(translation, cyphered);
|
} else common_dict.Add(translation);
|
||||||
entered = true;
|
entered = true;
|
||||||
break;
|
break;
|
||||||
case '2':
|
case '2':
|
||||||
if (extended_dict.ContainsKey(translation)) {
|
if (extended_dict.Contains(translation)) {
|
||||||
WriteLine("Error: Unable to add a new translation. Translation already present.");
|
WriteLine("Error: Unable to add a new translation. Translation already present.");
|
||||||
} else extended_dict.Add(translation, cyphered);
|
} else extended_dict.Add(translation);
|
||||||
entered = true;
|
entered = true;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -144,26 +144,12 @@ namespace cce {
|
||||||
Write(string.Join("", writeout));
|
Write(string.Join("", writeout));
|
||||||
for (int i = 0; i < decode.Length; i++) {
|
for (int i = 0; i < decode.Length; i++) {
|
||||||
if (symbols[left] != 'x') left++;
|
if (symbols[left] != 'x') left++;
|
||||||
//var options = new List<string>();
|
|
||||||
CursorTop = memTop;
|
CursorTop = memTop;
|
||||||
Console.BackgroundColor = ConsoleColor.Green;
|
Console.BackgroundColor = ConsoleColor.Green;
|
||||||
Console.ForegroundColor = ConsoleColor.Black;
|
Console.ForegroundColor = ConsoleColor.Black;
|
||||||
wordwrite(common_dict, decode[i], entry, left, i);
|
wordwrite(common_dict, decode[i], entry, left);
|
||||||
/*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++;
|
|
||||||
}
|
|
||||||
}*/
|
|
||||||
Console.BackgroundColor = ConsoleColor.Blue;
|
Console.BackgroundColor = ConsoleColor.Blue;
|
||||||
Console.ForegroundColor = ConsoleColor.Black;
|
wordwrite(extended_dict, decode[i], entry, left);
|
||||||
wordwrite(extended_dict, decode[i], entry, left, i);
|
|
||||||
ResetColor();
|
ResetColor();
|
||||||
List<List<char>> letter_decode = new List<List<char>>();
|
List<List<char>> letter_decode = new List<List<char>>();
|
||||||
for (int j = 0; j < decode[i].Length; j++) {
|
for (int j = 0; j < decode[i].Length; j++) {
|
||||||
|
@ -197,24 +183,10 @@ namespace cce {
|
||||||
ResetColor();
|
ResetColor();
|
||||||
//return string.Join(" ", decoded);
|
//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() {
|
static private void update() {
|
||||||
uniquire();
|
uniquere();
|
||||||
File.WriteAllText(AppSettings.Extended, JsonConvert.SerializeObject(extended_dict));
|
var dict = new Dictionary<string, List<string>>();
|
||||||
File.WriteAllText(AppSettings.Common, JsonConvert.SerializeObject(common_dict));
|
File.WriteAllText(AppSettings.Dictionary, JsonConvert.SerializeObject(dict));
|
||||||
}
|
}
|
||||||
static private string raw_encode(string entry) {
|
static private string raw_encode(string entry) {
|
||||||
var sentence = entry.ToLower();
|
var sentence = entry.ToLower();
|
||||||
|
@ -231,61 +203,28 @@ namespace cce {
|
||||||
static internal bool init() {
|
static internal bool init() {
|
||||||
if (common_dict != null && extended_dict != null) return true;
|
if (common_dict != null && extended_dict != null) return true;
|
||||||
var checker = true;
|
var checker = true;
|
||||||
|
var dict = new Dictionary<string, List<string>>();
|
||||||
WriteLine("[Loading Dictionary]");
|
WriteLine("[Loading Dictionary]");
|
||||||
if (File.Exists(AppSettings.Extended)) extended_dict = JsonConvert.DeserializeObject<Dictionary<string, string>>(File.ReadAllText(AppSettings.Extended));
|
if (File.Exists(AppSettings.Dictionary)) dict = JsonConvert.DeserializeObject<Dictionary<string, List<string>>>(File.ReadAllText(AppSettings.Dictionary));
|
||||||
else { WriteLine("File missing"); checker = false; }
|
|
||||||
if (File.Exists(AppSettings.Common)) common_dict = JsonConvert.DeserializeObject<Dictionary<string, string>>(File.ReadAllText(AppSettings.Common));
|
|
||||||
else { WriteLine("File missing"); checker = false; }
|
else { WriteLine("File missing"); checker = false; }
|
||||||
|
common_dict = dict["common"];
|
||||||
|
extended_dict = dict["extended"];
|
||||||
return checker;
|
return checker;
|
||||||
}
|
}
|
||||||
static private void uniquire() {
|
static private void uniquere() {
|
||||||
init();
|
init();
|
||||||
foreach (var item in common_dict) {
|
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) {
|
static private void wordwrite(List<string> collection, string decode, string entry,int left) {
|
||||||
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) {
|
|
||||||
foreach (var item in collection) {
|
foreach (var item in collection) {
|
||||||
if (item.Value == decode) {
|
var trans = raw_encode(item);
|
||||||
|
if (trans == decode) {
|
||||||
CursorLeft = left;
|
CursorLeft = left;
|
||||||
//options.Add(item.Key);
|
//options.Add(item.Key);
|
||||||
for (int j = 0; j < item.Key.Length; j++) {
|
for (int j = 0; j < item.Length; j++) {
|
||||||
Write(Char.IsUpper(entry[CursorLeft]) ? Char.ToUpper(item.Key[j]) : Char.ToLower(item.Key[j]));
|
Write(Char.IsUpper(entry[CursorLeft]) ? Char.ToUpper(item[j]) : Char.ToLower(item[j]));
|
||||||
}
|
}
|
||||||
Utils.VarSleep(10, low: 20,high:100);
|
Utils.VarSleep(10, low: 20,high:100);
|
||||||
CursorTop++;
|
CursorTop++;
|
||||||
|
|
10
cce/Utils.cs
10
cce/Utils.cs
|
@ -27,7 +27,7 @@ namespace cce {
|
||||||
WriteLine();
|
WriteLine();
|
||||||
if (Char.ToLower(cki) == 'y') { Clipboard.SetText(clip); WriteLine("Writing to Clipboard: Done!"); } else WriteLine("Writing to Clipboard: Canceled by User");
|
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 (AppSettings.Lgwrite == 0) {
|
||||||
if (newline) WriteLine(input);
|
if (newline) WriteLine(input);
|
||||||
else Write(input);
|
else Write(input);
|
||||||
|
@ -59,5 +59,13 @@ namespace cce {
|
||||||
if (newline || i < phrases.Count - 1) WriteLine();
|
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);
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
1004
cce/necessary files/common.txt
Normal file
1004
cce/necessary files/common.txt
Normal file
File diff suppressed because it is too large
Load diff
1
cce/necessary files/dictionary.json
Normal file
1
cce/necessary files/dictionary.json
Normal file
File diff suppressed because one or more lines are too long
465544
cce/necessary files/extended.txt
Normal file
465544
cce/necessary files/extended.txt
Normal file
File diff suppressed because it is too large
Load diff
26
cce/necessary files/strip.py
Normal file
26
cce/necessary files/strip.py
Normal 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
1
cce/strip.py
Normal file
|
@ -0,0 +1 @@
|
||||||
|
import json
|
Loading…
Reference in a new issue