static void Main(string[] args) { var dictionary = from word in OneToManyJsonSerializer.Deserialize(File.ReadAllText(@"dictionary.json")).Words select word.Entry.Form; using (StreamReader sr = new StreamReader("input.txt")) using (StreamWriter swBuffer = new StreamWriter("buffer.tsv")) using (StreamWriter swAll = new StreamWriter("all.tsv")) using (StreamWriter swExample = new StreamWriter("example.tsv")) { var text = sr.ReadToEnd(); var words = from word in text.Split('\n') .Distinct() where !dictionary.Contains(word) select word; var analyzer = new LineparinePhoneticBufferFrequencyAnalyzer { Text = text, Words = words, }; var table = analyzer.Analyze(); var alphabet = new List <string> { "i", "y", "u", "o", "e", "a", "p", "fh", "f", "t", "c", "x", "k", "q", "h", "r", "z", "m", "n", "r", "l", "j", "w", "b", "vh", "v", "d", "s", "g", "dz", "ph", "ts", "ch", "ng", "sh", "th", "dh", "kh", "rkh", "rl", }; foreach (var first in alphabet) { foreach (var last in alphabet) { var tuple = new Tuple <string, string>(first, last); if (table.ContainsKey(tuple)) { var example = table[tuple].Examples .Select(w => $"{w.Word}\t{string.Join(" ", w.Decomposition)}\t{w.FastLetterIndex}\t{w.LastLetterIndex}") .Aggregate((now, next) => $"{now}\n{next}"); swAll.Write(table[tuple].All + "\t"); swBuffer.Write(table[tuple].Buffer + "\t"); swExample.WriteLine($"{first.ToString()} + {last.ToString()}\n{example}"); swExample.WriteLine(); } else { swBuffer.Write("0\t"); swAll.Write("0\t"); } } swBuffer.Write("\n"); swAll.Write("\n"); } } }
static void Main(string[] args) { var json = File.ReadAllText(@"lojbantan-zei-jbovlaste.json"); var dictionary = OneToManyJsonSerializer.Deserialize(json); Thesaurus thesaurus = JsonSerializer.Deserialize <Thesaurus>(File.ReadAllText(@"relations.json")); foreach (var word in dictionary.Words.Where(word => !word.Tags.Contains("ラフシ") && !word.Tags.Contains("語根《ラフシ》"))) { word.Relations = new List <Relation>(); } foreach (var tagFamily in thesaurus.TagFamilies) { var words = dictionary.Words.Where(word => word.Tags.Contains(tagFamily.Tag)); foreach (var category in tagFamily.Categories) { var relations = new List <Relation>(); foreach (var group in category.Groups) { foreach (var relationWord in group.Relations) { relations.Add(new Relation { Title = group.Title, Entry = dictionary.Words.First(word => word.Entry.Form == relationWord && word.Tags.Contains(tagFamily.Tag)).Entry }); } } foreach (var group in category.Groups) { foreach (var relationWord in group.Relations) { var word = dictionary.Words.First(w => w.Entry.Form == relationWord && w.Tags.Contains(tagFamily.Tag)); word.Relations = word.Relations.Union(relations).ToList(); } } } } var options = new JsonSerializerOptions { Encoder = JavaScriptEncoder.Create(UnicodeRanges.All), WriteIndented = true, }; json = OneToManyJsonSerializer.Serialize(dictionary, options); File.WriteAllText(@"output.json", json); }
static void Main() { var path = @"lineparine.csv"; var dicwords = Load(path); var dictionary = new OneToManyJson { Zpdic = new Zpdic { AlphabetOrder = "", WordOrderType = "UNICODE", Punctuations = new List <string> { ",", "、" }, IgnoredTranslationRegex = @"\(.*\)|(.*)|\[.*\]", PlainInformationTitles = null, InformationTitleOrder = null, FormFontFamily = null, DefaultWord = new Word { }, } }; int totalTicks = dicwords.Count; var progressBarOptions = new ProgressBarOptions { ForegroundColor = ConsoleColor.Yellow, BackgroundColor = ConsoleColor.DarkGray, BackgroundCharacter = '.', ProgressCharacter = '#', }; var childProgressBarOptions = new ProgressBarOptions { ForegroundColor = ConsoleColor.Green, BackgroundColor = ConsoleColor.DarkGray, BackgroundCharacter = '.', ProgressCharacter = '#', CollapseWhenFinished = false, }; using (var pbar = new ProgressBar(5, "Total Progress", progressBarOptions)) using (var pbar5 = pbar.Spawn(1, "Output to ./output.json", childProgressBarOptions)) using (var pbar4 = pbar.Spawn(1, "Relation ID completion", childProgressBarOptions)) using (var pbar3 = pbar.Spawn(totalTicks, "Register cases", childProgressBarOptions)) using (var pbar2 = pbar.Spawn(totalTicks, "Register subheadings", childProgressBarOptions)) using (var pbar1 = pbar.Spawn(totalTicks, "Register words", childProgressBarOptions)) { foreach (var dicword in dicwords) { var wc = new WordConverter { DicWord = dicword, DicWords = dicwords }; var word = wc.Convert(); dictionary.AddWord(word); var subheadings = wc.AddSubheading(dictionary); pbar1.Tick($"Register \"{word.Entry.Form}\" in the dictionary"); foreach (var subheading in subheadings) { if (dictionary.Words.All(w => w.Entry.Id != subheading.Entry.Id)) { dictionary.AddWord(subheading); } } pbar2.Tick($"Register \"{word.Entry.Form}\"'s subheadings in the dictionary"); } pbar.Tick("Register words"); pbar.Tick("Register subheadings"); pbar3.MaxTicks = dictionary.Words.Count; var casegen = new CaseGenerator(); foreach (var word in dictionary.Words) { casegen.Word = word; casegen.AddCase(); pbar3.Tick($"Register \"{word.Entry.Form}\"'s cases in the dictionary"); } pbar.Tick("Register cases"); dictionary.RelationIdCompletion(); pbar4.Tick("Relation ID completion"); pbar.Tick("Relation ID completion"); var options = new System.Text.Json.JsonSerializerOptions { Encoder = JavaScriptEncoder.Create(UnicodeRanges.All), WriteIndented = true, }; var json = OneToManyJsonSerializer.Serialize(dictionary, options); File.WriteAllText(@"output.json", json); pbar5.Tick("Output to ./output.json"); pbar.Tick("Output to ./output.json"); } }