Пример #1
0
        public void SplitToWord_0word_Test()
        {
            string str = "";
            var parser = new TextParser();
            var words = parser.SplitToWords(str);
            var expected = new string[] { };
            Assert.IsTrue(ArrayEquals(expected, words));


        }
Пример #2
0
 public void SplitToWordTest()
 {
     string str = "qwerty 123 asdf";
     var parser = new TextParser();
     var words=parser.SplitToWords(str);
     var expected = new string[] {"qwerty", "123", "asdf"};
     Assert.IsTrue(ArrayEquals(expected, words));
     
    
 }
Пример #3
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);
        }
Пример #4
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});

        }
Пример #5
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(""));

        }