public async Task ExportAsync(AggregationResult result) { var kanjis = ConvertToStandardKanjiModel(result); var vocabs = ConvertToStandardVocabModel(result); var kanjiTags = result.KanjiTags.Select(x => new Tag { Key = x.Key, Value = x.Value.Value }).ToList(); var vocabTags = result.VocabTags.Select(x => new Tag { Key = x.Key, Value = x.Value.Value }).ToList(); var homonyms = ComputeHomonyms(vocabs); var synonyms = ComputeSynonyms(vocabs); var metadata = new Metadata { KanjiCount = kanjis.Count, VocabCount = vocabs.Count, HomonymCount = homonyms.Where(x => x.Value.Count > 1).Count(), SynonymCount = synonyms.Where(x => x.Value.Count > 1).Count(), KanjiTagCount = kanjiTags.Count, VocabTagCount = vocabTags.Count, }; await WriteJsonFileAsync(kanjis, "kanjis"); await WriteJsonFileAsync(vocabs, "vocabs"); await WriteJsonFileAsync(kanjiTags, "kanji-tags"); await WriteJsonFileAsync(vocabTags, "vocab-tags"); await WriteJsonFileAsync(homonyms, "homonyms"); await WriteJsonFileAsync(synonyms, "synonyms"); await WriteJsonFileAsync(metadata, "metadata"); }
private List <Vocab> ConvertToStandardVocabModel(AggregationResult result) { return(result.Vocabs.Select(x => new Vocab { Kanji = x.Kanji, Frequency = x.Frequency, Meanings = x.VocabModel.Meanings.Select(cm => new VocabContextualMeaning { Kana = cm.Kana, Meanings = cm.Meanings, Tags = CreateTags(cm.Tags), }).ToList(), }).OrderBy(x => x.Frequency).ToList()); }
private List <Kanji> ConvertToStandardKanjiModel(AggregationResult result) { return(result.Kanjis.Select(x => new Kanji { Frequency = x.Frequency, Kunyomi = x.Kunyomi, Meanings = x.Meanings, Onyomi = x.Onyomi, Tags = CreateTags(x.Tags), Character = x.Kanji, WaniKaniLevel = x.WaniKaniLevel, Similar = x.Similar, Grade = x.KanjiModel.Grade, Jlpt = x.KanjiModel.Jlpt, Strokes = x.KanjiModel.Strokes, }).OrderBy(x => x.Character).ToList()); }