Beispiel #1
0
        private void AttachWordFrequency(List <VocabEntity> vocabList, Dictionary <string, List <VocabEntity> > fullDictionary)
        {
            DateTime before = DateTime.Now;

            foreach (string line in FileReadingHelper.ReadLineByLine(PathHelper.WordUsagePath, Encoding.UTF8))
            {
                if (!string.IsNullOrWhiteSpace(line))
                {
                    string[] split = line.Trim().Split('|');
                    long?    rank  = ParsingHelper.ParseLong(split[0]);
                    if (split.Count() == 3 && rank.HasValue)
                    {
                        string kanjiReading = split[1];
                        string kanaReading  = split[2];
                        string vocabString  = kanjiReading + "|" + kanaReading;
                        if (fullDictionary.ContainsKey(vocabString))
                        {
                            foreach (VocabEntity match in fullDictionary[vocabString])
                            {
                                match.FrequencyRank = (int)rank.Value;
                            }
                        }
                    }
                }
            }
            TimeSpan duration = DateTime.Now - before;

            _log.InfoFormat("Attaching word frequency took {0}ms.", (long)duration.TotalMilliseconds);
        }
Beispiel #2
0
        private void AttachWordFrequencyOnSingleKanaMatch()
        {
            _log.InfoFormat("Attaching word frequency on single kana match...");
            VocabDao dao = new VocabDao();

            dao.OpenMassTransaction();
            foreach (string line in FileReadingHelper.ReadLineByLine(PathHelper.WordUsagePath, Encoding.UTF8))
            {
                if (!string.IsNullOrWhiteSpace(line))
                {
                    string[] split = line.Trim().Split('|');
                    long?    rank  = ParsingHelper.ParseLong(split[0]);
                    if (split.Count() == 3 && rank.HasValue)
                    {
                        string kanjiReading = split[1];
                        string kanaReading  = split[2];
                        if (kanjiReading == kanaReading)
                        {
                            if (dao.UpdateFrequencyRankOnSingleKanaMatch(kanaReading, (int)rank.Value))
                            {
                                _log.InfoFormat("{0} has a frequency of {1}", kanaReading, rank.Value);
                            }
                        }
                    }
                }
            }
            dao.CloseMassTransaction();
        }