Ejemplo n.º 1
0
        public TextProcessor(string text)
        {
            Input       = text;
            Input       = HttpUtility.HtmlDecode(Input);
            CurrentText = Input;
            CurrentText = CurrentText.StripHtml().ToStandard();

            var _models = CurrentText.ToWords();

            _models = _models.Where(t => t.IsWord()).ToArray();
            for (int i = 0; i < _models.Length; i++)
            {
                var _word = new Word(_models[i]);

                if (_word.CanRead())
                {
                    WordObject _object = new WordObject(_models[i], i);
                    _object.Indexs = CurrentText.IndexAll(_word.Value);
                    FullWordObjects.Add(_object);
                    _object.ToClean();
                    if (_object.IsClean())
                    {
                        CleanWordObjects.Add(_object);
                    }
                }
            }
            CountOfWords     = CleanWordObjects.Count;
            CountOfFullWords = FullWordObjects.Count;
            TimeToRead       = CountOfWords / 200; //Normal read speed
            LoadFull();
        }
Ejemplo n.º 2
0
        public string[] GetVnKeywords()
        {
            var _keywords = CleanWordObjects
                            .Where(t => t.IsVnKeyword())
                            .Select(t => t.Value)
                            .Distinct()
                            .ToArray();

            return(_keywords);
        }
Ejemplo n.º 3
0
 public void LoadFull()
 {
     Words        = FullWordObjects.Select(t => t.Value).ToList();
     EnglihsWords = CleanWordObjects.Where(t => t.Lang == WordLang.English)
                    .Select(t => t.Value.ToLower())
                    .Distinct()
                    .ToList();
     VietnameseWords = CleanWordObjects.Where(t => t.Lang == WordLang.Vietnamese)
                       .Select(t => t.Value.ToLower())
                       .Distinct()
                       .ToList();
     Numbers = CleanWordObjects.Where(t => t.IsNumber())
               .Select(t => t.Value.ToLower())
               .Distinct()
               .ToList();
     UrlLinks = CleanWordObjects.Where(t => t.Value.IsUrl())
                .Select(t => t.Value.ToLower())
                .Distinct()
                .ToList();
     Emails = CleanWordObjects.Where(t => t.Value.IsEmail())
              .Select(t => t.Value.ToLower())
              .Distinct()
              .ToList();
     Sentences = CurrentText.GetSentences()
                 .Distinct()
                 .ToList();
     QuestionSentences = GetQuestionSentences();
     CountOfQuestions  = QuestionSentences.Count();
     try
     {
         Phrases   = GetPhrases().ToList();
         MathExprs = GetMathExprs().ToList();
         Commands  = GetCommands();
         MakeOutput();
     }
     catch
     {
         return;
     }
 }
Ejemplo n.º 4
0
 public IEnumerable <WordObject> GetWordsBy(WordLang lang)
 {
     return(CleanWordObjects.Where(t => t.Lang == lang));
 }