Esempio n. 1
0
        /// <summary>
        /// 找到字幕中的生词,先进行分词,然后取每个单词的原型,然后看每个单词是否认识,认识则跳过,不认识则注释。
        /// </summary>
        /// <param name="subtitles"></param>
        /// <returns></returns>
        private IDictionary <string, SubtitleWord> PickNewWords(IList <SubtitleLine> subtitles)
        {
            Dictionary <string, SubtitleWord> result = new Dictionary <string, SubtitleWord>();
            var knownVocabulary = dbOperator.FindAll <UserVocabulary>(v => v.KnownStatus == KnownStatus.Known).Select(v => v.Word).ToList();
            var texts           = subtitles.Select(s => s.EnglishText).ToList();

            foreach (var line in texts)
            {
                var array = line.Split(new char[] { ' ', ',', '.', '?', ':', '!' }, StringSplitOptions.RemoveEmptyEntries);
                foreach (string word in array)
                {
                    if (IsEnglishName(word))
                    {
                        //英文名,忽略
                        continue;
                    }
                    var original = englishWordService.GetOriginalWord(word);
                    if (knownVocabulary.Contains(word) || knownVocabulary.Contains(original))
                    {
                        //认识的单词,忽略
                        continue;
                    }

                    if (result.ContainsKey(original))
                    {
                        //重复的单词
                        continue;
                    }

                    var mean = RemarkWord(original);
                    if (mean != null)
                    {
                        result.Add(original, new SubtitleWord()
                        {
                            Word = original, WordInSubitle = word, Means = mean.Means, SubtitleSentence = line
                        });
                    }
                }
            }
            return(result);
        }
Esempio n. 2
0
        public void TestVerbIng(string word, string result)
        {
            var o = service.GetOriginalWord(word);

            Assert.AreEqual(o, result);
        }