public WordVM(WordInfo wordInfo, ILanguageService lang) { var s = wordInfo.RawWord; StringForm = s; codePoints.AddRange(s.AsCodePoints().Select(rawCp => { var cp = CodePoint.FromInt(rawCp); var vm = new CodePointVM( cp, lang.LookupRelatedCharacters(cp), cp is Kanji k ? lang.LookupRadicals(k).ValueOr(Enumerable.Empty <CodePoint>()) : Enumerable.Empty <CodePoint>(), cp is Kana kana ? lang.LookupRomaji(kana) : null); return(vm); })); WordInfo = wordInfo; }
public WordVM(WordInfo wordInfo, IKanjiProperties lang, IKanaProperties kanaProperties, IRelated related) { var s = wordInfo.RawWord; StringForm = s; codePoints.AddRange(s.AsCodePoints().Select(rawCp => { var cp = CodePoint.FromInt(rawCp); var vm = new CodePointVM( cp, related.FindRelated(cp).SelectMany(g => g), cp is Kanji k ? lang.LookupRadicalsByKanji(k).ValueOr(Enumerable.Empty <CodePoint>()) : Enumerable.Empty <CodePoint>(), cp is Kana kana ? kanaProperties.LookupRomaji(kana.ToString()) : null); return(vm); })); WordInfo = wordInfo; }
private static IReadOnlyDictionary <CodePoint, string> CreateTextRadicalMappings(IEnumerable <CodePoint> radicals, IReadOnlyDictionary <int, int> remapper) { var dict = radicals.ToDictionary( r => r, r => Char.ConvertFromUtf32(remapper.GetValueOrNone(r.Utf32).ValueOr(r.Utf32))); /*var d = new Dictionary<int, int> * { * {'化', '⺅'}, * {'刈', '⺉'}, * {'込', '⻌'}, * {'汁', '氵'}, * {'初', '衤'}, * {'尚', '⺌'}, * {'買', '罒'}, * {'犯', '犭'}, * {'忙', '忄'}, * {'礼', '礻'}, * {'个', 131490}, * {'老', '⺹'}, * {'扎', '扌'}, * {'杰', '灬'}, * {'疔', '疒'}, * {'禹', '禸'}, * {'艾', '⺾'}, * //{'邦', '⻏'}, * //{'阡', '⻖'}, * // 并 none available - upside-down ハ * };*/ dict[CodePoint.FromInt('邦')] = "邦"; dict[CodePoint.FromInt('阡')] = "阡"; dict[CodePoint.FromInt('老')] = "⺹"; dict[CodePoint.FromInt('并')] = "丷"; dict[CodePoint.FromInt('乞')] = "𠂉"; return(dict); }
public static Kernel Configure(string dataDir) { var kernel = new Kernel(); kernel.Bind(() => KanjiDict.Create(Path.Combine(dataDir, "character", "kanjidic2.xml.gz"))); kernel.Bind(() => new Kradfile(Path.Combine(dataDir, "character", "kradfile1_plus_2_utf8"), Encoding.UTF8)); kernel.Bind(() => new Radkfile(Path.Combine(dataDir, "character", "radkfile1_plus_2_utf8"), Encoding.UTF8)); kernel.Bind(() => JMDictLookup.Create(Path.Combine(dataDir, "dictionaries", "JMdict_e.gz"), Path.Combine(dataDir, "dictionaries", "JMdict_e.cache"))); kernel.Bind(() => JMNedictLookup.Create(Path.Combine(dataDir, "dictionaries", "JMnedict.xml.gz"), Path.Combine(dataDir, "dictionaries", "JMnedict.xml.cache"))); kernel.Bind(() => new FrequencyList(Path.Combine(dataDir, "other", "word_form_frequency_list.txt"), Encoding.UTF8)); kernel.Bind(() => new Tanaka(Path.Combine(dataDir, "corpora", "examples.utf.gz"), Encoding.UTF8)); kernel.Bind(() => new JESC(Path.Combine(dataDir, "corpora", "jesc_raw"), Encoding.UTF8)); kernel.Bind(() => new BasicExpressionsCorpus(Path.Combine(dataDir, "corpora", "JEC_basic_sentence_v1-2.csv"), Encoding.UTF8)); kernel.Bind <IFontResolver>(() => new DefaultFontResolver(Path.Combine(dataDir, "character", "KanjiStrokeOrders"))); kernel.Bind <IMorphologicalAnalyzer <IpadicEntry> >(() => new MeCabIpadic(new MeCabParam { DicDir = Path.Combine(dataDir, "mecab", "ipadic"), UseMemoryMappedFile = true })); kernel.Bind <IMorphologicalAnalyzer <UnidicEntry> >(() => new MeCabUnidic(new MeCabParam { DicDir = Path.Combine(dataDir, "mecab", "unidic"), UseMemoryMappedFile = true })); kernel.Bind <IMorphologicalAnalyzer <IEntry> >(get => { // not sure if objects created this way will be disposed twice // probably doesn't matter (IDisposable.Dispose's contract says // it's not a problem), but still try { return(get.Get <IMorphologicalAnalyzer <UnidicEntry> >()); } catch (Exception) { return(get.Get <IMorphologicalAnalyzer <IpadicEntry> >()); } }); kernel.Bind <Models.Settings>(get => { try { return(JsonConvert.DeserializeObject <Models.Settings>(File.ReadAllText("settings.config"))); } catch (FileNotFoundException) { return(Models.Settings.CreateDefault()); } }); kernel.Bind(get => new ReplRootModule( get.Get <JMDictLookup>(), get.Get <JMNedictLookup>(), new ReplCorpora( get.Get <BasicExpressionsCorpus>(), get.Get <Tanaka>(), get.Get <JESC>()))); kernel.Bind(get => new RadicalRemapper(get.Get <Kradfile>(), get.Get <Radkfile>())); kernel.Bind(get => EasilyConfusedKana.FromFile(Path.Combine(dataDir, "character", "confused.txt"))); kernel.Bind <IKanjiProperties, KanjiProperties>(); kernel.Bind(get => new KanjiProperties( get.Get <KanjiDict>(), get.Get <Kradfile>(), get.Get <Radkfile>(), null)); kernel.Bind(get => new MainWindowVM( get.Get <ISentenceParser>(), new KanaBoardVM(Path.Combine(dataDir, "character", "hiragana_romaji.txt"), Encoding.UTF8), new KanaBoardVM(Path.Combine(dataDir, "character", "katakana_romaji.txt"), Encoding.UTF8), get.Get <IEnumerable <UsageDataSourcePreviewVM> >(), get.Get <KanjiRadicalLookupControlVM>(), get.Get <IRelated>(), get.Get <IKanjiProperties>(), get.Get <IKanaProperties>(), get.Get <IWebBrowser>(), () => { var version = FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location) .ProductVersion; return ($"Didactical Enigma {version}\n\n{File.ReadAllText(Path.Combine(dataDir, @"about.txt"), Encoding.UTF8)}"); }, get.Get <ITextInsertCommand>(), get.Get <Models.Settings>(), get.Get <ReplVM>(), get.Get <DidacticalEnigma.Mem.Client.DidacticalEnigmaMemViewModel>())); kernel.Bind(get => new KanjiRadicalLookupControlVM( get.Get <KanjiRadicalLookup>(), get.Get <IKanjiProperties>(), get.Get <IRadicalSearcher>(), CreateTextRadicalMappings(get.Get <KanjiRadicalLookup>().AllRadicals, get.Get <RadkfileKanjiAliveCorrelator>()))); kernel.Bind <IRomaji, ModifiedHepburn>(); kernel.Bind(get => new ModifiedHepburn( get.Get <IMorphologicalAnalyzer <IEntry> >(), get.Get <IKanaProperties>())); kernel.Bind <IAutoGlosser, AutoGlosserNext>(); kernel.Bind(get => new AutoGlosserNext(get.Get <ISentenceParser>(), get.Get <JMDictLookup>(), get.Get <IKanaProperties>())); kernel.Bind(get => new[] { new DataSourceVM(new CharacterDataSource(get.Get <IKanjiProperties>(), get.Get <IKanaProperties>()), get.Get <IFlowDocumentRichFormattingRenderer>()), new DataSourceVM(new CharacterStrokeOrderDataSource(), get.Get <IFlowDocumentRichFormattingRenderer>()), new DataSourceVM(new JMDictDataSource(get.Get <JMDictLookup>(), get.Get <IKanaProperties>()), get.Get <IFlowDocumentRichFormattingRenderer>()), new DataSourceVM(new JNeDictDataSource(get.Get <JMNedictLookup>()), get.Get <IFlowDocumentRichFormattingRenderer>()), new DataSourceVM(new VerbConjugationDataSource(get.Get <JMDictLookup>()), get.Get <IFlowDocumentRichFormattingRenderer>()), new DataSourceVM(new WordFrequencyRatingDataSource(get.Get <FrequencyList>()), get.Get <IFlowDocumentRichFormattingRenderer>()), new DataSourceVM(new PartialExpressionJMDictDataSource(get.Get <IdiomDetector>()), get.Get <IFlowDocumentRichFormattingRenderer>()), new DataSourceVM(new JGramDataSource(get.Get <IJGramLookup>()), get.Get <IFlowDocumentRichFormattingRenderer>()), new DataSourceVM(new AutoGlosserDataSource(get.Get <IAutoGlosser>()), get.Get <IFlowDocumentRichFormattingRenderer>()), new DataSourceVM(new CustomNotesDataSource(Path.Combine(dataDir, "custom", "custom_notes.txt")), get.Get <IFlowDocumentRichFormattingRenderer>()), new DataSourceVM(new TanakaCorpusFastDataSource(get.Get <Corpus>()), get.Get <IFlowDocumentRichFormattingRenderer>()), new DataSourceVM(new TanakaCorpusDataSource(get.Get <Tanaka>()), get.Get <IFlowDocumentRichFormattingRenderer>()), new DataSourceVM(new BasicExpressionCorpusDataSource(get.Get <BasicExpressionsCorpus>()), get.Get <IFlowDocumentRichFormattingRenderer>()), new DataSourceVM(new PartialWordLookupJMDictDataSource(get.Get <PartialWordLookup>(), get.Get <FrequencyList>()), get.Get <IFlowDocumentRichFormattingRenderer>()), new DataSourceVM(new JESCDataSource(get.Get <JESC>()), get.Get <IFlowDocumentRichFormattingRenderer>()), new DataSourceVM(new RomajiDataSource(get.Get <IRomaji>()), get.Get <IFlowDocumentRichFormattingRenderer>()), new DataSourceVM(new DidacticalEnigmaMemDataSource(get.Get <DidacticalEnigma.Mem.Client.DidacticalEnigmaMemViewModel>().ClientAccessor), get.Get <IFlowDocumentRichFormattingRenderer>()) }.Concat(get.Get <EpwingDictionaries>().Dictionaries.Select(dict => new DataSourceVM(new EpwingDataSource(dict, get.Get <IKanaProperties>()), get.Get <IFlowDocumentRichFormattingRenderer>(), dict.Revision)))); kernel.Bind <IKanaProperties, KanaProperties2>(); kernel.Bind(get => new KanaProperties2(Path.Combine(dataDir, "character", "kana.txt"), Encoding.UTF8)); kernel.Bind(get => new SimilarKanji(Path.Combine(dataDir, "character", "kanji.tgz_similars.ut8"), Encoding.UTF8)); kernel.Bind(get => new SentenceParser(get.Get <IMorphologicalAnalyzer <IEntry> >(), get.Get <JMDictLookup>())); kernel.Bind <ISentenceParser, SentenceParser>(); kernel.Bind <IRelated>(get => new CompositeRelated( get.Get <KanaProperties2>(), get.Get <EasilyConfusedKana>(), get.Get <SimilarKanji>())); kernel.Bind <IEnumerable <UsageDataSourcePreviewVM> >(get => new [] { new UsageDataSourcePreviewVM(get.Get <IEnumerable <DataSourceVM> >(), "view.config"), new UsageDataSourcePreviewVM(get.Get <IEnumerable <DataSourceVM> >(), "view_2.config"), new UsageDataSourcePreviewVM(get.Get <IEnumerable <DataSourceVM> >(), "view_3.config") }); kernel.Bind(get => CreateEpwing(Path.Combine(dataDir, "epwing"))); kernel.Bind(get => new IdiomDetector(get.Get <JMDictLookup>(), get.Get <IMorphologicalAnalyzer <IpadicEntry> >(), Path.Combine(dataDir, "dictionaries", "idioms.cache"))); kernel.Bind(get => new PartialWordLookup(get.Get <JMDictLookup>(), get.Get <IRadicalSearcher>(), get.Get <KanjiRadicalLookup>())); kernel.Bind(get => { using (var reader = File.OpenText(Path.Combine(dataDir, "character", "radkfile1_plus_2_utf8"))) return(new KanjiRadicalLookup(Radkfile.Parse(reader), get.Get <KanjiDict>())); }); kernel.Bind <IWebBrowser>(get => new WebBrowser()); kernel.Bind <IFlowDocumentRichFormattingRenderer>(get => new FlowDocumentRichFormattingRenderer(get.Get <IFontResolver>(), get.Get <IWebBrowser>())); kernel.Bind <IJGramLookup>(get => new JGramLookup( Path.Combine(dataDir, "dictionaries", "jgram"), Path.Combine(dataDir, "dictionaries", "jgram_lookup"), Path.Combine(dataDir, "dictionaries", "jgram.cache"))); kernel.Bind(get => new RadkfileKanjiAliveCorrelator(Path.Combine(dataDir, "character", "radkfile_kanjilive_correlation_data.txt"))); kernel.Bind <IRadicalSearcher, RadicalSearcher>(); kernel.Bind(get => new RadicalSearcher( get.Get <KanjiRadicalLookup>().AllRadicals, KanjiAliveJapaneseRadicalInformation.Parse(Path.Combine(dataDir, "character", "japanese-radicals.csv")), get.Get <RadkfileKanjiAliveCorrelator>())); kernel.Bind(get => new Corpus(get.Get <Tanaka>().AllSentences, get.Get <IMorphologicalAnalyzer <IpadicEntry> >(), Path.Combine(dataDir, "corpora", "tanaka.cache"))); kernel.Bind(get => new DidacticalEnigma.Mem.Client.DidacticalEnigmaMemViewModel()); return(kernel); IReadOnlyDictionary <CodePoint, string> CreateTextRadicalMappings(IEnumerable <CodePoint> radicals, IReadOnlyDictionary <int, int> remapper) { var dict = radicals.ToDictionary( r => r, r => char.ConvertFromUtf32(remapper.GetValueOrNone(r.Utf32).ValueOr(r.Utf32))); /*var d = new Dictionary<int, int> * { * {'化', '⺅'}, * {'刈', '⺉'}, * {'込', '⻌'}, * {'汁', '氵'}, * {'初', '衤'}, * {'尚', '⺌'}, * {'買', '罒'}, * {'犯', '犭'}, * {'忙', '忄'}, * {'礼', '礻'}, * {'个', 131490}, * {'老', '⺹'}, * {'扎', '扌'}, * {'杰', '灬'}, * {'疔', '疒'}, * {'禹', '禸'}, * {'艾', '⺾'}, * //{'邦', '⻏'}, * //{'阡', '⻖'}, * // 并 none available - upside-down ハ * };*/ dict[CodePoint.FromInt('邦')] = "邦"; dict[CodePoint.FromInt('阡')] = "阡"; dict[CodePoint.FromInt('老')] = "⺹"; dict[CodePoint.FromInt('并')] = "丷"; dict[CodePoint.FromInt('乞')] = "𠂉"; return(dict); } EpwingDictionaries CreateEpwing(string targetPath) { var dictionaries = new EpwingDictionaries(); try { var zipFiles = new Dictionary <string, ZipFile2>(); try { zipFiles = Directory.EnumerateFiles(targetPath, "*.zip") .ToDictionary(path => path, path => new ZipFile2(path)); var dicts = zipFiles .Select(file => new YomichanTermDictionary(file.Value, file.Key + ".cache")); foreach (var dict in dicts) { dictionaries.Add(dict); } } finally { foreach (var entry in zipFiles) { entry.Value.Dispose(); } } } catch (DirectoryNotFoundException) { } catch (InvalidOperationException ex) { MessageBox.Show( ex.Message + "\nIt was not possible to load the EPWING external dictionary.", "Error", MessageBoxButton.OK, MessageBoxImage.Warning); } return(dictionaries); } }
public static Kernel Configure(string dataDir) { var kernel = new Kernel(); kernel.BindFactory(() => KanjiDict.Create(Path.Combine(dataDir, "character", "kanjidic2.xml.gz"))); kernel.BindFactory(() => new JDict.Kradfile(Path.Combine(dataDir, "character", "kradfile1_plus_2_utf8"), Encoding.UTF8)); kernel.BindFactory(() => new Radkfile(Path.Combine(dataDir, "character", "radkfile1_plus_2_utf8"), Encoding.UTF8)); kernel.BindFactory(() => JMDictLookup.Create(Path.Combine(dataDir, "dictionaries", "JMdict_e.gz"), Path.Combine(dataDir, "dictionaries", "JMdict_e.cache"))); kernel.BindFactory(() => JMNedictLookup.Create(Path.Combine(dataDir, "dictionaries", "JMnedict.xml.gz"), Path.Combine(dataDir, "dictionaries", "JMnedict.xml.cache"))); kernel.BindFactory(() => new FrequencyList(Path.Combine(dataDir, "other", "word_form_frequency_list.txt"), Encoding.UTF8)); kernel.BindFactory(() => new Tanaka(Path.Combine(dataDir, "corpora", "examples.utf.gz"), Encoding.UTF8)); kernel.BindFactory(() => new JESC(Path.Combine(dataDir, "corpora", "jesc_raw"), Encoding.UTF8)); kernel.BindFactory(() => new BasicExpressionsCorpus(Path.Combine(dataDir, "corpora", "JEC_basic_sentence_v1-2.csv"), Encoding.UTF8)); kernel.BindFactory <IMorphologicalAnalyzer <IpadicEntry> >(() => new MeCabIpadic(new MeCabParam { DicDir = Path.Combine(dataDir, "mecab", "ipadic") })); kernel.Bind <IMorphologicalAnalyzer <IEntry>, IMorphologicalAnalyzer <IpadicEntry> >(); kernel.BindFactory(get => new RadicalRemapper(get.Get <JDict.Kradfile>(), get.Get <Radkfile>())); kernel.BindFactory(get => EasilyConfusedKana.FromFile(Path.Combine(dataDir, "character", "confused.txt"))); kernel.Bind <IKanjiProperties, KanjiProperties>(); kernel.BindFactory(get => new KanjiProperties( get.Get <KanjiDict>(), get.Get <JDict.Kradfile>(), get.Get <Radkfile>(), null)); kernel.Bind <IRomaji, ModifiedHepburn>(); kernel.BindFactory(get => new ModifiedHepburn( get.Get <IMorphologicalAnalyzer <IEntry> >(), get.Get <IKanaProperties>())); kernel.BindFactory(get => new AutoGlosserNext(get.Get <ISentenceParser>(), get.Get <JMDictLookup>(), get.Get <IKanaProperties>())); kernel.Bind <IKanaProperties, KanaProperties2>(); kernel.BindFactory(get => new KanaProperties2(Path.Combine(dataDir, "character", "kana.txt"), Encoding.UTF8)); kernel.BindFactory(get => new SimilarKanji(Path.Combine(dataDir, "character", "kanji.tgz_similars.ut8"), Encoding.UTF8)); kernel.BindFactory <IRelated>(get => new CompositeRelated( get.Get <KanaProperties2>(), get.Get <EasilyConfusedKana>(), get.Get <SimilarKanji>())); kernel.BindFactory(get => CreateEpwing(Path.Combine(dataDir, "epwing"))); kernel.BindFactory(get => new IdiomDetector(get.Get <JMDictLookup>(), get.Get <IMorphologicalAnalyzer <IpadicEntry> >(), Path.Combine(dataDir, "dictionaries", "idioms.cache"))); kernel.BindFactory(get => new PartialWordLookup(get.Get <JMDictLookup>(), get.Get <IRadicalSearcher>(), get.Get <KanjiRadicalLookup>())); kernel.BindFactory(get => { using (var reader = File.OpenText(Path.Combine(dataDir, "character", "radkfile1_plus_2_utf8"))) return(new KanjiRadicalLookup(Radkfile.Parse(reader), get.Get <KanjiDict>())); }); kernel.BindFactory <IJGramLookup>(get => new JGramLookup( Path.Combine(dataDir, "dictionaries", "jgram"), Path.Combine(dataDir, "dictionaries", "jgram_lookup"), Path.Combine(dataDir, "dictionaries", "jgram.cache"))); kernel.BindFactory(get => new RadkfileKanjiAliveCorrelator(Path.Combine(dataDir, "character", "radkfile_kanjilive_correlation_data.txt"))); kernel.Bind <IRadicalSearcher, RadicalSearcher>(); kernel.BindFactory(get => new SentenceParser(get.Get <IMorphologicalAnalyzer <IEntry> >(), get.Get <JMDictLookup>(), get.Get <IKanaProperties>())); kernel.Bind <ISentenceParser, SentenceParser>(); kernel.BindFactory(get => new RadicalSearcher( get.Get <KanjiRadicalLookup>().AllRadicals, KanjiAliveJapaneseRadicalInformation.Parse(Path.Combine(dataDir, "character", "japanese-radicals.csv")), get.Get <RadkfileKanjiAliveCorrelator>())); kernel.BindFactory(get => new Corpus(get.Get <Tanaka>().AllSentences, get.Get <IMorphologicalAnalyzer <IpadicEntry> >(), Path.Combine(dataDir, "corpora", "tanaka.cache"))); /* * kernel.BindFactory<IFontResolver>(() => new DefaultFontResolver(Path.Combine(dataDir, "character", "KanjiStrokeOrders"))); * kernel.BindFactory(get => new MainWindowVM( * get.Get<IMorphologicalAnalyzer<IEntry>>(), * new KanaBoardVM(Path.Combine(dataDir, "character", "hiragana_romaji.txt"), Encoding.UTF8), * new KanaBoardVM(Path.Combine(dataDir, "character", "katakana_romaji.txt"), Encoding.UTF8), * get.Get<IEnumerable<UsageDataSourcePreviewVM>>(), * get.Get<KanjiRadicalLookupControlVM>(), * get.Get<IRelated>(), * get.Get<IKanjiProperties>(), * get.Get<IKanaProperties>(), * get.Get<IWebBrowser>(), * () => File.ReadAllText(Path.Combine(dataDir, @"about.txt"), Encoding.UTF8), * get.Get<ITextInsertCommand>())); * kernel.BindFactory(get => new KanjiRadicalLookupControlVM( * get.Get<KanjiRadicalLookup>(), * get.Get<IKanjiProperties>(), * get.Get<IRadicalSearcher>(), * CreateTextRadicalMappings(get.Get<KanjiRadicalLookup>().AllRadicals, get.Get<RadkfileKanjiAliveCorrelator>()))); * kernel.BindFactory(get => new[] { * new DataSourceVM(new CharacterDataSource(get.Get<IKanjiProperties>(), get.Get<IKanaProperties>()), get.Get<IFlowDocumentRichFormattingRenderer>()), * new DataSourceVM(new CharacterStrokeOrderDataSource(), get.Get<IFlowDocumentRichFormattingRenderer>()), * new DataSourceVM(new JMDictDataSource(get.Get<JMDict>(), get.Get<IKanaProperties>()), get.Get<IFlowDocumentRichFormattingRenderer>()), * new DataSourceVM(new JNeDictDataSource(get.Get<Jnedict>()), get.Get<IFlowDocumentRichFormattingRenderer>()), * new DataSourceVM(new VerbConjugationDataSource(get.Get<JMDict>()), get.Get<IFlowDocumentRichFormattingRenderer>()), * new DataSourceVM(new WordFrequencyRatingDataSource(get.Get<FrequencyList>()), get.Get<IFlowDocumentRichFormattingRenderer>()), * new DataSourceVM(new PartialExpressionJMDictDataSource(get.Get<IdiomDetector>()), get.Get<IFlowDocumentRichFormattingRenderer>()), * new DataSourceVM(new JGramDataSource(get.Get<IJGramLookup>()), get.Get<IFlowDocumentRichFormattingRenderer>()), * new DataSourceVM(new AutoGlosserDataSource(get.Get<AutoGlosser>()), get.Get<IFlowDocumentRichFormattingRenderer>()), * new DataSourceVM(new CustomNotesDataSource(Path.Combine(dataDir, "custom", "custom_notes.txt")), get.Get<IFlowDocumentRichFormattingRenderer>()), * new DataSourceVM(new TanakaCorpusFastDataSource(get.Get<Corpus>()), get.Get<IFlowDocumentRichFormattingRenderer>()), * new DataSourceVM(new TanakaCorpusDataSource(get.Get<Tanaka>()), get.Get<IFlowDocumentRichFormattingRenderer>()), * new DataSourceVM(new BasicExpressionCorpusDataSource(get.Get<BasicExpressionsCorpus>()), get.Get<IFlowDocumentRichFormattingRenderer>()), * new DataSourceVM(new PartialWordLookupJMDictDataSource(get.Get<PartialWordLookup>(), get.Get<FrequencyList>()), get.Get<IFlowDocumentRichFormattingRenderer>()), * new DataSourceVM(new JESCDataSource(get.Get<JESC>()), get.Get<IFlowDocumentRichFormattingRenderer>()), * new DataSourceVM(new RomajiDataSource(get.Get<IRomaji>()), get.Get<IFlowDocumentRichFormattingRenderer>()) * }.Concat(get.Get<EpwingDictionaries>().Dictionaries.Select(dict => new DataSourceVM(new EpwingDataSource(dict, get.Get<IKanaProperties>()), get.Get<IFlowDocumentRichFormattingRenderer>(), dict.Revision)))); * kernel.BindFactory<IEnumerable<UsageDataSourcePreviewVM>>(get => new[]{ * new UsageDataSourcePreviewVM(get.Get<IEnumerable<DataSourceVM>>(), "view.config"), * new UsageDataSourcePreviewVM(get.Get<IEnumerable<DataSourceVM>>(), "view_2.config"), * new UsageDataSourcePreviewVM(get.Get<IEnumerable<DataSourceVM>>(), "view_3.config") * }); * kernel.BindFactory<IWebBrowser>(get => new WebBrowser()); * kernel.BindFactory<IFlowDocumentRichFormattingRenderer>(get => new FlowDocumentRichFormattingRenderer(get.Get<IFontResolver>(), get.Get<IWebBrowser>())); */ return(kernel); IReadOnlyDictionary <CodePoint, string> CreateTextRadicalMappings(IEnumerable <CodePoint> radicals, IReadOnlyDictionary <int, int> remapper) { var dict = radicals.ToDictionary( r => r, r => char.ConvertFromUtf32(remapper.GetValueOrNone(r.Utf32).ValueOr(r.Utf32))); /*var d = new Dictionary<int, int> * { * {'化', '⺅'}, * {'刈', '⺉'}, * {'込', '⻌'}, * {'汁', '氵'}, * {'初', '衤'}, * {'尚', '⺌'}, * {'買', '罒'}, * {'犯', '犭'}, * {'忙', '忄'}, * {'礼', '礻'}, * {'个', 131490}, * {'老', '⺹'}, * {'扎', '扌'}, * {'杰', '灬'}, * {'疔', '疒'}, * {'禹', '禸'}, * {'艾', '⺾'}, * //{'邦', '⻏'}, * //{'阡', '⻖'}, * // 并 none available - upside-down ハ * };*/ dict[CodePoint.FromInt('邦')] = "邦"; dict[CodePoint.FromInt('阡')] = "阡"; dict[CodePoint.FromInt('老')] = "⺹"; dict[CodePoint.FromInt('并')] = "丷"; dict[CodePoint.FromInt('乞')] = "𠂉"; return(dict); } EpwingDictionaries CreateEpwing(string targetPath) { var dictionaries = new EpwingDictionaries(); try { var dicts = Directory.EnumerateFiles(targetPath, "*.zip") .Select(file => new YomichanTermDictionary(file, file + ".cache")); foreach (var dict in dicts) { dictionaries.Add(dict); } } catch (DirectoryNotFoundException) { } catch (InvalidOperationException ex) { throw new InvalidOperationException(ex.Message + "\nIt was not possible to load the EPWING external dictionary."); } return(dictionaries); } }