/// <summary> /// Get all operators from user input text. /// </summary> /// <param name="userInputText">User input text.</param> /// <param name="invertedIndex">The inverted index that we are going to run operators on it.</param> /// <returns>List of all operators order by priority.</returns> public static List <IOperator> GetAllOperators(string userInputText, InvertedIndex invertedIndex) { var operatorExtractor = new OperatorExtractor(userInputText); var operators = new List <IOperator>(); while (!operatorExtractor.EndOfText()) { operators.Add(operatorExtractor.GetNextOperator(invertedIndex)); } return(operators.OrderBy(op => op.Priority).ToList()); }
static void Main(string[] args) { IUserInterface ui = new ConsoleUI(); var dataPath = ui.UserDataPath; var fileReader = new FileReader(dataPath); var directoryData = fileReader.GetRawData(); var invertedIndex = new InvertedIndex(); foreach (KeyValuePair <string, string> pair in directoryData) { invertedIndex.InsertDatas(Tokenizer.GetAllTokens(pair.Key, pair.Value)); } var userInputText = ui.UserInput; var operators = OperatorExtractor.GetAllOperators(userInputText, invertedIndex); var result = new Searcher().RunOperators(operators); ui.ShowOutput(result); }