Exemplo n.º 1
0
        //internal static void Run()
        //{
        //    string s;
        //    while (!string.IsNullOrEmpty(s = Console.ReadLine()))
        //    {
        //        if (_store.EntriesByReading.TryGetValue(s, out var entries))
        //        {
        //            foreach (var entry in entries)
        //            {
        //                Console.WriteLine($"Id: {entry.Id}");
        //                Console.WriteLine($"Readings: {string.Join(", ", entry.Readings)}");
        //                Console.WriteLine("Glosses:");
        //                foreach (var gloss in entry.Glosses)
        //                    Console.WriteLine($"    {gloss}");
        //                Console.WriteLine();
        //            }
        //        }
        //        else
        //        {
        //            Console.WriteLine($"Could not find '{s}'.");
        //        }
        //    }
        //}

        //internal static bool TryLookupKanji(string term, [NotNullWhen(true)] out List<DictionaryEntry>? entry)
        //{
        //    return _store.EntriesByKanji.TryGetValue(term, out entry);
        //}

        //internal static bool TryLookupReading(string term, [NotNullWhen(true)] out List<DictionaryEntry>? entry)
        //{
        //    return _store.EntriesByReading.TryGetValue(term, out entry);
        //}

        private static DictionaryStore LoadStore()
        {
            var stopwatch = new Stopwatch();

            Console.WriteLine("Loading JMdict...");
            stopwatch.Start();

            var store = DictionaryStore.Load(@"C:\Data\OneDrive\Study & Practice\Japanese\JMdict\JMdict_e.xml");

            stopwatch.Stop();
            Console.WriteLine($"Loaded JMdict in {stopwatch.Elapsed}.");
            Console.WriteLine($"Loaded {store.EntriesByReading.Count} unique readings");

            return(store);
        }