Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        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});

        }
Exemplo n.º 3
0
        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(""));

        }