public async Task SetupAsync()
        {
            var fileInfo = await _dictionaryProvider.GetSimilarKeiseiFileAsync();

            var serialzer = new JsonSerializer();

            using (var fs = fileInfo.OpenRead())
                using (var sr = new StreamReader(fs))
                    using (var jtr = new JsonTextReader(sr))
                    {
                        var raw = serialzer.Deserialize <SimilarModelRaw>(jtr);

                        Model = SafeMap <List <SimilarKanji> > .Create(raw, list => list.Select(x => new SimilarKanji
                        {
                            Value = x,
                            Score = 0.65,             // Default score for Keisei dictionary.
                        }).ToList());
                    }
        }
Ejemplo n.º 2
0
        public async Task SetupAsync()
        {
            var fileInfo = await _dictionaryProvider.GetSimilarNotoFileAsync();

            var serialzer = new JsonSerializer();

            using (var fs = fileInfo.OpenRead())
                using (var sr = new StreamReader(fs))
                    using (var jtr = new JsonTextReader(sr))
                    {
                        var raw = serialzer.Deserialize <SimilarModelWithScoreRaw>(jtr);

                        Model = SafeMap <List <SimilarKanji> > .Create(raw, list => list.Select(x => new SimilarKanji
                        {
                            Value = x.Kan,
                            Score = x.Score + 0.1,             // Add base score.
                        }).ToList());
                    }
        }