private void btnOK_Click(object sender, EventArgs e)
        {
            var userRank = numUserVocabularyRank.Value;
            //DbOperator dbOperator= DbOperator.Instance;
            //var words = dbOperator.FindAll<VocabularyRank>(v => v.RankValue >= numUserVocabularyRank.Value);
            var     words      = InnerDictionaryHelper.GetAllVocabularyRanks();
            Service service    = new Service();
            var     vocabulary = new List <Vocabulary>();

            foreach (var vocabularyRank in words)
            {
                if (vocabularyRank.Value >= userRank)
                {
                    vocabulary.Add(new Vocabulary()
                    {
                        Word = vocabularyRank.Key, IsKnown = true
                    });
                }
            }
            service.SaveUserVocabulary(vocabulary, "柯林斯词频分级");
            logger.Debug("柯林斯词频分级保存成功");
            MessageBox.Show("用户词频设置保存成功");
            //RegistryHelper.WTRegedit("Used","Yes");
            DialogResult = DialogResult.OK;
            //this.Close();
        }
        private int GetRank(string word)
        {
            var rankData = InnerDictionaryHelper.GetAllVocabularyRanks();

            if (rankData.ContainsKey(word))
            {
                return(rankData[word]);
            }
            return(-1);
            //if (rankData == null)
            //{
            //    rankData = dbOperator.GetAll<VocabularyRank>();
            //}
            //var x = rankData.SingleOrDefault(r => r.Word == word);
            //if (x == null)
            //{
            //    return -1;
            //}
            //return x.RankValue;
        }
Example #3
0
        //private IList<VocabularyRank> vocabularyRanks;
        //private VocabularyRank GetVocabularyRank(string word)
        //{
        //  if (vocabularyRanks == null||vocabularyRanks.Count==0)
        //    {
        //        vocabularyRanks = dbOperator.GetAll<VocabularyRank>();
        //    }
        //    return (vocabularyRanks.Where(v => v.Word == word).FirstOrDefault());
        //}
        private string CalcAndGetWordAndMean(string word)
        {
            var vocabulary = GetUserVocabulary(word);

            if (vocabulary != null)
            {
                if (vocabulary.KnownStatus == KnownStatus.Known)
                {
                    //用户认识这个词,那么就不用替换
                    return("");
                }
                else //用户的生词表中有这个词,
                {
                    return(word);
                }
            }
            //用户词汇中没有这个词,那么就查询词频分级表,看有没有分级信息
            var rankData = InnerDictionaryHelper.GetAllVocabularyRanks();

            //var rank = GetVocabularyRank(word);
            if (!rankData.ContainsKey(word))
            {
                return(word);
            }
            var rank = rankData[word];


            if (rank < 4)
            {
                return(word);
            }
            else
            {
                return("");
            }
        }