static void Main(string[] args) { var parser = new TextParser(); var textLines = File.ReadAllLines(args[0]); var textWords = textLines.Select(parser.SplitToWords).Select(dummy => dummy.ToList()).ToList(); var invertIndex = parser.BuildInvertIndex(textWords); var queriesLines = File.ReadAllLines(args[1]); var queriesWords = queriesLines.Select(line => parser.SplitToWords(line)).ToList(); var finder = new Finder(); var replies = queriesWords.Select(querie => finder.Find(invertIndex, querie)).ToList(); Printer.PrintResult(replies, ",", 20); }
public void BuildInvertIndexTest_wordIn1Line() { var allLines = new List<List<string>>() { new List<string>() {"123", "abcd", "eee"}, new List<string>() {"awaw", "abcd", "iii", "ewrjhgbw"}, }; var parser = new TextParser(); var actualInvertIndex = parser.BuildInvertIndex(allLines); var linesNums = actualInvertIndex["iii"]; Assert.AreEqual(linesNums[0], 1); //Assert.AreEqual(actualInvertIndex["abcd"],new List<int>(){0,1}); }
public void BuildInvertIndexTest_empty() { var allLines = new List<List<string>>() { new List<string>() {"123", "abcd", "eee"}, new List<string>() {"awaw", "abcd", "iii", "ewrjhgbw"}, }; var parser = new TextParser(); var actualInvertIndex = parser.BuildInvertIndex(allLines); Assert.IsFalse(actualInvertIndex.ContainsKey("q")); Assert.IsFalse(actualInvertIndex.ContainsKey("")); }