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(); }
public List <string> GetCommands() { List <string> commands = new List <string>(); var _first = FullWordObjects.First(); var _last = FullWordObjects.Last(); var _run = _first; while (HasNext(_run)) { if (_run.Contains("[>") && _run.Contains(";")) { commands.Add(_run.Value.ExtendRightTo(text: CurrentText, to: ";")); } _run = Next(_run); if (_run == null) { System.Console.Write(_run.PrintAllProperties()); } } return(commands); }
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; } }